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

Bug#792501: lintian: rcS.d check should whitelist units masked by systemd



Package: lintian
Version: 2.5.33
Followup-For: Bug #792501

Now actually attaching the files...

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.0.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.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.25-10
ii  bzip2                          1.0.6-8
ii  diffstat                       1.58-1
ii  file                           1:5.22+15-2
ii  gettext                        0.19.4-1
ii  hardening-includes             2.7
ii  intltool-debian                0.35.0+20060710.2
ii  libapt-pkg-perl                0.1.29+b2
ii  libarchive-zip-perl            1.48-1
ii  libclass-accessor-perl         0.34-1
ii  libclone-perl                  0.38-1
ii  libdpkg-perl                   1.18.1
ii  libemail-valid-perl            1.196-1
ii  libfile-basedir-perl           0.07-1
ii  libipc-run-perl                0.94-1
ii  liblist-moreutils-perl         0.413-1
ii  libparse-debianchangelog-perl  1.2.0-5
ii  libtext-levenshtein-perl       0.12-1
ii  libtimedate-perl               2.3000-2
ii  liburi-perl                    1.64-1
ii  man-db                         2.7.0.2-5
ii  patchutils                     0.3.4-1
ii  perl [libdigest-sha-perl]      5.20.2-6
ii  t1utils                        1.38-4
ii  xz-utils                       5.1.1alpha+20120614-2.1

Versions of packages lintian recommends:
ii  dpkg                            1.18.1
ii  libautodie-perl                 2.28-1
ii  libperlio-gzip-perl             0.18-3+b1
ii  perl                            5.20.2-6
ii  perl-modules [libautodie-perl]  5.20.2-6

Versions of packages lintian suggests:
pn  binutils-multiarch     <none>
ii  dpkg-dev               1.18.1
ii  libhtml-parser-perl    3.71-2
ii  libtext-template-perl  1.46-1
ii  libyaml-perl           1.13-1

-- no debconf information
>From 367188c08c140e1d465f5da96a8d3a12b5293f5e Mon Sep 17 00:00:00 2001
From: Felipe Sateler <fsateler@debian.org>
Date: Thu, 16 Jul 2015 18:47:00 -0300
Subject: [PATCH 1/3] Use Lintian::Data instead of hardcoded array for ignore
 whitelist

---
 checks/systemd.pm                           | 8 ++++++--
 data/systemd/init-whitelist                 | 5 +++++
 t/tests/systemd-general/debian/debian/rules | 5 +++++
 3 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 data/systemd/init-whitelist

diff --git a/checks/systemd.pm b/checks/systemd.pm
index 5319152..fd5b83a 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -34,6 +34,11 @@ use Text::ParseWords qw(shellwords);
 use Lintian::Tags qw(tag);
 use Lintian::Util qw(fail lstrip rstrip);
 
