NetBSD-Bugs archive

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

bin/46023: Add -S pidfile option to newsyslog(8)



>Number:         46023
>Category:       bin
>Synopsis:       Add -S pidfile option to newsyslog(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 15 11:00:00 +0000 2012
>Originator:     Bartosz Kuzma
>Release:        NetBSD 5.1/i386
>Organization:
>Environment:
>Description:
NetBSD newsyslog(8) uses hardcoded path to syslogd.pid to notificate syslogd 
that log files has been rotated. It might be problematic if you want to use non 
standard syslog e.g. wip/rsyslog5 which has different pid file location:

# newsyslog -F
newsyslog: /var/run/syslogd.pid: No such file or directory

There are several way to handle this problem
 1. Change newsyslog.conf and add pid files with new path
 2. Link /var/run/rsyslogd.pid to /var/run/syslogd.pid
 3. Provide configurable syslogd.pid path to newsyslog(8)

The following patch add -S pidfile option to newsyslog(8) which allows to 
overwrite the default syslogd.pid path.
>How-To-Repeat:

>Fix:
Index: newsyslog.8
===================================================================
RCS file: /cvsroot/src/usr.bin/newsyslog/newsyslog.8,v
retrieving revision 1.36
diff -u -r1.36 newsyslog.8
--- newsyslog.8 21 Dec 2007 19:45:33 -0000      1.36
+++ newsyslog.8 15 Feb 2012 10:54:34 -0000
@@ -50,6 +50,7 @@
 .Nm newsyslog
 .Op Fl nrsvF
 .Op Fl f Ar config_file
+.Op Fl S Ar pidfile
 .Op Pa file ...
 .Sh DESCRIPTION
 .Nm
@@ -393,6 +394,12 @@
 Force trimming of the logs, even if the trim conditions have not been met.
 This option is useful for diagnosing system problems by providing you with
 fresh logs.
+.It Fl S Ar pidfile
+Use 
+.Ar pidfile
+as
+.Xr syslogd 8
+pidfile.
 .El
 .Pp
 If additional command line arguments are given,
Index: newsyslog.c
===================================================================
RCS file: /cvsroot/src/usr.bin/newsyslog/newsyslog.c,v
retrieving revision 1.53.10.2
diff -u -r1.53.10.2 newsyslog.c
--- newsyslog.c 5 Sep 2009 12:58:07 -0000       1.53.10.2
+++ newsyslog.c 15 Feb 2012 10:54:34 -0000
@@ -130,6 +130,7 @@
 static char    hostname[MAXHOSTNAMELEN + 1];   /* Hostname, no domain */
 static uid_t   myeuid;                         /* EUID we are running with */
 static int     ziptype;                        /* compression type, if any */
+static const char      *path_syslogdpid = _PATH_SYSLOGDPID;    /* path to 
syslogd.pid */
 
 static int     getsig(const char *);
 static int     isnumber(const char *);
@@ -172,11 +173,14 @@
                *p = '\0';
 
        /* Parse command line options. */
-       while ((c = getopt(argc, argv, "f:nrsvF")) != -1) {
+       while ((c = getopt(argc, argv, "f:S:nrsvF")) != -1) {
                switch (c) {
                case 'f':
                        cfile = optarg;
                        break;
+               case 'S':
+                       path_syslogdpid = optarg;
+                       break;
                case 'n':
                        noaction = 1;
                        verbose = 1;
@@ -616,7 +620,7 @@
                if (log->pidfile[0] != '\0')
                        pid = readpidfile(log->pidfile);
                else
-                       pid = readpidfile(_PATH_SYSLOGDPID);
+                       pid = readpidfile(path_syslogdpid);
                
                if (pid != (pid_t)-1) {
                        PRINFO(("kill -%s %lu\n", 
@@ -729,7 +733,7 @@
 {
 
        (void)fprintf(stderr, 
-           "Usage: %s [-nrsvF] [-f config-file] [file ...]\n", getprogname());
+           "Usage: %s [-nrsvF] [-f config-file] [-S pidfile] [file ...]\n", 
getprogname());
        exit(EXIT_FAILURE);
 }
 



Home | Main Index | Thread Index | Old Index