From nobody  Mon Oct 13 04:56:43 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.7/8.8.7) id EAA17286;
          Mon, 13 Oct 1997 04:56:43 -0700 (PDT)
          (envelope-from nobody)
Message-Id: <199710131156.EAA17286@hub.freebsd.org>
Date: Mon, 13 Oct 1997 04:56:43 -0700 (PDT)
From: jbrogan@reply.net
To: freebsd-gnats-submit@freebsd.org
Subject: sendmail writing to old maillogs after rotation
X-Send-Pr-Version: www-1.0

>Number:         4751
>Category:       conf
>Synopsis:       sendmail writing to old maillogs after rotation
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 13 05:00:01 PDT 1997
>Closed-Date:    Sun Oct 19 21:11:34 MEST 1997
>Last-Modified:  Mon Oct 20 11:00:01 PDT 1997
>Originator:     John Brogan
>Release:        2.2.2-RELEASE from CD
>Organization:
ReplyNet, Inc.
>Environment:
FreeBSD phillips.reply.net 2.2.2-RELEASE FreeBSD 2.2.2-RELEASE #0: Tue May 20 10:45:24 GMT 1997 jkh@time.cdrom.com:/usr/src/sys/compile/GENERIC i396
>Description:
We rotate the maillogs each morning at 12:01am.  This is using the
standard code FreeBSD had for many many prior versions.  The 2.2.2
release seems to be using newsyslog.conf to handle the logs so we
simply removed the maillogs entry from the newsyslog.conf file and
went back to using your regular maillog rotation scheme which worked
like a champ. 

Anyway, now when the maillogs are rotated as follows...

...
maillog.0 ----> maillog.1
maillog   ----> maillog.0

Just like it has always done.  But now sendmail will start writing
to maillog.0 instead of maillog where it's supposed to.  In fact,
I've even found times when it's writing to maillog.2 or even
maillog.3.  And when I actually *rename* a maillog it is writing
to.... it will write to that renamed version!  Real neat, but not
good.

What can I do to stop this writing to older maillog problem?
It is important because I try to keep logs of the entire day's
activity in each log.  It seems sendmail isn't letting go of the
file or something.

Any ideas?

Thanks much.

John Brogan
ReplyNet, Inc.

>How-To-Repeat:
rename maillog to maillog.keep or maillog.whatever and it should
write to that file.  rename maillog to maillog.0 and it should
also write to maillog.0 instead of maillog
>Fix:
Unknown.  Perhaps sendmail isn't "letting go" of the file when
it's done writing?
>Release-Note:
>Audit-Trail:

From: Martin Cracauer <cracauer@cons.org>
To: jbrogan@reply.net
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: conf/4751: sendmail writing to old maillogs after rotation
Date: Mon, 13 Oct 1997 15:19:21 +0200

 In <199710131156.EAA17286@hub.freebsd.org>, jbrogan@reply.net wrote: 
 > Anyway, now when the maillogs are rotated as follows...
 > 
 > ...
 > maillog.0 ----> maillog.1
 > maillog   ----> maillog.0
 > 
 > Just like it has always done.  But now sendmail will start writing
 > to maillog.0 instead of maillog where it's supposed to.  In fact,
 > I've even found times when it's writing to maillog.2 or even
 > maillog.3.  And when I actually *rename* a maillog it is writing
 > to.... it will write to that renamed version!  Real neat, but not
 > good.
 
 If you rename a file that is opened by a process, the file pointer
 inside that process will still point to the original file.
 
 daemons are supposed to reopen their log file on `kill -HUP` and
 scripts that rename logfiles are supposed to send -HUP to the daemon
 in question.
 
 "scripts" in this case is /usr/sbin/newsyslog, which needs to know
 where to find the pid. The third field in /etc/newsyslog.conf is
 supposed to point to a file where a daemon stores its pid file, but
 it's empty on my systems.
 
 Apparaently, this works in the usual FreeBSD case because the old
 files are compressed, which means removed to the writing process,
 which then tries reopening it. Am I right that you don't have 'Z' in
 your /etc/newsyslog.conf line or don't use newsyslog at all?
 
 John, if you have some time, could you please add
 "/var/run/sendmail.pid" as the last field to your /etc/newsyslog.conf,
 *not* enable compression and see if that solves your problem? Maybe
 you could test this for other lines in newsyslog.conf as well?
 
 Thanks for the report
 	Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
 BSD User Group Hamburg/Germany      http://www.bsdhh.org/

