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

[lintian] 02/02: Emit new "elf-maintainer-script" classification tag if debian/postinst (etc.) is an ELF binary.



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

lamby pushed a commit to branch master
in repository lintian.

commit aa56791c81f3f8a94847da0feb4bb32335945f14
Author: Chris Lamb <lamby@debian.org>
Date:   Sat Jul 22 10:41:11 2017 +0100

    Emit new "elf-maintainer-script" classification tag if debian/postinst (etc.) is an ELF binary.
---
 checks/scripts.desc                              | 5 +++++
 checks/scripts.pm                                | 5 +++++
 collection/scripts                               | 7 ++++---
 debian/changelog                                 | 2 ++
 t/tests/scripts-does-not-start-with-shebang/desc | 2 ++
 t/tests/scripts-does-not-start-with-shebang/tags | 1 +
 6 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/checks/scripts.desc b/checks/scripts.desc
index 90e4be3..78e31af 100644
--- a/checks/scripts.desc
+++ b/checks/scripts.desc
@@ -753,3 +753,8 @@ Info: The maintainer script appears to use <tt>dpkg-statoverride --add</tt>
  without a prior call to <tt>dpkg-statoverride --list</tt> to check the
  current status.
 Ref: policy 10.9.1
+
+Tag: elf-maintainer-script
+Severity: classification
+Certainty: certain
+Info: The maintainer script is an ELF binary.
diff --git a/checks/scripts.pm b/checks/scripts.pm
index d7daee6..1aff985 100644
--- a/checks/scripts.pm
+++ b/checks/scripts.pm
@@ -542,6 +542,11 @@ sub run {
             next;
         }
 
+        if ($interpreter eq 'ELF') {
+            tag 'elf-maintainer-script', "control/$file";
+            next;
+        }
+
         tag 'interpreter-not-absolute', "control/$file", "#!$interpreter"
           unless ($interpreter =~ m|^/|);
 
diff --git a/collection/scripts b/collection/scripts
index 1c4260a..c659e54 100755
--- a/collection/scripts
+++ b/collection/scripts
@@ -73,13 +73,14 @@ sub collect {
         next unless $path =~ m/^(?:(?:pre|post)(?:inst|rm)|config)$/;
 
         # Allow ELF binaries
-        my $magic;
         my $fd = $path->open;
+        my ($magic, $scriptpath);
         if (read($fd, $magic, 4)) {
-            next if $magic eq "\x7FELF";
+            $scriptpath = 'ELF' if $magic eq "\x7FELF";
         }
         close($fd);
-        my $scriptpath = shebang_line($path) // '';
+        # If they aren't ELF, look for a shebang
+        $scriptpath = $scriptpath // shebang_line($path) // '';
 
         # Remove everything after the first space (i.e. any options)
         $scriptpath =~ s/\s++ .++ \Z//xsm;
diff --git a/debian/changelog b/debian/changelog
index 74c5b55..ebe5f26 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -73,6 +73,8 @@ lintian (2.5.52) UNRELEASED; urgency=medium
       corresponding --list.  (Closes: #652963)
     + [CL] Add missing "contains" verb to the description of the
       debhelper-autoscript-in-maintainer-scripts tag.
+    + [CL] Emit new "elf-maintainer-script" classification tag if
+      debian/postinst (etc.) is an ELF binary.
   * checks/rules.desc:
     + [CL] Clarify wording in debian-rules-parses-dpkg-parsechangelog to
       make the justification clearer.  (Closes: #865882)
diff --git a/t/tests/scripts-does-not-start-with-shebang/desc b/t/tests/scripts-does-not-start-with-shebang/desc
index f999796..a05537d 100644
--- a/t/tests/scripts-does-not-start-with-shebang/desc
+++ b/t/tests/scripts-does-not-start-with-shebang/desc
@@ -1,6 +1,8 @@
 Testname: scripts-does-not-start-with-shebang
 Type: native
 Version: 1.0
+Options: -L +classification -C scripts
 Description: Check for maintainer scripts that do not start with #!
 Test-For:
  script-without-interpreter
+ elf-maintainer-script
diff --git a/t/tests/scripts-does-not-start-with-shebang/tags b/t/tests/scripts-does-not-start-with-shebang/tags
index c93921a..1e30a6f 100644
--- a/t/tests/scripts-does-not-start-with-shebang/tags
+++ b/t/tests/scripts-does-not-start-with-shebang/tags
@@ -1 +1,2 @@
+C: scripts-does-not-start-with-shebang: elf-maintainer-script control/preinst
 E: scripts-does-not-start-with-shebang: script-without-interpreter control/postrm

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


Reply to: