On Fri, Jun 12, 2015 at 10:30:18AM -0600, Todd C. Miller wrote:
> > I need a syslogd running in foreground for a project.  FreeBSD
> > also uses the option -F for that.
> 
> I don't have any objection to that.  A few comments inline.

Theo convinced me that this feature does not make sense for OpenBSD.

> Why move the close(lockfd) here?

I wanted both places were we close the lockpipe in a consistent
order.  Now I think we should compare the fd with 2 in both places
to have the same level of paranoia as with nullfd a few lines below.

ok for this part?

> Since "daemonize" is not a word, how about something like:
> 
> Run in the foreground instead of disassociating from the controlling
> terminal and running as a background daemon.

Thanks for your input.

bluhm

Index: usr.sbin/syslogd/privsep.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/privsep.c,v
retrieving revision 1.51
diff -u -p -r1.51 privsep.c
--- usr.sbin/syslogd/privsep.c  19 Jan 2015 16:40:49 -0000      1.51
+++ usr.sbin/syslogd/privsep.c  12 Jun 2015 18:41:07 -0000
@@ -151,10 +151,11 @@ priv_init(char *conf, int numeric, int l
        }
 
        if (!Debug) {
-               close(lockfd);
                dup2(nullfd, STDIN_FILENO);
                dup2(nullfd, STDOUT_FILENO);
                dup2(nullfd, STDERR_FILENO);
+               if (lockfd > 2)
+                       close(lockfd);
        }
        if (nullfd > 2)
                close(nullfd);
Index: usr.sbin/syslogd/syslogd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.162
diff -u -p -r1.162 syslogd.c
--- usr.sbin/syslogd/syslogd.c  12 Jun 2015 00:54:28 -0000      1.162
+++ usr.sbin/syslogd/syslogd.c  12 Jun 2015 18:40:30 -0000
@@ -632,7 +632,8 @@ main(int argc, char *argv[])
                dup2(nullfd, STDIN_FILENO);
                dup2(nullfd, STDOUT_FILENO);
                dup2(nullfd, STDERR_FILENO);
-               close(lockpipe[1]);
+               if (lockpipe[1] > 2)
+                       close(lockpipe[1]);
        }
        if (nullfd > 2)
                close(nullfd);

Reply via email to