[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/02: Warn if native systemd service files only wrap existing SysV/LSB init scripts. (Closes: #870704)



This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository lintian.

commit d3ea2ad81a9917d16b35c29d9234199f6ff693dc
Author: Chris Lamb <lamby@debian.org>
Date:   Thu Oct 12 11:41:23 2017 -0400

    Warn if native systemd service files only wrap existing SysV/LSB init scripts. (Closes: #870704)
---
 checks/systemd.desc                                           | 11 +++++++++++
 checks/systemd.pm                                             |  8 ++++++++
 debian/changelog                                              |  3 +++
 .../systemd-complex-service-file/debian/debian/test5.service  |  7 ++++++-
 t/tests/systemd-complex-service-file/desc                     |  1 +
 t/tests/systemd-complex-service-file/tags                     |  6 ++++++
 6 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/checks/systemd.desc b/checks/systemd.desc
index 532f445..0b42398 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -145,3 +145,14 @@ Info: The systemd service file does not contain a <tt>WantedBy=</tt> or
  Forgetting to add such a line (e.g. <tt>WantedBy=multi-user.target</tt>)
  results in the service file not being started by default.
 Ref: systemd.unit(5)
+
+Tag: systemd-service-file-wraps-init-script
+Severity: normal
+Certainty: certain
+Info: The listed service file simply uses ths existing SysV init script
+ via ExecStart, ExecStop, etc.
+ .
+ The main logic of more complex init scripts should be moved into helper
+ scripts which can be used directly from both the .service file and the
+ init script. This will also make the init scripts more readable and easier
+ to support other alternatives.
diff --git a/checks/systemd.pm b/checks/systemd.pm
index 50841a0..877d9ea 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -203,6 +203,14 @@ sub check_systemd_service_file {
     tag 'systemd-service-file-refers-to-obsolete-bindto', $file,
       if extract_service_file_values($file, 'Unit', 'BindTo', 1);
 
+    for my $key (
+        qw(ExecStart ExecStartPre ExecStartPost ExecReload ExecStop ExecStopPost)
+      ) {
+        tag 'systemd-service-file-wraps-init-script', $file, $key
+          if any { m,^/etc/init\.d/, }
+        extract_service_file_values($file, 'Service', $key, 1);
+    }
+
     if (not $file->is_symlink or $file->link ne '/dev/null') {
         tag 'systemd-service-file-missing-documentation-key', $file,
           unless extract_service_file_values($file, 'Unit', 'Documentation',1);
diff --git a/debian/changelog b/debian/changelog
index d2817b4..e7ca4e4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -45,6 +45,9 @@ lintian (2.5.55) UNRELEASED; urgency=medium
   * checks/standards-version.desc:
     + [CL] Correct invalid link to upgrading-checklist. Thanks to Dann
       Frazier for the report.  (Closes: #878184)
+  * checks/systemd.{desc,pm}:
+    + [CL] Warn if native systemd service files only wrap existing SysV/LSB
+      init scripts.  (Closes: #870704)
   * checks/watch-file.{pm,desc}:
     + [CL] Warn for debian/watch files using insecure URIs such as HTTP or
       FTP, similar to vcs-field-uses-insecure-uri.  (Closes: #849515)
diff --git a/t/tests/systemd-complex-service-file/debian/debian/test5.service b/t/tests/systemd-complex-service-file/debian/debian/test5.service
index 64a7562..d26713a 100644
--- a/t/tests/systemd-complex-service-file/debian/debian/test5.service
+++ b/t/tests/systemd-complex-service-file/debian/debian/test5.service
@@ -3,4 +3,9 @@ Documentation=https://www.example.com/
 
 [Service]
 Type=oneshot
-ExecStart=/usr/bin/test
+ExecStart=/etc/init.d/test5 start
+ExecStartPre=/etc/init.d/test5 start-pre
+ExecStartPost=/etc/init.d/test5 start-post
+ExecReload=/etc/init.d/test5 reload
+ExecStop=/etc/init.d/test5 stop
+ExecStopPost=/etc/init.d/test5 stop-post
diff --git a/t/tests/systemd-complex-service-file/desc b/t/tests/systemd-complex-service-file/desc
index dc65813..15ff707 100644
--- a/t/tests/systemd-complex-service-file/desc
+++ b/t/tests/systemd-complex-service-file/desc
@@ -7,3 +7,4 @@ Test-For:
  systemd-service-file-refers-to-obsolete-target
  systemd-service-file-missing-documentation-key
  systemd-service-file-missing-install-key
+ systemd-service-file-wraps-init-script
diff --git a/t/tests/systemd-complex-service-file/tags b/t/tests/systemd-complex-service-file/tags
index 11095e2..8ec6752 100644
--- a/t/tests/systemd-complex-service-file/tags
+++ b/t/tests/systemd-complex-service-file/tags
@@ -3,3 +3,9 @@ I: systemd-complex-service-file: systemd-service-file-missing-documentation-key
 I: systemd-complex-service-file: systemd-service-file-missing-install-key lib/systemd/system/test2.service
 W: systemd-complex-service-file: systemd-service-file-refers-to-obsolete-target lib/systemd/system/test.service dbus.target
 W: systemd-complex-service-file: systemd-service-file-refers-to-obsolete-target lib/systemd/system/test2.service syslog.target
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecReload
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecStart
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecStartPost
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecStartPre
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecStop
+W: systemd-complex-service-file: systemd-service-file-wraps-init-script lib/systemd/system/test5.service ExecStopPost

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: