Bug#819087: systemd.pm: does not correctly pair .sh-suffixed init scripts with non-.sh native units
Package: lintian
Version: 2.5.42.1
Severity: normal
Tags: patch
Hi,
The patchset in #790323 was incomplete, in that the .sh suffix of some
init scripts was not always removed when deciding that the init script
is matched by a native systemd unit.
Please find attached a small patch that corrects the issue, with test.
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.4.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages lintian depends on:
ii binutils 2.26-8
ii bzip2 1.0.6-8
ii diffstat 1.61-1
ii file 1:5.25-2
ii gettext 0.19.7-2
ii hardening-includes 2.8+nmu2
ii intltool-debian 0.35.0+20060710.4
ii libapt-pkg-perl 0.1.29+b5
ii libarchive-zip-perl 1.56-2
ii libclass-accessor-perl 0.34-1
ii libclone-perl 0.38-1+b1
ii libdata-alias-perl 1.20-1+b1
ii libdpkg-perl 1.18.4
ii libemail-valid-perl 1.198-1
ii libfile-basedir-perl 0.07-1
ii libipc-run-perl 0.94-1
ii liblist-moreutils-perl 0.413-1+b1
ii libparse-debianchangelog-perl 1.2.0-8
ii libperl5.22 [libdigest-sha-perl] 5.22.1-9
ii libtext-levenshtein-perl 0.13-1
ii libtimedate-perl 2.3000-2
ii liburi-perl 1.71-1
ii libyaml-libyaml-perl 0.41-6+b1
ii man-db 2.7.5-1
ii patchutils 0.3.4-1
ii perl 5.22.1-9
ii t1utils 1.39-2
ii xz-utils 5.1.1alpha+20120614-2.1
Versions of packages lintian recommends:
ii dpkg 1.18.4
ii libautodie-perl 2.29-2
ii libperlio-gzip-perl 0.19-1+b1
ii perl 5.22.1-9
ii perl-modules-5.22 [libautodie-perl] 5.22.1-9
Versions of packages lintian suggests:
ii binutils-multiarch 2.26-8
ii dpkg-dev 1.18.4
ii libhtml-parser-perl 3.72-1
ii libtext-template-perl 1.46-1
-- no debconf information
-- debsums errors found:
debsums: changed file /usr/share/lintian/checks/systemd.pm (from lintian package)
>From 2ecf75da8f41cbf9ad5813aefdf7c3a0054d3b9d Mon Sep 17 00:00:00 2001
From: Felipe Sateler <fsateler@debian.org>
Date: Wed, 23 Mar 2016 12:11:43 -0300
Subject: [PATCH] systemd.pm: Properly remove .sh suffix when checking
systemd-initscript matching
---
checks/systemd.pm | 16 +++++++++----
t/tests/systemd-general/debian/debian/install | 1 +
t/tests/systemd-general/debian/debian/rules | 1 +
.../systemd-general/debian/debian/sourced.service | 9 ++++++++
.../systemd-general/debian/debian/sourced.sh.init | 27 ++++++++++++++++++++++
5 files changed, 50 insertions(+), 4 deletions(-)
create mode 100644 t/tests/systemd-general/debian/debian/sourced.service
create mode 100644 t/tests/systemd-general/debian/debian/sourced.sh.init
diff --git a/checks/systemd.pm b/checks/systemd.pm
index 69092be..face504 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -66,14 +66,21 @@ sub run {
return;
}
+sub get_init_service_name {
+ my ($file) = @_;
+ my $basename = $file->basename;
+ # sysv generator drops the .sh suffix
+ $basename =~ s/\.sh$//;
+ return $basename;
+}
+
sub get_init_scripts {
my ($info) = @_;
my @scripts;
if (my $initd_path = $info->index_resolved_path('etc/init.d/')) {
for my $init_script ($initd_path->children) {
# sysv generator drops the .sh suffix
- my $basename = $init_script->basename;
- $basename =~ s/\.sh$//;
+ my $basename = get_init_service_name($init_script);
next if $INIT_WHITELIST->known($basename);
next
if $init_script->is_symlink
@@ -90,6 +97,7 @@ sub get_init_scripts {
sub check_init_script {
my ($info, $file, $services) = @_;
my $basename = $file->basename;
+ my $servicename = get_init_service_name($file);
my $lsb_source_seen;
my $is_rcs_script = 0;
@@ -121,12 +129,12 @@ sub check_init_script {
# Only tag if the maintainer of this package did any effort to
# make the package work with systemd.
tag 'systemd-no-service-for-init-script', $basename
- if (%{$services} and not $services->{$basename});
+ if (%{$services} and not $services->{$servicename});
# rcS scripts are particularly bad, warn even if there is
# no systemd integration
tag 'systemd-no-service-for-init-rcS-script', $basename
- if (not $services->{$basename} and $is_rcs_script);
+ if (not $services->{$servicename} and $is_rcs_script);
return;
}
diff --git a/t/tests/systemd-general/debian/debian/install b/t/tests/systemd-general/debian/debian/install
index 56cf085..3ed93ab 100644
--- a/t/tests/systemd-general/debian/debian/install
+++ b/t/tests/systemd-general/debian/debian/install
@@ -1,3 +1,4 @@
debian/test.service etc/systemd/system/
debian/test.service usr/lib/systemd/system/
+debian/sourced.service lib/systemd/system/
debian/test.conf etc/tmpfiles.d/
diff --git a/t/tests/systemd-general/debian/debian/rules b/t/tests/systemd-general/debian/debian/rules
index fade512..47cdf51 100644
--- a/t/tests/systemd-general/debian/debian/rules
+++ b/t/tests/systemd-general/debian/debian/rules
@@ -23,3 +23,4 @@ override_dh_fixperms:
override_dh_installinit:
dh_installinit
dh_installinit --name systemd-aliasd
+ dh_installinit --name sourced.sh
diff --git a/t/tests/systemd-general/debian/debian/sourced.service b/t/tests/systemd-general/debian/debian/sourced.service
new file mode 100644
index 0000000..3fdee38
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/sourced.service
@@ -0,0 +1,9 @@
+[Unit]
+After=network.target
+Documentation=man:sourced(1)
+
+[Service]
+ExecStart=/usr/bin/test
+
+[Install]
+WantedBy=multi-user.target
diff --git a/t/tests/systemd-general/debian/debian/sourced.sh.init b/t/tests/systemd-general/debian/debian/sourced.sh.init
new file mode 100644
index 0000000..c7fb722
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/sourced.sh.init
@@ -0,0 +1,27 @@
+#!/bin/sh
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+### BEGIN INIT INFO
+# Provides: sourced
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Example initscript
+# Description: This file should be used to construct scripts to be
+# placed in /etc/init.d. This example start a
+# single forking daemon capable of writing a pid
+# file. To get other behavoirs, implemend
+# do_start(), do_stop() or other functions to
+# override the defaults in /lib/init/init-d-script.
+### END INIT INFO
+
+# Author: Foo Bar <foobar@baz.org>
+#
+# Please remove the "Author" lines above and replace them
+# with your own name if you copy and modify this script.
+
+DESC="Description of the service"
+DAEMON=/usr/sbin/daemonexecutablename
--
2.8.0.rc3
Reply to: