Hi,

I need a syslogd running in foreground for a project.  FreeBSD
also uses the option -F for that.

Do we want this feature in OpenBSD?
ok?

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  11 Jun 2015 22:58:31 -0000
@@ -151,10 +151,10 @@ priv_init(char *conf, int numeric, int l
        }
 
        if (!Debug) {
-               close(lockfd);
                dup2(nullfd, STDIN_FILENO);
                dup2(nullfd, STDOUT_FILENO);
                dup2(nullfd, STDERR_FILENO);
+               close(lockfd);
        }
        if (nullfd > 2)
                close(nullfd);
Index: usr.sbin/syslogd/syslogd.8
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.8,v
retrieving revision 1.33
diff -u -p -r1.33 syslogd.8
--- usr.sbin/syslogd/syslogd.8  30 Jan 2015 14:09:49 -0000      1.33
+++ usr.sbin/syslogd/syslogd.8  11 Jun 2015 22:55:14 -0000
@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm syslogd
 .Bk -words
-.Op Fl 46dhnuV
+.Op Fl 46dFhnuV
 .Op Fl a Ar path
 .Op Fl C Ar CAfile
 .Op Fl f Ar config_file
@@ -85,6 +85,8 @@ and do not disassociate from the control
 Specify the pathname of an alternate configuration file;
 the default is
 .Pa /etc/syslog.conf .
+.It Fl F
+Do not daemonize and stay in foreground.
 .It Fl h
 Include the hostname when forwarding messages to a remote host.
 .It Fl m Ar mark_interval
Index: usr.sbin/syslogd/syslogd.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.161
diff -u -p -r1.161 syslogd.c
--- usr.sbin/syslogd/syslogd.c  30 Mar 2015 09:21:42 -0000      1.161
+++ usr.sbin/syslogd/syslogd.c  11 Jun 2015 22:59:10 -0000
@@ -205,6 +205,7 @@ struct      filed consfile;
 int    nunix = 1;              /* Number of Unix domain sockets requested */
 char   *path_unix[MAXUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */
 int    Debug;                  /* debug flag */
+int    Foreground;             /* run in foreground, instead of daemonizing */
 int    Startup = 1;            /* startup flag */
 char   LocalHostName[HOST_NAME_MAX+1]; /* our hostname */
 char   *LocalDomain;           /* our local domain name */
@@ -328,7 +329,7 @@ main(int argc, char *argv[])
        int              ch, i;
        int              lockpipe[2] = { -1, -1}, pair[2], nullfd, fd;
 
-       while ((ch = getopt(argc, argv, "46C:dhnuf:m:p:a:s:V")) != -1)
+       while ((ch = getopt(argc, argv, "46C:dhnuf:Fm:p:a:s:V")) != -1)
                switch (ch) {
                case '4':               /* disable IPv6 */
                        IPv4Only = 1;
@@ -347,6 +348,9 @@ main(int argc, char *argv[])
                case 'f':               /* configuration file */
                        ConfFile = optarg;
                        break;
+               case 'F':               /* foreground */
+                       Foreground = 1;
+                       break;
                case 'h':               /* RFC 3164 hostnames */
                        IncludeHostname = 1;
                        break;
@@ -557,7 +561,7 @@ main(int argc, char *argv[])
 
        tzset();
 
-       if (!Debug) {
+       if (!Debug && !Foreground) {
                char c;
 
                pipe(lockpipe);
@@ -969,7 +973,7 @@ usage(void)
 {
 
        (void)fprintf(stderr,
-           "usage: syslogd [-46dhnuV] [-a path] [-C CAfile] [-f config_file]\n"
+           "usage: syslogd [-46dFhnuV] [-a path] [-C CAfile] [-f 
config_file]\n"
            "               [-m mark_interval] [-p log_socket] [-s 
reporting_socket]\n");
        exit(1);
 }

Reply via email to