Control: tags -1 +patch +pending

Hello there Sven, Kevin & Robert,

thanks to your groundwork to provide the systemd unit files, Kevin has worked 
towards packaging them and integrating them to form a working NMU to fix this 
long-standing serious bug.

The full debdiff is attached, which includes the unit files from Sven and 
further integration work from Kevin, which I have reviewed and pushed to 
https://salsa.debian.org/debian/dictd/-/merge_requests/4 as well.

I have sponsored his NMU to the DELAYED/2 queue and it will land in unstable 
after this delay. Feel free to accelerate the upload as you see fit.

Many thanks to Kevin for his work on this, and to Sven for providing the 
systemd unit files.

Best,

OdyX

On Wed, 02 Aug 2023 17:39:48 +0200 Sven Joachim <[email protected]> wrote:
> > Package: dictd
> > Severity: important
> > User: [email protected]
> > Usertags: missing-systemd-service
> >
> > Dear Maintainer(s),
> >
> > dictd has been flagged by Lintian as shipping a sysv-init script
> > without a corresponding systemd unit file. The default init system in
> > Debian is systemd, and so far this worked because a transitional
> > sysv-init-to-unit generator was shipped by systemd. This is in the
> > process of being deprecated and will be removed by the time Trixie
> > ships, so the remaining packages that ship init scripts without
> > systemd units will stop working.
> 
> The other day I checked my system for init scripts without a
> corresponding service file, and found dictd as the only package left.
> 
> Since dictd supports both running as a daemon and being started on
> demand via inetd, I took the effort to translate the latter option into
> systemd socket activation[1], adapting the units from the dicod package
> which fulfills the same purpose as dictd.  The three systemd units I
> installed on my system are attached.
> 
> In the per-connection instance [email protected] I have set User=dictd.  It
> would be possible to do that in dictd.service as well by shipping a
> tmpfiles.d(5) snippet that creates a directory (say, /run/dictd)
> writable by the dictd user, and changing the PIDFile= option to create
> the pid file in that directory rather than directly under /run.  Since
> dictd drops privileges very early I did not bother to do that, nor did
> I implement any of the proposed hardening features[2].  But that is
> certainly something the maintainer should consider.
> 
> Occasionally I saw the error message
> 
> dictd.service: Failed to parse PID from file /run/dictd.pid: Invalid 
argument
> 
> in the logs, which indicates some kind of race condition I do not fully
> understand.  The service worked fine anyway, but I have chosen to enable
> dictd.socket instead on my system since that does not require a
> permanently waiting daemon, and the answers from the per-connection
> instances were pretty much instantaneous.
> 
> How all this fits into the existing scheme where debconf and ucf are
> used to let users switch between daemon and on-demand activation, and
> how the various README files need to be updated, is unclear to me and
> really needs to be decided by the maintainer.
> 
> Cheers,
>        Sven
> 
> 
> 1. https://0pointer.net/blog/projects/inetd.html
> 2. https://bugs.debian.org/1032331
> 
diff -Nru dictd-1.13.1+dfsg/debian/changelog dictd-1.13.1+dfsg/debian/changelog
--- dictd-1.13.1+dfsg/debian/changelog	2024-01-14 21:49:53.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/changelog	2025-11-21 08:14:35.000000000 +0100
@@ -1,3 +1,27 @@
+dictd (1.13.1+dfsg-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+
+  [ Sven Joachim ]
+  * Add native systemd units for dictd
+    - dictd.service for the long-running daemon.
+    - dictd.socket and [email protected] for socket-activated, inetd-style
+      per-connection instances.
+    - Use a dedicated runtime directory /run/dictd via RuntimeDirectory=.
+    (Closes: #1039171)
+
+  [ Kevin Mueller ]
+  * Integrate debconf RUN_MODE with systemd
+    - RUN_MODE=daemon enables dictd.service and disables dictd.socket.
+    - RUN_MODE=inetd enables dictd.socket (socket activation) and disables
+      dictd.service.
+    - RUN_MODE=disabled disables both units.
+  * Preserve inetd integration on non-systemd systems while avoiding direct
+    systemctl calls from maintainer scripts by using deb-systemd-invoke
+    instead.
+
+ -- Kevin Mueller <[email protected]>  Fri, 21 Nov 2025 08:14:35 +0100
+
 dictd (1.13.1+dfsg-1) unstable; urgency=low
 
   [ Debian Janitor ]
diff -Nru dictd-1.13.1+dfsg/debian/dictd.config dictd-1.13.1+dfsg/debian/dictd.config
--- dictd-1.13.1+dfsg/debian/dictd.config	2024-01-14 21:49:53.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/dictd.config	2025-11-21 08:14:35.000000000 +0100
@@ -31,7 +31,10 @@
 
 # Make dpkg-reconfigure stop the dictd server before
 # /etc/default/dictd is modified by the postinst script.
-if [ "$1" = "reconfigure" ] && [ "$RUN_MODE" = "daemon" ] \
-   && [ -x "$INITFILE" ] && command -v invoke-rc.d >/dev/null; then
-    invoke-rc.d dictd stop >&2 || echo "Warning: failed to stop dictionary server" >&2
+if [ "$1" = "reconfigure" ] && [ "$RUN_MODE" = "daemon" ]; then
+    if [ -d /run/systemd/system ] && command -v systemctl >/dev/null; then
+        systemctl stop dictd.service >&2 || echo "Warning: failed to stop dictionary server" >&2
+    elif [ -x "$INITFILE" ] && command -v invoke-rc.d >/dev/null; then
+        invoke-rc.d dictd stop >&2 || echo "Warning: failed to stop dictionary server" >&2
+    fi
 fi
diff -Nru dictd-1.13.1+dfsg/debian/dictd.postinst dictd-1.13.1+dfsg/debian/dictd.postinst
--- dictd-1.13.1+dfsg/debian/dictd.postinst	2024-01-14 21:49:53.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/dictd.postinst	2025-11-21 08:14:35.000000000 +0100
@@ -23,17 +23,53 @@
     DICTD_ARGS=""
     . "$DEFAULTSFILE"
 
-    if [ "$RUN_MODE" = "inetd" ] ; then
-        # Add service to /etc/inetd.conf
-        update-inetd \
-            --group OTHER \
-            --add "dict\tstream\ttcp\tnowait\tdictd.dictd\t/usr/sbin/tcpd\t/usr/sbin/dictd $DICTD_ARGS --inetd" && \
-        update-inetd --enable dict
+    # systemd present?
+    if [ -d /run/systemd/system ] && command -v deb-systemd-invoke >/dev/null; then
+        case "$RUN_MODE" in
+            daemon)
+                # daemon mode: regular service, no socket
+                deb-systemd-invoke stop dictd.socket >/dev/null 2>&1 || true
+                deb-systemd-invoke disable dictd.socket >/dev/null 2>&1 || true
+
+                deb-systemd-invoke enable dictd.service >/dev/null 2>&1 || true
+                deb-systemd-invoke restart dictd.service >/dev/null 2>&1 || true
+                ;;
+            inetd)
+                # on-demand mode: socket activation only
+                deb-systemd-invoke stop dictd.service >/dev/null 2>&1 || true
+                deb-systemd-invoke disable dictd.service >/dev/null 2>&1 || true
+
+                deb-systemd-invoke enable dictd.socket >/dev/null 2>&1 || true
+                deb-systemd-invoke restart dictd.socket >/dev/null 2>&1 || true
+                ;;
+            disabled)
+                # fully disabled
+                deb-systemd-invoke stop dictd.service dictd.socket >/dev/null 2>&1 || true
+                deb-systemd-invoke disable dictd.service dictd.socket >/dev/null 2>&1 || true
+                ;;
+        esac
+
+        # On systemd, inetd is no longer used for dictd; make sure it’s off.
+        if command -v update-inetd >/dev/null; then
+            update-inetd --disable dict >/dev/null 2>&1 || true
+        fi
     else