+use Lintian::Data;
+
+# Init script that do not need a service file
+my $INIT_WHITELIST = Lintian::Data->new('systemd/init-whitelist');
+
 sub run {
     my (undef, undef, $info) = @_;
 
@@ -63,11 +68,10 @@ sub run {
 
 sub get_init_scripts {
     my ($info) = @_;
-    my @ignore = ('README','skeleton','rc','rcS',);
     my @scripts;
     if (my $initd_path = $info->index_resolved_path('etc/init.d/')) {
         for my $init_script ($initd_path->children) {
-            next if any { $_ eq $init_script->basename } @ignore;
+            next if $INIT_WHITELIST->known($init_script->basename);
             next
               if $init_script->is_symlink
               && $init_script->link eq '/lib/init/upstart-job';
diff --git a/data/systemd/init-whitelist b/data/systemd/init-whitelist
new file mode 100644
index 0000000..555d48e
--- /dev/null
+++ b/data/systemd/init-whitelist
@@ -0,0 +1,5 @@
+# These are not really init scripts...
+README
+skeleton
+rc
+rcS
diff --git a/t/tests/systemd-general/debian/debian/rules b/t/tests/systemd-general/debian/debian/rules
index 8c12dd7..f952939 100644
--- a/t/tests/systemd-general/debian/debian/rules
+++ b/t/tests/systemd-general/debian/debian/rules
@@ -12,3 +12,8 @@ override_dh_install:
 	install -m 0755 -d $(INITD_DIR) $(SYSD_DIR)
 	mkfifo $(INITD_DIR)/fifo-pipe-as-init
 	mkfifo $(SYSD_DIR)/fifo-pipe-as-init.service
+	touch $(INITD_DIR)/README
+
+override_dh_fixperms:
+	dh_fixperms
+	chmod -x $(INITD_DIR)/README
-- 
2.1.4

>From c54c908718d79fc9921bf633b94118fb63ab15ed Mon Sep 17 00:00:00 2001
From: Felipe Sateler <fsateler@debian.org>
Date: Thu, 16 Jul 2015 19:19:39 -0300
Subject: [PATCH 2/3] Add systemd-provided names to init whitelist

Strip .sh suffixes, as those are removed by the systemd sysv generator
Copy bootmisc.sh from initscripts as a test
---
 checks/systemd.pm                                 |  5 +-
 data/systemd/init-whitelist                       | 39 +++++++++++++++
 t/tests/systemd-general/debian/debian/bootmisc.sh | 59 +++++++++++++++++++++++
 t/tests/systemd-general/debian/debian/rules       |  1 +
 t/tests/systemd-general/tags                      |  1 +
 5 files changed, 104 insertions(+), 1 deletion(-)
 create mode 100755 t/tests/systemd-general/debian/debian/bootmisc.sh

diff --git a/checks/systemd.pm b/checks/systemd.pm
index fd5b83a..e59510e 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -71,7 +71,10 @@ sub get_init_scripts {
     my @scripts;
     if (my $initd_path = $info->index_resolved_path('etc/init.d/')) {
         for my $init_script ($initd_path->children) {
-            next if $INIT_WHITELIST->known($init_script->basename);
+            # sysv generator drops the .sh suffix
+            my $basename = $init_script->basename;
+            $basename =~ s/\.sh$//;
+            next if $INIT_WHITELIST->known($basename);
             next
               if $init_script->is_symlink
               && $init_script->link eq '/lib/init/upstart-job';
diff --git a/data/systemd/init-whitelist b/data/systemd/init-whitelist
index 555d48e..b9d7a42 100644
--- a/data/systemd/init-whitelist
+++ b/data/systemd/init-whitelist
@@ -3,3 +3,42 @@ README
 skeleton
 rc
 rcS
+
+# Names provided/masked by systemd
+# Generated from the systemd links
+# sed -n -e 's|^.\+[[:space:]]\+/lib/systemd/system/\([^/]\+\)\.service$|\1|p' debian/systemd.links
+urandom
+procps
+rc.local
+module-init-tools
+kmod
+x11-common
+hostname
+rmnologin
+bootmisc
+fuse
+bootlogd
+stop-bootlogd-single
+stop-bootlogd
+hwclock
+mountkernfs
+mountdevsubfs
+mountall
+mountall-bootclean
+mountnfs
+mountnfs-bootclean
+umountfs
+umountnfs
+umountroot
+checkfs
+checkroot
+checkroot-bootclean
+cryptdisks
+cryptdisks-early
+single
+killprocs
+sendsigs
+halt
+reboot
+motd
+bootlogs
diff --git a/t/tests/systemd-general/debian/debian/bootmisc.sh b/t/tests/systemd-general/debian/debian/bootmisc.sh
new file mode 100755
index 0000000..5c73683
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/bootmisc.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          bootmisc
+# Required-Start:    $remote_fs
+# Required-Stop:
+# Should-Start:      udev
+# Default-Start:     S
+# Default-Stop:
+# Short-Description: Miscellaneous things to be done during bootup.
+# Description:       Some cleanup.  Note, it need to run after mountnfs-bootclean.sh.
+### END INIT INFO
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+[ "$DELAYLOGIN" ] || DELAYLOGIN=yes
+. /lib/init/vars.sh
+
+do_start () {
+	#
+	# If login delaying is enabled then create the flag file
+	# which prevents logins before startup is complete
+	#
+	case "$DELAYLOGIN" in
+	  Y*|y*)
+		echo "System bootup in progress - please wait" > /var/lib/initscripts/nologin
+		;;
+	esac
+
+	# Create /var/run/utmp so we can login.
+	: > /var/run/utmp
+	if grep -q ^utmp: /etc/group
+	then
+		chmod 664 /var/run/utmp
+		chgrp utmp /var/run/utmp
+	fi
+
+	# Remove bootclean's flag files.
+	# Don't run bootclean again after this!
+	rm -f /tmp/.clean /run/.clean /run/lock/.clean
+	rm -f /tmp/.tmpfs /run/.tmpfs /run/lock/.tmpfs
+}
+
+case "$1" in
+  start|"")
+	do_start
+	;;
+  restart|reload|force-reload)
+	echo "Error: argument '$1' not supported" >&2
+	exit 3
+	;;
+  stop|status)
+	# No-op
+	;;
+  *)
+	echo "Usage: bootmisc.sh [start|stop]" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/t/tests/systemd-general/debian/debian/rules b/t/tests/systemd-general/debian/debian/rules
index f952939..ef793af 100644
--- a/t/tests/systemd-general/debian/debian/rules
+++ b/t/tests/systemd-general/debian/debian/rules
@@ -12,6 +12,7 @@ override_dh_install:
 	install -m 0755 -d $(INITD_DIR) $(SYSD_DIR)
 	mkfifo $(INITD_DIR)/fifo-pipe-as-init
 	mkfifo $(SYSD_DIR)/fifo-pipe-as-init.service
+	install -m 0755 debian/bootmisc.sh $(INITD_DIR)
 	touch $(INITD_DIR)/README
 
 override_dh_fixperms:
diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags
index 3dc3b91..d570cdb 100644
--- a/t/tests/systemd-general/tags
+++ b/t/tests/systemd-general/tags
@@ -12,6 +12,7 @@ E: systemd-general: systemd-service-file-outside-lib usr/lib/systemd/system/test
 E: systemd-general: systemd-tmpfiles.d-outside-usr-lib etc/tmpfiles.d/test.conf
 W: systemd-general: init.d-script-does-not-source-init-functions etc/init.d/systemd-general
 W: systemd-general: maintainer-script-calls-systemctl postrm:6
+W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/bootmisc.sh
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/fifo-pipe-as-init
 W: systemd-general: systemd-service-file-refers-to-obsolete-target etc/systemd/system/test.service syslog.target
 W: systemd-general: systemd-service-file-refers-to-obsolete-target usr/lib/systemd/system/test.service syslog.target
-- 
2.1.4

>From 93adf18c4af8d421d11ac38e8841aeb310281b53 Mon Sep 17 00:00:00 2001
From: Felipe Sateler <fsateler@debian.org>
Date: Thu, 16 Jul 2015 19:24:38 -0300
Subject: [PATCH 3/3] Add test to make sure masked services are not complained
 about

---
 t/tests/systemd-general/debian/debian/links       |  1 +
 t/tests/systemd-general/debian/debian/masked.init | 27 +++++++++++++++++++++++
 t/tests/systemd-general/debian/debian/rules       |  1 +
 t/tests/systemd-general/tags                      |  1 +
 4 files changed, 30 insertions(+)
 create mode 100644 t/tests/systemd-general/debian/debian/links
 create mode 100644 t/tests/systemd-general/debian/debian/masked.init

diff --git a/t/tests/systemd-general/debian/debian/links b/t/tests/systemd-general/debian/debian/links
new file mode 100644
index 0000000..c022cff
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/links
@@ -0,0 +1 @@
+/dev/null /lib/systemd/system/masked.service
diff --git a/t/tests/systemd-general/debian/debian/masked.init b/t/tests/systemd-general/debian/debian/masked.init
new file mode 100644
index 0000000..0f6abf0
--- /dev/null
+++ b/t/tests/systemd-general/debian/debian/masked.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:          masked
+# 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
diff --git a/t/tests/systemd-general/debian/debian/rules b/t/tests/systemd-general/debian/debian/rules
index ef793af..ea39c0e 100644
--- a/t/tests/systemd-general/debian/debian/rules
+++ b/t/tests/systemd-general/debian/debian/rules
@@ -13,6 +13,7 @@ override_dh_install:
 	mkfifo $(INITD_DIR)/fifo-pipe-as-init
 	mkfifo $(SYSD_DIR)/fifo-pipe-as-init.service
 	install -m 0755 debian/bootmisc.sh $(INITD_DIR)
+	install -m 0755 debian/masked.init $(INITD_DIR)/masked
 	touch $(INITD_DIR)/README
 
 override_dh_fixperms:
diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags
index d570cdb..9f35134 100644
--- a/t/tests/systemd-general/tags
+++ b/t/tests/systemd-general/tags
@@ -14,5 +14,6 @@ W: systemd-general: init.d-script-does-not-source-init-functions etc/init.d/syst
 W: systemd-general: maintainer-script-calls-systemctl postrm:6
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/bootmisc.sh
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/fifo-pipe-as-init
+W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/masked
 W: systemd-general: systemd-service-file-refers-to-obsolete-target etc/systemd/system/test.service syslog.target
 W: systemd-general: systemd-service-file-refers-to-obsolete-target usr/lib/systemd/system/test.service syslog.target
-- 
2.1.4


Reply to: