[I used the wrong address in the X-Debbugs-CC pseudoheader, forwarding
manually.]
I noticed that haveged.service installs itself with
WantedBy=default.target, rather than multi-user.target.
This lintian check warns when a service unit is WantedBy=
something other than {sysinit,multi-user,graphical}.target.
Would pkg-systemd-maintainers care to comment on whether this is a good
idea and/or whether there are likely to be too many false positives? I
ran the following on my system:
systemctl --no-legend list-unit-files -t service | while read unit rest; do w=$(systemctl cat "$unit" | grep ^WantedBy=); for x in $w; do printf '%s %s\n' $x "$unit"; done; done
and the false positives were from systemd itself, bluez and anacron.
--
Sam Morris <https://robots.org.uk/>
CAAA AA1A CA69 A83A 892B 1855 D20B 4202 5CDA 27B9
>From 13fe1c75dae2d64d61adf765478990d5c2c84d4a Mon Sep 17 00:00:00 2001
From: Sam Morris <sam@robots.org.uk>
Date: Tue, 8 Mar 2016 16:11:18 +0000
Subject: [PATCH] systemd: warn if services are WantedBy= an unusual target
---
checks/systemd.desc | 11 +++++++++++
checks/systemd.pm | 7 +++++++
2 files changed, 18 insertions(+)
diff --git a/checks/systemd.desc b/checks/systemd.desc
index 7c8eddb..dc8ec73 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -126,3 +126,14 @@ Info: The systemd service file does not contain a <tt>Documentation</tt> key.
Documentation for systemd service files can be automatically viewed using
<tt>systemctl help servicename</tt> if this field is present.
Ref: systemd.unit(5)
+
+Tag: systemd-service-wantedby-unusual-target
+Severity: normal
+Certainty: certain
+Info: The systemd service file declares an unusual WantedBy= relationship.
+ .
+ Most services that want to be started automatically at boot should use
+ WantedBy=multi-user.target or WantedBy=graphical.target. Services that want to
+ be started in rescue or single-user mode should instead use
+ WantedBy=sysinit.target.
+Ref: https://wiki.debian.org/Teams/pkg-systemd/rcSMigration
diff --git a/checks/systemd.pm b/checks/systemd.pm
index 69092be..225f153 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -195,6 +195,13 @@ sub check_systemd_service_file {
unless extract_service_file_values($file, 'Unit', 'Documentation',1);
}
+ if ($file =~ /\.service$/) {
+ my @wantedby = extract_service_file_values($file, 'Install', 'WantedBy');
+ my @unusual_wantedby = grep { /(?<!^sysinit)(?<!^multi-user)(?<!^graphical)\.target$/ } @wantedby;
+ tag 'systemd-service-wantedby-unusual-target', $file, $_
+ for @unusual_wantedby;
+ }
+
return 1;
}
--
2.7.0
Attachment:
signature.asc
Description: This is a digitally signed message part