Package: snmptt
Version: 1.4-2
Severity: normal
Tags: patch bullseye sid

Dear Maintainer,

Please consider adding a native systemd service masking the currently
shipped init scripts (fixes lintian tag[1] in subject).

I tried creating a native systemd service myself based on reading the
init script. There where some additional changes needed to the packaging
(like making logrotate use invoke-rc.d) so I'm providing my work as a
debdiff in the hope that it can be useful to you. Note that I've only
build-tested the patch (as I'm not personally using the package).

Please note that I also bumped debhelper compat to 10, as compat 9 is
now deprecated which made me feel like doing the systemd integration
the <10 way seemed pointless.

Don't hesitate to reach out if any help is necessary. I'll happily help
if you provide the testing and review (as I don't use snmptt myself).

Further improvements like security hardening[2] could be added later.

Regards,
Andreas Henriksson

[1]: 
https://lintian.debian.org/tags/missing-systemd-service-for-init.d-script.html
[2]: 
https://lintian.debian.org/tags/systemd-service-file-missing-hardening-features.html
diff -Nru snmptt-1.4/debian/changelog snmptt-1.4/debian/changelog
--- snmptt-1.4/debian/changelog 2018-05-19 16:23:26.000000000 +0200
+++ snmptt-1.4/debian/changelog 2020-02-01 19:24:17.000000000 +0100
@@ -1,3 +1,15 @@
+snmptt (1.4-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * debian/logrotate: Use invoke-rc.d instead of init script directly.
+  * Add debian/snmptt.service masking init script
+  * Drop lsb-base dependency
+    - it's guaranteed to be installed on sysvinit systems and not
+      needed on other systems now that there's a native systemd unit.
+  * Bump debhelper compat to 10 for automatic systemd handling
+
+ -- Andreas Henriksson <andr...@fatal.se>  Sat, 01 Feb 2020 19:24:17 +0100
+
 snmptt (1.4-2) unstable; urgency=medium
 
   * Depend on lsb-base.
diff -Nru snmptt-1.4/debian/compat snmptt-1.4/debian/compat
--- snmptt-1.4/debian/compat    2014-10-09 15:29:23.000000000 +0200
+++ snmptt-1.4/debian/compat    2020-02-01 19:24:17.000000000 +0100
@@ -1 +1 @@
-9
+10
diff -Nru snmptt-1.4/debian/control snmptt-1.4/debian/control
--- snmptt-1.4/debian/control   2018-05-19 16:23:26.000000000 +0200
+++ snmptt-1.4/debian/control   2020-02-01 19:24:17.000000000 +0100
@@ -2,7 +2,7 @@
 Section: net
 Priority: optional
 Maintainer: Christoph Berg <m...@debian.org>
-Build-Depends: debhelper (>= 9)
+Build-Depends: debhelper (>= 10)
 Homepage: http://www.snmptt.org/
 Standards-Version: 4.1.4
 Vcs-Git: https://salsa.debian.org/debian/snmptt.git
@@ -14,7 +14,6 @@
  adduser,
  libconfig-inifiles-perl,
  libsnmp-perl,
- lsb-base,
  snmpd,
  ${misc:Depends},
 Recommends: libsys-syslog-perl
diff -Nru snmptt-1.4/debian/logrotate snmptt-1.4/debian/logrotate
--- snmptt-1.4/debian/logrotate 2012-12-22 14:44:50.000000000 +0100
+++ snmptt-1.4/debian/logrotate 2020-02-01 19:24:05.000000000 +0100
@@ -6,6 +6,6 @@
        compress
        sharedscripts
        postrotate
-               /etc/init.d/snmptt reload > /dev/null
+               invoke-rc.d --quiet snmptt reload > /dev/null
        endscript
 }
diff -Nru snmptt-1.4/debian/snmptt.service snmptt-1.4/debian/snmptt.service
--- snmptt-1.4/debian/snmptt.service    1970-01-01 01:00:00.000000000 +0100
+++ snmptt-1.4/debian/snmptt.service    2020-02-01 19:23:48.000000000 +0100
@@ -0,0 +1,22 @@
+[Unit]
+Description=SNMP trap translator
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/snmptt.pid
+Environment=DAEMON_ARGS="--daemon"
+EnvironmentFile=-/etc/default/snmptt
+ExecStart=/usr/sbin/snmptt $DAEMON_ARGS
+# Note: signals are async, but ExecReload command should block until
+# reloading is finished.
+ExecReload=/bin/kill -HUP $MAINPID
+ExecReload=/bin/sleep 2
+# Daemon will drop privilegies on its own. Will use privilegied mode for
+# dealing with pidfile. Might be better to try to start it unprivilegied
+# instead at some point....
+#User=snmptt
+#Group=snmptt
+
+[Install]
+WantedBy=multi-user.target

Reply via email to