From joes@shasta.wstein.com  Wed Apr 22 18:21:49 1998
Received: from shasta.wstein.com (joes@shasta.wstein.com [207.173.11.132])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA07086
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 22 Apr 1998 18:21:46 GMT
          (envelope-from joes@shasta.wstein.com)
Received: (from joes@localhost)
	by shasta.wstein.com (8.8.8/8.8.8) id LAA29419;
	Wed, 22 Apr 1998 11:21:38 -0700 (PDT)
Message-Id: <199804221821.LAA29419@shasta.wstein.com>
Date: Wed, 22 Apr 1998 11:21:38 -0700 (PDT)
From: Joseph Stein <joes@shasta.wstein.com>
Reply-To: joes@shasta.wstein.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: if pid_file is absent, newsyslog does not kill -HUP syslog
X-Send-Pr-Version: 3.2

>Number:         6385
>Category:       docs
>Synopsis:       if pid_file is absent, newsyslog does not kill -HUP syslog
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 22 11:30:01 PDT 1998
>Closed-Date:    Sun May 10 14:14:55 PDT 1998
>Last-Modified:  Sun May 10 14:20:39 PDT 1998
>Originator:     Joseph Stein
>Release:        FreeBSD 2.2.6-STABLE i386
>Organization:
Stein Family Internet Services
>Environment:

FreeBSD shasta.wstein.com 2.2.6-STABLE FreeBSD 2.2.6-STABLE #0: Tue Apr 14 20:37:14 PDT 1998     joes@shasta.wstein.com:/usr/src/sys/compile/SHASTA  i386

>Description:

	
	man (8) newsyslog states that newsyslog will remain compatible with
	old (prior to the addition of the pid_file) syslog.  This is not
	the case, as syslog does not get a HUP signal without it being
	explicitly mentioned in the config file. 
	(I've lost eight days of logs unknowningly because of this change).

	From reading the source code, at about line 495, this appears to be
	because of the logic that checks the flags:

	else if (needroot && !(flags & CE_BINARY))

	I do not like the new line that tells me the logs were turned over
	because the format is not consistent with syslog, so ALL my log files
	are 'BINARY' and marked with a 'B'.


>How-To-Repeat:

	
	Remove the pidfile from the config line in /etc/newsyslog.conf and
	run newsyslog.  Your log files will be truncated, but not written
	to again unless you manually signal syslog.

>Fix:
	
	
        at line 130, keep the syslog pid regardless of the status of 
	needroot;  (The logic for actually determining the pid in line
	130 is redundant, as pid is explicitly set to 0 at line 490)
	At line 495, Instead of checking
	whether the logfile is binary, check to make sure we have
	super-user permissions.  (Please double check my test for uid==0)

--- /usr/src/usr.sbin/newsyslog/newsyslog.c	Mon Apr 13 00:39:14 1998
+++ ./newsyslog.c	Wed Apr 22 11:09:16 1998
@@ -127,7 +127,7 @@
                 errx(1, "must have root privs");
         p = q = parse_file();
 
-	syslog_pid = needroot ? get_pid(PIDFILE) : 0;
+	syslog_pid = get_pid(PIDFILE);
 
         while (p) {
                 do_entry(p);
@@ -492,7 +492,7 @@
 	if (pid_file != NULL) {
 		need_notification = 1;
 		pid = get_pid(pid_file);
-	} else if (needroot && !(flags & CE_BINARY)) {
+	} else if (needroot && !(getuid() && geteuid())) {
 		need_notification = 1;
 		pid = syslog_pid;
 	}
	else if (needroot && !(flags & CE_BINARY))
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Sun May 10 14:14:55 PDT 1998 
State-Changed-Why:  
[the PR applied specifically to logfiles marked with B (BINARY)] 

Fixed in Rev. 1.19 of newsyslog.c.  If you are interested, that rev 
should run finely on -stable, otherwise, merge pending. 
>Unformatted:
