[Pkg-samba-maint] Bug#905954: samba: Logrotate for /var/log/samba/log.smbd fails if samba is in AD mode

Yannik dc1 at mester-fehmarn.de
Sun Aug 12 10:47:23 BST 2018

Package: samba
Version: 2:4.5.12+dfsg-2+deb9u2
Severity: normal

Dear Maintainer,

I'm using samba 4 in AD mode. Therefore, smbd and nmbd services are
disabled, and the samba-ad-dc service is enabled.

The logrotate conf included with samba (/etc/logrotate.d/samba) 
only checks if a smbd pid exists (which it does, as samba-ad-dc
has an active smbd process), and tries to reload the (disabled)
smbd service, which subsequently fails.

Relevant logrotate error output:

  smbd.service is not active, cannot reload.
  error: error running non-shared postrotate script for
  /var/log/samba/log.smbd of '/var/log/samba/log.smbd '
  run-parts: /etc/cron.daily/logrotate exited with return code 1

In summary, this file should probably still be rotated (as the
samba-ad-dc smbd process logs to it), but the samba-ad-dc service
should be reloaded instead of the smbd service.

The following patch fixes the situation. The code is based on the
existing config for the /var/log/samba/log.samba file.

--- /etc/logrotate.d/samba	2018-03-05 14:30:11.000000000 +0100
+++ samba	2018-08-12 11:44:44.926253127 +0200
@@ -3,7 +3,11 @@
 	rotate 7
-		[ ! -f /var/run/samba/smbd.pid ] || /etc/init.d/smbd reload > /dev/null
+		if [ -d /run/systemd/system ] && command systemctl >/dev/null 2>&1 && systemctl is-active --quiet samba-ad-dc; then
+			systemctl kill --kill-who all --signal=SIGHUP samba-ad-dc
+		elif [ -f /var/run/samba/smbd.pid ]; then
+                        /etc/init.d/smbd reload > /dev/null
+                fi

-- System Information:
Debian Release: 9.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-7-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=locale: Cannot set LC_ALL to default locale: No such file or directory
UTF-8), LANGUAGE=en_US:en (charmap=locale: Cannot set LC_ALL to default locale: No such file or directory
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages samba depends on:
ii  adduser              3.115
ii  dpkg                 1.18.25
ii  init-system-helpers  1.48
ii  libbsd0              0.8.3-1
ii  libc6                2.24-11+deb9u3
ii  libldb1              2:1.1.27-1+b1
ii  libpam-modules       1.1.8-3.6
ii  libpam-runtime       1.1.8-3.6
ii  libpopt0             1.16-10+b2
ii  libpython2.7         2.7.13-2+deb9u2
ii  libtalloc2           2.1.8-1
ii  libtdb1              1.3.11-2
ii  libtevent0           0.9.31-1
ii  libwbclient0         2:4.5.12+dfsg-2+deb9u2
ii  lsb-base             9.20161125
ii  procps               2:3.3.12-3+deb9u1
ii  python               2.7.13-2
ii  python-dnspython     1.15.0-1
ii  python-samba         2:4.5.12+dfsg-2+deb9u2
ii  python2.7            2.7.13-2+deb9u2
ii  samba-common         2:4.5.12+dfsg-2+deb9u2
ii  samba-common-bin     2:4.5.12+dfsg-2+deb9u2
ii  samba-libs           2:4.5.12+dfsg-2+deb9u2
ii  tdb-tools            1.3.11-2
ii  update-inetd         4.44

Versions of packages samba recommends:
ii  attr                1:2.4.47-2+b2
ii  logrotate           3.11.0-0.1
ii  samba-dsdb-modules  2:4.5.12+dfsg-2+deb9u2
ii  samba-vfs-modules   2:4.5.12+dfsg-2+deb9u2

Versions of packages samba suggests:
ii  bind9          1:9.10.3.dfsg.P4-12.3+deb9u4
ii  bind9utils     1:9.10.3.dfsg.P4-12.3+deb9u4
pn  ctdb           <none>
pn  ldb-tools      <none>
pn  ntp | chrony   <none>
pn  smbldap-tools  <none>
pn  ufw            <none>
ii  winbind        2:4.5.12+dfsg-2+deb9u2

-- debconf information excluded

More information about the Pkg-samba-maint mailing list