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

[lintian] 01/01: Check scripts using init-functions without lsb-base Depends.



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

lamby pushed a commit to branch init.d-script-needs-depends-on-lsb-base
in repository lintian.

commit c09ecd4c2a776461d68ce9449e95169348cb79a4
Author: Chris Lamb <lamby@debian.org>
Date:   Sat Oct 1 16:05:06 2016 +0100

    Check scripts using init-functions without lsb-base Depends.
    
    Emit a tag for initscripts that source the /lib/lsb/init-functions utility
    functions without declaring the corresponding dependency on lsb-base
    (>= 3.0-6).
    
    Closes: #838997
    Signed-off-by: Chris Lamb <lamby@debian.org>
---
 checks/init.d.desc                                 |  6 ++
 checks/init.d.pm                                   | 12 +++-
 .../files-bad-perm-owner/debian/debian/control.in  |  2 +-
 t/tests/init.d-general/debian/debian/control.in    |  6 +-
 t/tests/init.d-lsb-depends/debian/debian/init      | 71 ++++++++++++++++++++++
 t/tests/init.d-lsb-depends/desc                    |  4 ++
 t/tests/init.d-lsb-depends/tags                    |  1 +
 .../init.d-lsb-headers/debian/debian/control.in    | 16 ++---
 t/tests/init.d-script-registration/tags            |  1 +
 t/tests/legacy-scripts/tags                        |  1 +
 t/tests/scripts-calls-init-script/tags             |  1 +
 t/tests/systemd-general/tags                       |  1 +
 12 files changed, 107 insertions(+), 15 deletions(-)

diff --git a/checks/init.d.desc b/checks/init.d.desc
index ce33ba5..5b19b3a 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -370,3 +370,9 @@ Info: The given init script declares a dependency on the
  totally broken.
 Ref: https://wiki.debian.org/LSBInitScripts
 
+Tag: init.d-script-needs-depends-on-lsb-base
+Severity: important
+Certainty: possible
+Info: The given init script sources the <tt>/lib/lsb/init-functions</tt> utility
+ functions without declaring the corresponding dependency on lsb-base
+ (&gt;= 3.0-6).
diff --git a/checks/init.d.pm b/checks/init.d.pm
index f91afa1..7b0fa7d 100644
--- a/checks/init.d.pm
+++ b/checks/init.d.pm
@@ -198,7 +198,7 @@ sub run {
 
         # Check if file exists in package and check the script for
         # other issues if it was included in the package.
-        check_init($initd_path);
+        check_init($initd_path, $info);
     }
 
     return unless $initd_dir and $initd_dir->is_dir;
@@ -222,7 +222,7 @@ sub run {
         # coverage in the first pass.
         unless ($initd_postinst{$script->basename}) {
             tag $tagname, $script;
-            check_init($script);
+            check_init($script, $info);
         }
     }
 
@@ -230,7 +230,7 @@ sub run {
 }
 
 sub check_init {
-    my ($initd_path) = @_;
+    my ($initd_path, $info) = @_;
 
     # In an upstart system, such as Ubuntu, init scripts are symlinks to
     # upstart-job.  It doesn't make sense to check the syntax of upstart-job,
@@ -321,6 +321,12 @@ sub check_init {
         while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload|status)//o) {
             $tag{$1} = 1;
         }
+
+        if ($l =~ m{^\s*\.\s+/lib/lsb/init-functions}
+            && !$info->relation('strong')->implies('lsb-base (>= 3.0-6)')) {
+            tag 'init.d-script-needs-depends-on-lsb-base',
+              $initd_path, "(line $.)";
+        }
     }
     close($fd);
 
diff --git a/t/tests/files-bad-perm-owner/debian/debian/control.in b/t/tests/files-bad-perm-owner/debian/debian/control.in
index 0286455..60b27bc 100644
--- a/t/tests/files-bad-perm-owner/debian/debian/control.in
+++ b/t/tests/files-bad-perm-owner/debian/debian/control.in
@@ -7,7 +7,7 @@ Build-Depends: {$build_depends}
 
 Package: binary
 Architecture: all
