Re: [PATCH] uuidd: use die() where possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday, February 01, 2011 10:19:13 Petr Uzel wrote:
> --- a/misc-utils/uuidd.c
> +++ b/misc-utils/uuidd.c
> @@ -63,12 +63,10 @@ static void create_daemon(void)
>  	uid_t euid;
> 
>  	pid = fork();
> -	if (pid == -1) {
> -		perror("fork");
> -		exit(1);
> -	} else if (pid != 0) {
> -	    exit(0);
> -	}
> +	if (pid == -1)
> +		die("fork");
> +	else if (pid != 0)
> +		exit(0);
> 
>  	close(0);
>  	close(1);

somewhat related, this code really should read something like:
create_daemon()
{
	uid_t euid;

	if (daemon(0, 0))
		die("daemon");

	euid = geteuid();
	if (setreuid(euid, euid) < 0)
		die("setreuid");
}
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux