NetBSD Problem Report #46023

From www@NetBSD.org  Wed Feb 15 10:58:46 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 78F3463DE68
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 15 Feb 2012 10:58:46 +0000 (UTC)
Message-Id: <20120215105845.66E4963BCF4@www.NetBSD.org>
Date: Wed, 15 Feb 2012 10:58:45 +0000 (UTC)
From: bartosz.kuzma@gmail.com
Reply-To: bartosz.kuzma@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Add -S pidfile option to newsyslog(8)
X-Send-Pr-Version: www-1.0

>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
>Last-Modified:  Sat Sep 15 23:40:02 +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);
 }


>Audit-Trail:
From: Julian Djamil Fagir <gnrp@komkon2.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/46023: Add -S pidfile option to newsyslog(8)
Date: Sun, 16 Sep 2012 01:38:35 +0200

 --Sig_/DlN==.IG5=xOMcqhwbGGH=2
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: quoted-printable

 Hi,

 > 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:
 >=20
 > # newsyslog -F
 > newsyslog: /var/run/syslogd.pid: No such file or directory
 >=20
 > 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)

 I would still prefer option 1 over 3. That's what the configuration file is
 for. Plus, the behaviour should be more documented. I would expect to have
 the command line arguments *over* the configuration file, not being only the
 fallback in case there is no pidfile specified.

 Regards, Julian

 --Sig_/DlN==.IG5=xOMcqhwbGGH=2
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Disposition: attachment; filename=signature.asc

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (GNU/Linux)

 iEYEARECAAYFAlBVEXsACgkQc7h7cu1Hpp4Y6wCeL8gwer75XPrh4MBf3IRRDf9q
 koUAniZfNNAGUsE6nuBgLihxtu8rptI6
 =aGwy
 -----END PGP SIGNATURE-----

 --Sig_/DlN==.IG5=xOMcqhwbGGH=2--

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.