From: Peter Wemm <peter@netplex.com.au>
To: Martin Cracauer <cracauer@cons.org>, jbrogan@reply.net
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: conf/4751: sendmail writing to old maillogs after rotation 
Date: Tue, 14 Oct 1997 09:31:49 +0800

 Martin Cracauer wrote:
 >  In <199710131156.EAA17286@hub.freebsd.org>, jbrogan@reply.net wrote: 
 >  > Anyway, now when the maillogs are rotated as follows...
 >  > 
 >  > ...
 >  > maillog.0 ----> maillog.1
 >  > maillog   ----> maillog.0
 >  > 
 >  > Just like it has always done.  But now sendmail will start writing
 >  > to maillog.0 instead of maillog where it's supposed to.  In fact,
 >  > I've even found times when it's writing to maillog.2 or even
 >  > maillog.3.  And when I actually *rename* a maillog it is writing
 >  > to.... it will write to that renamed version!  Real neat, but not
 >  > good.
 >  
 >  If you rename a file that is opened by a process, the file pointer
 >  inside that process will still point to the original file.
 >  
 >  daemons are supposed to reopen their log file on `kill -HUP` and
 >  scripts that rename logfiles are supposed to send -HUP to the daemon
 >  in question.
 [..]
 >  John, if you have some time, could you please add
 >  "/var/run/sendmail.pid" as the last field to your /etc/newsyslog.conf,
 >  *not* enable compression and see if that solves your problem? Maybe
 >  you could test this for other lines in newsyslog.conf as well?
 
 Umm, no.. Sendmail does not write to log files.  It sends log messages to 
 syslogd via the /var/run/log socket.  syslogd needs the kill -HUP, not 
 sendmail.  Do *not* put /var/run/sendmail.pid into newsyslog.conf, that 
 will cause something completely different... (a kill -HUP to sendmail will 
 cause it to shutdown and re-exec itself)
 
 newsyslog(8) automatically sends a HUP signal to syslogd after rotation and
 before compression.  If you move the mail log rotation elsewhere, you need
 to add back the explicit kill -HUP to syslogd again.
 
 You can change the /etc/crontab entry that calls newsyslog so that it only 
 runs at 12:01am if you want.  You can also remove the 'Z' flag on the 
 maillog line if you want to keep uncompressed mail logs.  Surely that 
 would be simpler...
 
 Cheers,
 -Peter
 --
 Peter Wemm <peter@netplex.com.au>   Netplex Consulting
 
 

From: j@uriah.heep.sax.de (J Wunsch)
To: jbrogan@reply.net
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: conf/4751: sendmail writing to old maillogs after rotation
Date: Sat, 18 Oct 1997 13:33:12 +0200

 As jbrogan@reply.net wrote:
 
 > Just like it has always done.  But now sendmail will start writing
 > to maillog.0 instead of maillog where it's supposed to.  In fact,
 > I've even found times when it's writing to maillog.2 or even
 > maillog.3.  And when I actually *rename* a maillog it is writing
 > to.... it will write to that renamed version!  Real neat, but not
 > good.
 
 This means the file has been held open still by the writing process.
 Normally, sendmail is supposed to log via the syslog facility, and
 syslogd is supposed to get sent a SIGHUP after newsyslog ran, so in
 order to reopen the logfiles.
 
 Either your sendmail setup is screwed, or newsyslog fails somehow to
 notifiy syslogd.  Check who's holding the file open by saying:
 
 	fstat /var/log/maillog
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sun Oct 19 21:11:34 MEST 1997 
State-Changed-Why:  

No response from originator despite of various helpful hints. 

From: Martin Cracauer <cracauer@wavehh.hanse.de>
To: Peter Wemm <peter@netplex.com.au>
Cc: Martin Cracauer <cracauer@cons.org>, jbrogan@reply.net,
        freebsd-gnats-submit@freebsd.org
Subject: Re: conf/4751: sendmail writing to old maillogs after rotation
Date: Tue, 14 Oct 1997 12:42:59 +0200

 Ops, Peter is of course just right here. Please ignore my comments,
 they are applicable only if you use newsyslog to rotate logfiles from
 a daemon that doesn't use syslog (i.e. apache).
 
 In <199710140131.JAA24190@spinner.netplex.com.au>, Peter Wemm wrote: 
 > Martin Cracauer wrote:
 > >  In <199710131156.EAA17286@hub.freebsd.org>, jbrogan@reply.net wrote: 
 > >  > Anyway, now when the maillogs are rotated as follows...
 > >  > 
 > >  > ...
 > >  > maillog.0 ----> maillog.1
 > >  > maillog   ----> maillog.0
 > >  > 
 > >  > Just like it has always done.  But now sendmail will start writing
 > >  > to maillog.0 instead of maillog where it's supposed to.  In fact,
 > >  > I've even found times when it's writing to maillog.2 or even
 > >  > maillog.3.  And when I actually *rename* a maillog it is writing
 > >  > to.... it will write to that renamed version!  Real neat, but not
 > >  > good.
 > >  
 > >  If you rename a file that is opened by a process, the file pointer
 > >  inside that process will still point to the original file.
 > >  
 > >  daemons are supposed to reopen their log file on `kill -HUP` and
 > >  scripts that rename logfiles are supposed to send -HUP to the daemon
 > >  in question.
 > [..]
 > >  John, if you have some time, could you please add
 > >  "/var/run/sendmail.pid" as the last field to your /etc/newsyslog.conf,
 > >  *not* enable compression and see if that solves your problem? Maybe
 > >  you could test this for other lines in newsyslog.conf as well?
 > 
 > Umm, no.. Sendmail does not write to log files.  It sends log messages to 
 > syslogd via the /var/run/log socket.  syslogd needs the kill -HUP, not 
 > sendmail.  Do *not* put /var/run/sendmail.pid into newsyslog.conf, that 
 > will cause something completely different... (a kill -HUP to sendmail will 
 > cause it to shutdown and re-exec itself)
 > 
 > newsyslog(8) automatically sends a HUP signal to syslogd after rotation and
 > before compression.  If you move the mail log rotation elsewhere, you need
 > to add back the explicit kill -HUP to syslogd again.
 > 
 > You can change the /etc/crontab entry that calls newsyslog so that it only 
 > runs at 12:01am if you want.  You can also remove the 'Z' flag on the 
 > maillog line if you want to keep uncompressed mail logs.  Surely that 
 > would be simpler...
 > 
 > Cheers,
 > -Peter
 > --
 > Peter Wemm <peter@netplex.com.au>   Netplex Consulting
 > 
 > 
 
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin.Cracauer@wavehh.hanse.de http://www.cons.org/cracauer/
 BSD User Group Hamburg/Germany  http://www.bsdhh.org/ 
>Unformatted:
