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

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

 



On Tue, Feb 01, 2011 at 08:11:43PM -0500, Mike Frysinger wrote:
> 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");
> }

This seems to be a nice simplification. I'm just wondering - would
that require checking for daemon(3) in configure.ac? Is there any
universal rule that could help me to decide whether new check is
necessary?

Thanks,


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

Attachment: pgp30SO_Aqrwk.pgp
Description: PGP signature


[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