-        (
-          [ -r /etc/inetd.conf ] || exec 2>/dev/null
-          update-inetd --disable dict || true
-        )
+
+        # Non-systemd: keep the old inetd behaviour
+        if command -v update-inetd >/dev/null; then
+            if [ "$RUN_MODE" = "inetd" ] ; then
+                # Add service to /etc/inetd.conf
+                update-inetd \
+                    --group OTHER \
+                    --add "dict\tstream\ttcp\tnowait\tdictd.dictd\t/usr/sbin/tcpd\t/usr/sbin/dictd $DICTD_ARGS --inetd" && \
+                update-inetd --enable dict
+            else
+                (
+                  [ -r /etc/inetd.conf ] || exec 2>/dev/null
+                  update-inetd --disable dict || true
+                )
+            fi
+        fi
     fi
 }
 
diff -Nru dictd-1.13.1+dfsg/debian/dictd.service dictd-1.13.1+dfsg/debian/dictd.service
--- dictd-1.13.1+dfsg/debian/dictd.service	1970-01-01 01:00:00.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/dictd.service	2025-11-21 08:14:35.000000000 +0100
@@ -0,0 +1,25 @@
+[Unit]
+Description=Dictd dictionary server daemon
+Documentation=man:dictd(8) man:dictdconfig(8)
+After=network.target
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/default/dictd
+
+User=dictd
+Group=dictd
+# Let systemd create /run/dictd owned by dictd:dictd
+RuntimeDirectory=dictd
+RuntimeDirectoryMode=0755
+
+PIDFile=/run/dictd/dictd.pid
+
+# DICTD_ARGS comes from /etc/default/dictd
+ExecStart=/usr/sbin/dictd $DICTD_ARGS --pid-file=/run/dictd/dictd.pid
+ExecReload=/bin/kill -HUP $MAINPID
+
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff -Nru dictd-1.13.1+dfsg/debian/dictd.socket dictd-1.13.1+dfsg/debian/dictd.socket
--- dictd-1.13.1+dfsg/debian/dictd.socket	1970-01-01 01:00:00.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/dictd.socket	2025-11-21 08:14:35.000000000 +0100
@@ -0,0 +1,11 @@
+[Unit]
+Description=Dictd dictionary server socket
+Before=dictd.service
+Conflicts=dictd.service
+
+[Socket]
+ListenStream=2628
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
\ No newline at end of file
diff -Nru dictd-1.13.1+dfsg/debian/dictd.tmpfiles dictd-1.13.1+dfsg/debian/dictd.tmpfiles
--- dictd-1.13.1+dfsg/debian/dictd.tmpfiles	1970-01-01 01:00:00.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/dictd.tmpfiles	2025-11-21 08:14:35.000000000 +0100
@@ -0,0 +1 @@
+d /run/dictd 0755 dictd dictd -
\ No newline at end of file
diff -Nru dictd-1.13.1+dfsg/debian/[email protected] dictd-1.13.1+dfsg/debian/[email protected]
--- dictd-1.13.1+dfsg/debian/[email protected]	1970-01-01 01:00:00.000000000 +0100
+++ dictd-1.13.1+dfsg/debian/[email protected]	2025-11-21 08:14:35.000000000 +0100
@@ -0,0 +1,14 @@
+[Unit]
+Description=Dictd dictionary server (socket-activated instance)
+
+[Service]
+User=dictd
+Group=dictd
+
+# inetd-style mode
+ExecStart=/usr/sbin/dictd --inetd
+StandardInput=socket
+StandardOutput=socket
+StandardError=journal
+
+KillMode=process
\ No newline at end of file

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to