logrotate script needs to be updated for Upstart conversion

Bug #529290 reported by Colin Watson
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
samba (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Binary package hint: samba

/etc/logrotate.d/samba produces error output, because the smbd stanza calls 'invoke-rc.d --quiet samba reload > /dev/null' in a postrotate stanza (no stderr redirection, nor should there be). This should be updated to use Upstart's facilities. I suspect the same may go for the nmbd stanza, which currently calls '[ ! -f /var/run/samba/nmbd.pid ] || kill -HUP `cat /var/run/samba/nmbd.pid`'.

Revision history for this message
Chuck Short (zulcss) wrote :

Will be fixed for lucid, thanks for the bug report.

Regards
chuck

Changed in samba (Ubuntu):
status: New → Confirmed
Revision history for this message
Chuck Short (zulcss) wrote :

Will get this fixed for lucid tomorow.

Regards
chuck

Changed in samba (Ubuntu):
status: Confirmed → Triaged
Thierry Carrez (ttx)
tags: added: bugzapping-target
Changed in samba (Ubuntu):
importance: Undecided → High
Chuck Short (zulcss)
Changed in samba (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package samba - 2:3.4.6~dfsg-1ubuntu3

---------------
samba (2:3.4.6~dfsg-1ubuntu3) lucid; urgency=low

  [Thierry Carrez]
  * debian/samba.postinst: Avoid scary pdbedit warnings on first import
    (LP: #24741)

  [Chuck Short]
  * debian/samba.logrotate: Make it upstart compatible (LP: #529290)
  * debian/samba-common.dhcp: Fix typo to get a proper parsing in /etc/samba/dhcp. (LP: #507374)
 -- Thierry Carrez <email address hidden> Thu, 11 Mar 2010 13:57:06 +0100

Changed in samba (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Simon Déziel (sdeziel) wrote :

The fix implemented in http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/lucid/samba/lucid/revision/99 is not working as the wrong pid is sent a HUP signal :

- invoke-rc.d --quiet samba reload > /dev/null
+ [ ! -f /var/run/samba/nmbd.pid ] || kill -HUP `cat /var/run/samba/nmbd.pid`

This was probably a copy-n-paste error and should corrected to be smbd.pid.

Revision history for this message
Simon Déziel (sdeziel) wrote :

I don't know what status to assign to this bug but the current situation isn't good as smbd processes will keep logging to the old log file. All this logging will be lost as it ends up in a "deleted" log file. Another potentially bad consequence is that the server might run out of space because of this hidden log file that grows without bounds.

Steps to observe the problem :

# Only one log file exists
ls /var/log/samba
cores log.smbd

# Force the rotation
logrotate -f /etc/logrotate.d/samba

# The log is rotated but the old log file is missing (was rm'ed but does not show in ls)
ls /var/log/samba
cores log.smbd.1.gz

# with lsof
lsof | grep log.smbd
smbd 6593 root 2w REG 251,1 524288000 783512 /var/log/samba/log.smbd.1 (deleted)
smbd 6593 root 27w REG 251,1 524288000 783512 /var/log/samba/log.smbd.1 (deleted)
smbd 6595 root 2w REG 251,1 343 783436 /var/log/samba/log.smbd.1 (deleted)
smbd 6595 root 8w REG 251,1 343 783436 /var/log/samba/log.smbd.1 (deleted)

# Instruct smbd to reopen the log file
kill -HUP `cat /var/run/samba/smbd.pid`

# Now the log.smbd finally appears
ls /var/log/samba
cores log.smbd log.smbd.1.gz

# lsof still shows problems
lsof | grep log.smbd
smbd 6593 root 2w REG 251,1 202 783521 /var/log/samba/log.smbd
smbd 6593 root 8w REG 251,1 202 783521 /var/log/samba/log.smbd
smbd 6595 root 2w REG 251,1 343 783436 /var/log/samba/log.smbd.1 (deleted)
smbd 6595 root 8w REG 251,1 343 783436 /var/log/samba/log.smbd.1 (deleted)

Maybe the solution is to use pkill -HUP smbd to notify all children to reopen the log file.

Revision history for this message
Simon Déziel (sdeziel) wrote :

Changing the kill -HUP `cat /var/run/samba/smbd.pid` for the upstart "reload" doesn't work either.

Revision history for this message
Simon Déziel (sdeziel) wrote :

This was partly fixed in revision 104 of the bzr branch for Natty. As already pointed out, this is only a partial fix as only one of the children is notified to reopen the log file.

Revision history for this message
Simon Déziel (sdeziel) wrote :

The upstart job tries to start smbd in foreground mode but apparently fails to do so :

standard input is not a socket, assuming -D option

Even if this foreground operation was to work, the man page says that child processes will still be created. Those too need to be notified about the log rotation IMO.

One of the possible solutions is to use smbcontrol to notify all related daemons (smbd, nmbd and winbindd) :

smbcontrol all reload-config

This problem was apparently introduced in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=160076 where killall was removed from the logrotate configuration.

Revision history for this message
Simon Déziel (sdeziel) wrote :

I opened a new bug (LP: 810736) for those child processes that continue to log to rotated files.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.