Package: samba
Version: 2:4.4.6+dfsg-2
Severity: minor

Dear Maintainer,

While apt upgrading my system today, I saw that samba failed in the postinstall

> Setting up samba (2:4.4.6+dfsg-2) ...
> Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is 
> masked.
> /usr/bin/deb-systemd-helper: error: systemctl preset failed on 
> samba-ad-dc.service: No such file or directory

... at least it looked like an error to me, so I started investigating.  It took
me 3 times systemctl-unmasking and reinstalling samba to notice that the service
is masked by the package itself in the postinstall script when samba is not
being run as a domain controller... :-)

The action which generates this message is produced by this debhelper section
in /var/lib/dpkg/info/samba.postinst:

> # Automatically added by dh_systemd_enable
> # This will only remove masks created by d-s-h on package removal.
> deb-systemd-helper unmask samba-ad-dc.service >/dev/null || true
> # was-enabled defaults to true, so new installations run enable.
> if deb-systemd-helper --quiet was-enabled samba-ad-dc.service; then
>       # Enables the unit on first installation, creates new
>       # symlinks on upgrades if the unit file has changed.
>       deb-systemd-helper enable samba-ad-dc.service >/dev/null || true
> else
>       # Update the statefile to add new symlinks (if any), which need to be
>       # cleaned up on purge. Also remove old symlinks.
>       deb-systemd-helper update-state samba-ad-dc.service >/dev/null || true
> fi
> # End automatically added section

Since this is auto-generated, it cannot easily be overwritten. However, to mark 
false negatives as such and reduce workload for admins, I suggest to be a bit
more verbose when masking the service, like this:

-------------------------------------- 8< --------------------------------------
diff --git a/debian/samba.postinst b/debian/samba.postinst
index 35b476f..cfea921 100644
--- a/debian/samba.postinst
+++ b/debian/samba.postinst
@@ -86,6 +86,9 @@ if [ "$SERVER_ROLE" != "active directory domain controller" ] 
        && ( echo "$DCERPC_ENDPOINT_SERVERS" | grep -qv '\(^\|, 
\)mapiproxy\(,\|$\)' ) \
 ; then
     if [ ! -e /etc/systemd/system/samba-ad-dc.service ]; then
+        echo "Samba is not being run as an AD Domain Controller, masking 
+        echo "Please ignore the following error about deb-systemd-helper not 
finding samba-ad-dc-service."
+        mkdir -p /etc/systemd/system
         mkdir -p /etc/systemd/system
         ln -s /dev/null /etc/systemd/system/samba-ad-dc.service
         # In case this system is running systemd, we make systemd reload the 
unit files
-------------------------------------- >8 --------------------------------------

As an alternative, try to patch deb-systemd-helper so it does correctly
determine that the service was masked, i.e. not enabled, when running
`deb-systemd-helper was-enabled`.  But since I don't quite understand what that
debhelper section is supposed to do, I don't know which one is the better

 - Roland

-- System Information:
Debian Release: stretch/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing'), (500, 'stable'), (170, 
'unstable'), (1, 'unstable-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.7.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
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.10
ii  init-system-helpers  1.45
ii  libbsd0              0.8.3-1
ii  libc6                2.24-3
ii  libldb1              2:1.1.27-1
ii  libpam-modules       1.1.8-3.3
ii  libpam-runtime       1.1.8-3.3
ii  libpopt0             1.16-10
ii  libpython2.7         2.7.12-3+b1
ii  libtalloc2           2.1.8-1
ii  libtdb1              1.3.11-2
ii  libtevent0           0.9.28-1
ii  libwbclient0         2:4.4.6+dfsg-2
ii  lsb-base             9.20160629
ii  procps               2:3.3.12-2
ii  python               2.7.11-2
ii  python-dnspython     1.14.0-3
ii  python-samba         2:4.4.6+dfsg-2
pn  python2.7:any        <none>
ii  samba-common         2:4.4.6+dfsg-2
ii  samba-common-bin     2:4.4.6+dfsg-2
ii  samba-libs           2:4.4.6+dfsg-2
ii  tdb-tools            1.3.11-2
ii  update-inetd         4.43

Versions of packages samba recommends:
pn  attr                <none>
ii  logrotate           3.8.7-2
ii  samba-dsdb-modules  2:4.4.6+dfsg-2
pn  samba-vfs-modules   <none>

Versions of packages samba suggests:
pn  bind9          <none>
pn  bind9utils     <none>
pn  ctdb           <none>
pn  ldb-tools      <none>
ii  ntp            1:4.2.8p8+dfsg-1
pn  smbldap-tools  <none>
pn  ufw            <none>
pn  winbind        <none>

-- debconf information:
  samba/run_mode: daemons

Reply via email to