-Depends: $\{misc:Depends\},
+Depends: $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description}
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
diff --git a/t/tests/init.d-general/debian/debian/control.in b/t/tests/init.d-general/debian/debian/control.in
index 7bd9f10..2b08fe1 100644
--- a/t/tests/init.d-general/debian/debian/control.in
+++ b/t/tests/init.d-general/debian/debian/control.in
@@ -7,7 +7,7 @@ Build-Depends: {$build_depends}
 
 Package: {$source}
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description}
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
@@ -15,7 +15,7 @@ Description: {$description}
 
 Package: {$source}-bugs
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- bugs
  Test some simple bugs in the check
  .
@@ -35,7 +35,7 @@ Description: {$description} -- bad script interpreter
 
 Package: {$source}-sourcing-without-test
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- sourcing without test
  Test a check for . /etc/default/foo without checking the existence of
  the file beforehand.
diff --git a/t/tests/init.d-lsb-depends/debian/debian/init b/t/tests/init.d-lsb-depends/debian/debian/init
new file mode 100644
index 0000000..48d4cde
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/debian/debian/init
@@ -0,0 +1,71 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:		init.d-lsb-depends
+# Required-Start:	$syslog $remote_fs
+# Required-Stop:	$syslog $remote_fs
+# Should-Start:		$local_fs
+# Should-Stop:		$local_fs
+# Default-Start:	2 3 4 5
+# Default-Stop:		0 1 6
+# Short-Description:	init.d-lsb-depends
+# Description:		init.d-lsb-depends
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/bin/init.d-lsb-depends
+NAME=init.d-lsb-depends
+DESC=init.d-lsb-depends
+
+RUNDIR=/var/run/redis
+PIDFILE=$RUNDIR/init.d-lsb-depends.pid
+
+test -x $DAEMON || exit 0
+
+if [ -r /etc/default/$NAME ]
+then
+	. /etc/default/$NAME
+fi
+
+. /lib/lsb/init-functions
+
+set -e
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
+	then
+		echo "$NAME."
+	else
+		echo "failed"
+	fi
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	if start-stop-daemon --stop --retry --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
+	then
+		echo "$NAME."
+	else
+		echo "failed"
+	fi
+	rm -f $PIDFILE
+	sleep 1
+	;;
+
+  restart|force-reload)
+	${0} stop
+	${0} start
+	;;
+
+  status)
+	status_of_proc -p ${PIDFILE} ${DAEMON} ${NAME}
+	;;
+
+  *)
+	echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/t/tests/init.d-lsb-depends/desc b/t/tests/init.d-lsb-depends/desc
new file mode 100644
index 0000000..e0f6565
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/desc
@@ -0,0 +1,4 @@
+Testname: init.d-lsb-depends
+Version: 1.0
+Description: Test for packages missing dependencies on lsb-base
+Test-For: init.d-script-needs-depends-on-lsb-base
diff --git a/t/tests/init.d-lsb-depends/tags b/t/tests/init.d-lsb-depends/tags
new file mode 100644
index 0000000..21e92fd
--- /dev/null
+++ b/t/tests/init.d-lsb-depends/tags
@@ -0,0 +1 @@
+E: init.d-lsb-depends: init.d-script-needs-depends-on-lsb-base etc/init.d/init.d-lsb-depends (line 30)
diff --git a/t/tests/init.d-lsb-headers/debian/debian/control.in b/t/tests/init.d-lsb-headers/debian/debian/control.in
index f1246ab..fd2f749 100644
--- a/t/tests/init.d-lsb-headers/debian/debian/control.in
+++ b/t/tests/init.d-lsb-headers/debian/debian/control.in
@@ -7,7 +7,7 @@ Build-Depends: {$build_depends}
 
 Package: {$source}
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description}
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
@@ -15,7 +15,7 @@ Description: {$description}
 
 Package: {$source}-parsing
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- headers parsing
  This is a test package designed to exercise the parsing of init scripts
  by Lintian.  It is part of the Lintian test suite and may do very odd
@@ -23,7 +23,7 @@ Description: {$description} -- headers parsing
 
 Package: {$source}-remote
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- using /usr files
  This is a test package designed to exercise the checking of init scripts
  by Lintian.  It is part of the Lintian test suite and may do very odd
@@ -31,7 +31,7 @@ Description: {$description} -- using /usr files
 
 Package: {$source}-length
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- breaking length assumptions
  Test package designed to exercise the checking of init
  scripts by Lintian.  It is part of the Lintian test suite and may do
@@ -39,7 +39,7 @@ Description: {$description} -- breaking length assumptions
 
 Package: {$source}-local
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- using /var files
  This is another test package designed to exercise the checking of init
  scripts by Lintian.  It is part of the Lintian test suite and may do
@@ -47,7 +47,7 @@ Description: {$description} -- using /var files
 
 Package: {$source}-missing
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- missing runlevels
  This is yet another test package designed to exercise the checking of
  init scripts by Lintian.  It is part of the Lintian test suite and may
@@ -55,7 +55,7 @@ Description: {$description} -- missing runlevels
 
 Package: {$source}-virtual
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- virtual facilities
  Test package to exercise the virtual facilities in init.d scripts
  checks by lintian.  It is part of the Lintian test suite and may
@@ -63,7 +63,7 @@ Description: {$description} -- virtual facilities
 
 Package: {$source}-all
 Architecture: {$architecture}
-Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}, lsb-base (>= 3.0-6)
 Description: {$description} -- all virtual facilities
  Test package designed to exercise the checking of virtual all facilities
  in init.d scripts checks by lintian.
diff --git a/t/tests/init.d-script-registration/tags b/t/tests/init.d-script-registration/tags
index 3562d6c..2ed0722 100644
--- a/t/tests/init.d-script-registration/tags
+++ b/t/tests/init.d-script-registration/tags
@@ -1,4 +1,5 @@
 E: init.d-script-registration: init-script-is-not-a-file etc/init.d/bar
+E: init.d-script-registration: init.d-script-needs-depends-on-lsb-base etc/init.d/foo.in (line 3)
 W: init.d-script-registration: init.d-script-missing-lsb-section etc/init.d/foo.in
 W: init.d-script-registration: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/bar
 W: init.d-script-registration: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/foo.in
diff --git a/t/tests/legacy-scripts/tags b/t/tests/legacy-scripts/tags
index 3f2854c..0436902 100644
--- a/t/tests/legacy-scripts/tags
+++ b/t/tests/legacy-scripts/tags
@@ -10,6 +10,7 @@ E: scripts: init.d-script-does-not-implement-required-option etc/init.d/lsb-brok
 E: scripts: init.d-script-does-not-implement-required-option etc/init.d/lsb-broken restart
 E: scripts: init.d-script-has-duplicate-lsb-section etc/init.d/lsb-broken
 E: scripts: init.d-script-has-unterminated-lsb-section etc/init.d/lsb-broken:15
+E: scripts: init.d-script-needs-depends-on-lsb-base etc/init.d/skeleton (line 40)
 E: scripts: missing-dep-for-interpreter jruby => jruby | jruby1.0 | jruby1.1 | jruby1.2 (usr/bin/jruby-broken)
 E: scripts: missing-dep-for-interpreter lefty => graphviz (usr/bin/lefty-foo)
 E: scripts: package-installs-python-bytecode usr/lib/python2.3/site-packages/test.pyc
diff --git a/t/tests/scripts-calls-init-script/tags b/t/tests/scripts-calls-init-script/tags
index f1cbd81..efa3050 100644
--- a/t/tests/scripts-calls-init-script/tags
+++ b/t/tests/scripts-calls-init-script/tags
@@ -1 +1,2 @@
+E: scripts-calls-init-script: init.d-script-needs-depends-on-lsb-base etc/init.d/self-invoke (line 12)
 E: scripts-calls-init-script: maintainer-script-calls-init-script-directly postinst:5
diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags
index 3d9bb5d..fb59e2c 100644
--- a/t/tests/systemd-general/tags
+++ b/t/tests/systemd-general/tags
@@ -1,4 +1,5 @@
 E: systemd-general: init-script-is-not-a-file etc/init.d/fifo-pipe-as-init
+E: systemd-general: init.d-script-needs-depends-on-lsb-base etc/init.d/systemd-aliasd (line 35)
 E: systemd-general: service-file-is-not-a-file etc/systemd/system/fifo-pipe-as-init.service
 E: systemd-general: service-key-has-whitespace etc/systemd/system/test.service at line 3
 E: systemd-general: service-key-has-whitespace usr/lib/systemd/system/test.service at line 3

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


Reply to: