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

[SCM] Debian package checker branch, master, updated. 2.2.11-29-g22733cd



The following commit has been merged in the master branch:
commit 22733cd991f0de9717cef4282e37abfe65d9278b
Author: Russ Allbery <rra@debian.org>
Date:   Thu Jun 18 15:20:17 2009 -0700

    Changelog and tweaks for init script checks
    
    Lower init.d-script-uses-usr-interpreter to normal/possible.  This is not
    a Policy violation (even of a should) and it's possible to do safely.
    It's just normally not a good idea.
    
    Ignore /etc/init.d/skeleton in init script checks as well.
    
    Rename checkinit to check_init following naming conventions elsewhere.
    We'll change globally if we start treating check_* subs as special.
    
    Make Emacs happier with comment markers in Perl regexes.

diff --git a/checks/init.d b/checks/init.d
index 43ba9d9..f799de1 100644
--- a/checks/init.d
+++ b/checks/init.d
@@ -151,7 +151,7 @@ for (keys %initd_postinst) {
     # check if file exists in package
     my $initd_file = "init.d/$_";
     if (-f $initd_file) {
-	checkinit($initd_file);
+	check_init($initd_file);
     } else {
 	tag "init.d-script-not-included-in-package", "/etc/init.d/$_";
     }
@@ -160,25 +160,24 @@ for (keys %initd_postinst) {
 # files actually installed in /etc/init.d should match our list :-)
 opendir(INITD, "init.d") or fail("cannot read init.d directory: $!");
 for (readdir(INITD)) {
-    next if $_ eq '.' || $_ eq '..' || $_ eq 'README';
+    next if $_ eq '.' || $_ eq '..' || $_ eq 'README' || $_ eq 'skeleton';
     unless ($initd_postinst{$_}) {
 	tag "script-in-etc-init.d-not-registered-via-update-rc.d", "/etc/init.d/$_";
-	checkinit("init.d/$_");
+	check_init("init.d/$_");
     }
 }
 closedir(INITD);
 
 }
 
-sub checkinit {
+sub check_init {
     my ($initd_file) = @_;
-    # yes! check it...
     open(IN, '<', $initd_file)
 	or fail("cannot open init.d file $initd_file: $!");
     my (%tag, %lsb);
     my $in_file_test = 0;
     while (defined(my $l = <IN>)) {
-	if ($. eq 1 && $l =~ m,^#!\s*(/usr/[^\s]+),) {
+	if ($. eq 1 && $l =~ m,^\#!\s*(/usr/[^\s]+),) {
 	    tag "init.d-script-uses-usr-interpreter", "/etc/init.d/$_ $1";
 	}
 	if ($l =~ m/^\#\#\# BEGIN INIT INFO/) {
@@ -225,7 +224,7 @@ sub checkinit {
 	    tag "init.d-script-sourcing-without-test", "/etc/init.d/$_:$. $1";
 	}
 
-	while ($l =~ s/^[^#]*?(start|stop|restart|force-reload)//o) {
+	while ($l =~ s/^[^\#]*?(start|stop|restart|force-reload)//o) {
 	    $tag{$1} = 1;
 	}
     }
diff --git a/checks/init.d.desc b/checks/init.d.desc
index 3131960..eec11a0 100644
--- a/checks/init.d.desc
+++ b/checks/init.d.desc
@@ -201,25 +201,29 @@ Info: This <tt>/etc/init.d</tt> script specifies the S runlevel in
  Default-Stop.
 
 Tag: init.d-script-uses-usr-interpreter
-Severity: serious
-Certainty: certain
+Severity: normal
+Certainty: possible
 Info: The given <tt>/etc/init.d</tt> script specifies an interpreter in
- its shebang located under <tt>/usr</tt>.
+ its shebang located under <tt>/usr</tt>.  This means the init script will
+ fail if run at a point in the boot sequence before the <tt>/usr</tt>
+ partition has been mounted.
  .
- Since init scripts can be left on the system when the package is
- removed but not purged, its dependencies might no longer be installed
- causing the init script to fail if the interpreter is one of its dependencies.
+ It also indicates that the init script may be using a non-essential
+ interpreter.  Since init scripts are configuration files, they may be
+ left on the system after their package has been removed but not purged.
+ At that point, the package dependencies are not guaranteed to exist and
+ the interpreter may therefore not be available.
  .
- Another case where the script might fail to execute is early during the boot
- process, when the <tt>/usr</tt> partition might not yet be mounted by the time
- the script needs its interpreter.
+ It's generally best to write init scripts using <tt>/bin/sh</tt> or
+ <tt>/bin/bash</tt> where possible, since they are guaranteed to always be
+ available.
 
 Tag: init.d-script-sourcing-without-test
 Severity: important
 Certainty: possible
 Info: The given <tt>/etc/init.d</tt> script seems to be sourcing an
- <tt>/etc/default/</tt> file without assuring its existence first.
- .
- Files in <tt>/etc/default/</tt> can be deleted by the administrator at any
- time and the init script should handle the situation gracefully.
+ <tt>/etc/default/</tt> file without checking for its existence first.
+ Files in <tt>/etc/default/</tt> can be deleted by the administrator at
+ any time, and init scripts are required to handle the situation
+ gracefully.
 Ref: policy 9.3.2
diff --git a/debian/changelog b/debian/changelog
index 4a5a7d9..49f92a1 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ lintian (2.2.12) UNRELEASED; urgency=low
       - dh_scrollkeeper-is-deprecated
       - file-in-discouraged-x11-font-directory
       - file-in-unknown-x11-font-directory
+      - init.d-script-sourcing-without-test
+      - init.d-script-uses-usr-interpreter
       - missing-separator-between-items
       - package-contains-multiple-dpi-fonts
       - package-mixes-misc-and-dpi-fonts
@@ -52,6 +54,16 @@ lintian (2.2.12) UNRELEASED; urgency=low
       subdirectories of /usr/share/fonts/X11 per Policy 11.8.5.
     + [RA] Diagnose packages including both 100dpi and 75dpi fonts or
       mixing misc and Xdpi fonts.
+  * checks/init.d{,.desc}:
+    + [RA] Also check unregistered init scripts for other syntax problems.
+      Patch from Raphael Geissert.
+    + [RA] Don't think required init.d options are implemented just
+      because they occur in a comment.  Patch from Raphael Geissert.
+    + [RA] Diagnose init scripts sourcing /etc/default files without
+      checking first whether they're present.  Patch from Raphael
+      Geissert.  (Closes: #533571)
+    + [RA] Diagnose init scripts that use interpreters in /usr.  Patch
+      from Raphael Geissert.
   * checks/menus{,.desc}:
     + [RA] Read menu-methods files from the collected location instead of
       the unpacked binary package and change the unpack level of menus to
diff --git a/t/tests/init.d-general/desc b/t/tests/init.d-general/desc
index 91a4a90..1e4745f 100644
--- a/t/tests/init.d-general/desc
+++ b/t/tests/init.d-general/desc
@@ -3,5 +3,6 @@ Sequence: 6000
 Version: 1.0
 Description: Test tags related to the init.d checks
 Test-For:
-  init.d-script-does-not-implement-required-option
-  init.d-script-uses-usr-interpreter
+ init.d-script-does-not-implement-required-option
+ init.d-script-sourcing-without-test
+ init.d-script-uses-usr-interpreter
diff --git a/t/tests/init.d-general/tags b/t/tests/init.d-general/tags
index e13c89a..44d4adc 100644
--- a/t/tests/init.d-general/tags
+++ b/t/tests/init.d-general/tags
@@ -2,5 +2,5 @@ E: init.d-general-bugs: init.d-script-does-not-implement-required-option /etc/in
 E: init.d-general-bugs: init.d-script-does-not-implement-required-option /etc/init.d/init.d-general-bugs restart
 E: init.d-general-bugs: init.d-script-does-not-implement-required-option /etc/init.d/init.d-general-bugs start
 E: init.d-general-bugs: init.d-script-does-not-implement-required-option /etc/init.d/init.d-general-bugs stop
-E: init.d-general-interpreter-in-usr-dir: init.d-script-uses-usr-interpreter /etc/init.d/init.d-general-interpreter-in-usr-dir /usr/bin/perl
 E: init.d-general-sourcing-without-test: init.d-script-sourcing-without-test /etc/init.d/init.d-general-sourcing-without-test:15 /etc/default/rcS
+W: init.d-general-interpreter-in-usr-dir: init.d-script-uses-usr-interpreter /etc/init.d/init.d-general-interpreter-in-usr-dir /usr/bin/perl
diff --git a/t/tests/init.d-script-registration/debian/debian/install b/t/tests/init.d-script-registration/debian/debian/install
index dcfc064..2d8e757 100644
--- a/t/tests/init.d-script-registration/debian/debian/install
+++ b/t/tests/init.d-script-registration/debian/debian/install
@@ -1,2 +1,3 @@
 foo.in /etc/init.d/
 README /etc/init.d/
+skeleton /etc/init.d/
diff --git a/t/tests/init.d-script-registration/debian/debian/rules b/t/tests/init.d-script-registration/debian/debian/rules
index be15443..8d53c91 100644
--- a/t/tests/init.d-script-registration/debian/debian/rules
+++ b/t/tests/init.d-script-registration/debian/debian/rules
@@ -6,4 +6,5 @@
 binary:
 	dh $@ --until dh_fixperms
 	chmod -x debian/init.d-script-registration/etc/init.d/README
+	chmod -x debian/init.d-script-registration/etc/init.d/skeleton
 	dh $@ --remaining
diff --git a/t/tests/init.d-script-registration/debian/skeleton b/t/tests/init.d-script-registration/debian/skeleton
new file mode 100644
index 0000000..5984f06
--- /dev/null
+++ b/t/tests/init.d-script-registration/debian/skeleton
@@ -0,0 +1,2 @@
+The skeleton file looks like an init script, but we don't want to check it
+like an init script.
diff --git a/t/tests/init.d-script-registration/desc b/t/tests/init.d-script-registration/desc
index 4674ad2..ae1c889 100644
--- a/t/tests/init.d-script-registration/desc
+++ b/t/tests/init.d-script-registration/desc
@@ -2,4 +2,6 @@ Testname: init.d-script-registration
 Sequence: 6000
 Version: 1.0
 Description: Test tags related to the registration of init scripts
-Test-For: init.d-script-missing-lsb-section
\ No newline at end of file
+Test-For:
+ init.d-script-missing-lsb-section
+ script-in-etc-init.d-not-registered-via-update-rc.d

-- 
Debian package checker


Reply to: