From nobody@FreeBSD.org  Tue Jan 15 19:38:20 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 7A4BE334
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Jan 2013 19:38:20 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 5CDE317D
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Jan 2013 19:38:20 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r0FJcJHk012670
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Jan 2013 19:38:19 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r0FJcJK1012669;
	Tue, 15 Jan 2013 19:38:19 GMT
	(envelope-from nobody)
Message-Id: <201301151938.r0FJcJK1012669@red.freebsd.org>
Date: Tue, 15 Jan 2013 19:38:19 GMT
From: Paul Procacci <pprocacci@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: newsyslog R flag ignored
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         175330
>Category:       bin
>Synopsis:       newsyslog(8): newsyslog R flag ignored
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    markj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 15 19:40:00 UTC 2013
>Closed-Date:    Sun Feb 17 19:55:14 UTC 2013
>Last-Modified:  Sun Feb 17 20:00:01 UTC 2013
>Originator:     Paul Procacci
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD prod.xxxx.com 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
Using the R flag in a newsyslog configuration file is being ignored by newsyslog.
>How-To-Repeat:
prod# cat /root/test.conf
/var/log/varnishncsa.log       644 10       * $D3  BR /usr/local/scripts/test.sh

-
--
-

prod# cat /usr/local/scripts/test.sh
#!/bin/sh

touch /tmp/test

-
--
-

prod# newsyslog -vF -f /root/test.conf
Processing /root/test.conf
/var/log/varnishncsa.log <10>: --> trimming log....
Signal all daemon process(es)...
Pause 10 seconds to allow daemon(s) to close log file(s)


* Notice, it never runs the command.  Test script works fine via command line, and permissions are correct.
>Fix:
Unknown, but I will do some debugging (time permitting).

>Release-Note:
>Audit-Trail:

From: Mark Johnston <markj@freebsd.org>
To: bug-followup@FreeBSD.org, pprocacci@gmail.com
Cc:  
Subject: Re: bin/175330: newsyslog R flag ignored
Date: Tue, 15 Jan 2013 15:45:52 -0500

 Hm, I can't seem to reproduce this on CURRENT or using the newsyslog
 from 9.0-RELEASE. The script does indeed seem to be ignored though -
 newsyslog should be printing "Run command: ..." in between the "Signal
 all ..." and "Pause 10 ..." messages.
 
 I don't see anything in the code that could be causing this though.
 Would you be able to send the output of
 
 # newsyslog -Fnv -f /root/test.conf
 
 and a copy of test.conf? (Or a trimmed-down version that still
 reproduces the problem.)
 
 Thanks!
 -Mark
Responsible-Changed-From-To: freebsd-bugs->markj 
Responsible-Changed-By: markj 
Responsible-Changed-When: Tue Jan 15 21:49:25 UTC 2013 
Responsible-Changed-Why:  
I will take this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175330 
State-Changed-From-To: open->analyzed 
State-Changed-By: markj 
State-Changed-When: Tue Jan 15 23:09:53 UTC 2013 
State-Changed-Why:  
The problem is now understood, I am working on a fix. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175330 

From: Mark Johnston <markj@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/175330: newsyslog R flag ignored
Date: Tue, 15 Jan 2013 18:06:45 -0500

 --Bn2rw/3z4jIqBvZU
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 I worked on this with the submitter and we managed to find the root
 cause - when the 'R' flag is specified for a newsyslog conf file entry,
 the sw_pidok and sw_pid fields of the corresponding sigwork_entry are
 left uninitialized. In the submitter's case, they happened to be 0,
 leading to an early return from do_sigwork() (which later uses
 system(3) to invoke the shell command).
 
 The attached patch fixes the problem.
 
 -Mark
 
 --Bn2rw/3z4jIqBvZU
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="newsyslog_pidok2.diff"
 
 Index: newsyslog.c
 ===================================================================
 --- newsyslog.c	(revision 245470)
 +++ newsyslog.c	(working copy)
 @@ -1852,7 +1852,7 @@
  	int kres, secs;
  	char *tmp;
  
 -	if (!(swork->sw_pidok) || swork->sw_pid == 0)
 +	if (swork->run_cmd == 0 && (!(swork->sw_pidok) || swork->sw_pid == 0))
  		return;			/* no work to do... */
  
  	/*
 @@ -2062,6 +2062,7 @@
  	stmp->run_cmd = 0;
  	/* If this is a command to run we just set the flag and run command */
  	if (ent->flags & CE_PID2CMD) {
 +		stmp->sw_pidok = stmp->sw_pid = 0;
  		stmp->run_cmd = 1;
  	} else {
  		set_swpid(stmp, ent);
 
 --Bn2rw/3z4jIqBvZU--
State-Changed-From-To: analyzed->patched 
State-Changed-By: markj 
State-Changed-When: Sun Jan 27 06:07:09 UTC 2013 
State-Changed-Why:  
Fixed in r245961. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175330 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/175330: commit references a PR
Date: Sun, 27 Jan 2013 06:01:43 +0000 (UTC)

 Author: markj
 Date: Sun Jan 27 06:01:35 2013
 New Revision: 245961
 URL: http://svnweb.freebsd.org/changeset/base/245961
 
 Log:
   When the 'R' flag is used with a newsyslog.conf entry, some fields of
   the corresponding struct sigwork_entry were left uninitialized,
   potentially causing an early return from do_sigwork(). Ensure that these
   fields are initialized, and handle the 'R' flag properly in
   do_sigwork().
   
   PR:		bin/175330
   Reviewed by:	gad
   Approved by:	rstone (co-mentor)
   MFC after:	1 week
 
 Modified:
   head/usr.sbin/newsyslog/newsyslog.c
 
 Modified: head/usr.sbin/newsyslog/newsyslog.c
 ==============================================================================
 --- head/usr.sbin/newsyslog/newsyslog.c	Sun Jan 27 05:59:28 2013	(r245960)
 +++ head/usr.sbin/newsyslog/newsyslog.c	Sun Jan 27 06:01:35 2013	(r245961)
 @@ -1866,7 +1866,7 @@ do_sigwork(struct sigwork_entry *swork)
  	int kres, secs;
  	char *tmp;
  
 -	if (!(swork->sw_pidok) || swork->sw_pid == 0)
 +	if (swork->run_cmd == 0 && (!(swork->sw_pidok) || swork->sw_pid == 0))
  		return;			/* no work to do... */
  
  	/*
 @@ -2078,6 +2078,8 @@ save_sigwork(const struct conf_entry *en
  	stmp->run_cmd = 0;
  	/* If this is a command to run we just set the flag and run command */
  	if (ent->flags & CE_PID2CMD) {
 +		stmp->sw_pid = -1;
 +		stmp->sw_pidok = 0;
  		stmp->run_cmd = 1;
  	} else {
  		set_swpid(stmp, ent);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Espen Tagestad <espen.tagestad@modirum.com>
To: bug-followup@FreeBSD.org,
 pprocacci@gmail.com
Cc:  
Subject: Re: bin/175330: newsyslog(8): newsyslog R flag ignored
Date: Fri, 8 Feb 2013 08:30:49 +0100

 --Apple-Mail=_5E0D85BC-9BC2-47E1-BF92-190AC26DCFC3
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 Will this fix be MFC'ed into a patch release of 9.1? We need this fix in =
 our environments, and right now we're manually patching newsyslogd.
 
 
 Br,
 Espen
 
 
 --Apple-Mail=_5E0D85BC-9BC2-47E1-BF92-190AC26DCFC3
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP using GPGMail
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
 
 iQIcBAEBAgAGBQJRFKmpAAoJEJKvBcv9GfX8cIQP/io4nr6wFHYqe+4wYV/j976O
 yN/f93Y6AV9iHHlczADIb3kELwU0SGz0zhxnPnZlqiyX787obSzTFNhdoBVrxFU7
 RlCtMMJtVgJdDYHNZbCxqcnY3d+rks3UDX5NIoCxSTqKBQ8foofl0n5GhHr1w8DK
 Nd1Xb9H2vvbAcfQensNizCUqdbv1OOCqyoBj76ZQiAxAElHsUAjW9XpgXUobSMfy
 UIgmq1nYtHBKHp9be6d+8ylXSH7RATYECRWWYIgv73XIrrOjR+9rx7AxLNzBSLhL
 BZEaBEWUurZa5ZleK6GwfaQ2IS0Pevv9eoGTrusq9EkO+GfzNVeqYoT0YnZ8Q68R
 qVyP08wIuvX3/q/JJvdcla8AFaXvPuSD/aWC3JkWaMzaf3Is4KyweyyGJOmyVWfR
 IjlY4TkFkHUcNyqQ7QPb/EGBoB9Po8fsw+7KP2X1dUj/0lIFGYzrz4/sQr6gIF2k
 QIBtbksmqFtJgr92nYG+z1wmK8Wr17P27xnjkDOjOy2hqD79ABzx8qpnpu68tPfr
 7aoYgbO//5e1eQIuGsH2nO15lQVIcI884G8graLIvlAuYdxIHKCSayVyP2T4B4VA
 F+OzJpra83yfBYCeo2TD763U+98jphLVJvaAcEvLrkOfYOswe/evuNnDv0ZYxTv+
 suy+tlWaW0SvGXuBXJcR
 =AhHi
 -----END PGP SIGNATURE-----
 
 --Apple-Mail=_5E0D85BC-9BC2-47E1-BF92-190AC26DCFC3--
State-Changed-From-To: patched->closed 
State-Changed-By: markj 
State-Changed-When: Sun Feb 17 19:55:13 UTC 2013 
State-Changed-Why:  
The fix was merged to stable/8 and stable/9. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175330 

From: Mark Johnston <markj@freebsd.org>
To: Espen Tagestad <espen.tagestad@modirum.com>, bug-followup@FreeBSD.org,
	pprocacci@gmail.com
Cc:  
Subject: Re: bin/175330: newsyslog(8): newsyslog R flag ignored
Date: Sun, 17 Feb 2013 14:53:57 -0500

 I've just MFCed the fix to stable/9 in r246918 and stable/8 in r246919,
 so the fix will appear in the next releases from those branches (8.4 and
 9.1).
 
 Thanks,
 -Mark
>Unformatted:
