Axel Beckert pushed to branch master at lintian / lintian


Commits:
9266486e by Luca Boccassi at 2024-05-06T01:57:46+01:00
wrong-path-for-interpreter: allow aliased locations

merged-usr is mandatory in Debian since Bookworm (and much longer ago
in Ubuntu), so /usr/bin/bash is a valid path, as is /bin/python3.
Detect and ignore these instances.

Closes: #1051338

- - - - -


2 changed files:

- lib/Lintian/Check/Scripts.pm
- t/recipes/checks/scripts/scripts-control-interpreters/eval/hints


Changes:

=====================================
lib/Lintian/Check/Scripts.pm
=====================================
@@ -47,6 +47,7 @@ const my $NOT_EQUAL => q{!=};
 const my $BAD_MAINTAINER_COMMAND_FIELDS => 5;
 const my $UNVERSIONED_INTERPRETER_FIELDS => 2;
 const my $VERSIONED_INTERPRETER_FIELDS => 5;
+const my $USR_PREFIX_LENGTH => 4;
 
 use Moo;
 use namespace::clean;
@@ -692,10 +693,17 @@ sub visit_control_files {
           'incorrect-path-for-interpreter'
           : 'wrong-path-for-interpreter';
 
+# Debian is now mandatory usr-merged, so /bin/sh and /usr/bin/sh are both 
acceptable
+        if ($expected =~ '^(/bin/|/sbin/)') {
+            $expected = '(?:/usr)?' . $expected;
+        } elsif ($expected =~ '^/usr(/bin/|/sbin/)') {
+            $expected = '(?:/usr)?' . substr($expected, $USR_PREFIX_LENGTH);
+        }
+
         $self->pointed_hint(
             $tag_name, $item->pointer,  $interpreter,
             $NOT_EQUAL, $expected
-        )unless $interpreter eq $expected;
+        )unless $interpreter =~ $expected;
 
     } elsif ($item->name eq 'config') {
         $self->pointed_hint('forbidden-config-interpreter',
@@ -716,10 +724,17 @@ sub visit_control_files {
           'incorrect-path-for-interpreter'
           : 'wrong-path-for-interpreter';
 
+# Debian is now mandatory usr-merged, so /bin/sh and /usr/bin/sh are both 
acceptable
+        if ($expected =~ '^(/bin/|/sbin/)') {
+            $expected = '(?:/usr)?' . $expected;
+        } elsif ($expected =~ '^/usr(/bin/|/sbin/)') {
+            $expected = '(?:/usr)?' . substr($expected, $USR_PREFIX_LENGTH);
+        }
+
         $self->pointed_hint(
             $tag_name, $item->pointer, $interpreter,
             $NOT_EQUAL, $expected
-        )unless $interpreter eq $expected;
+        )unless $interpreter =~ $expected;
 
         $self->pointed_hint('unusual-control-interpreter', $item->pointer,
             $interpreter);


=====================================
t/recipes/checks/scripts/scripts-control-interpreters/eval/hints
=====================================
@@ -9,8 +9,6 @@ scripts-control-interpreters-prepython (binary): 
unusual-control-interpreter /us
 scripts-control-interpreters-prepython (binary): unusual-control-interpreter 
/usr/bin/python3 [postinst]
 scripts-control-interpreters-prepython (binary): maintainer-script-interpreter 
/usr/bin/python3 [preinst]
 scripts-control-interpreters-prepython (binary): maintainer-script-interpreter 
/usr/bin/python3 [postinst]
-scripts-control-interpreters-paths (binary): wrong-path-for-interpreter 
/usr/bin/bash != /bin/bash [postinst]
-scripts-control-interpreters-paths (binary): wrong-path-for-interpreter 
/bin/python3 != /usr/bin/python3 [prerm]
 scripts-control-interpreters-paths (binary): unusual-control-interpreter 
/bin/python3 [prerm]
 scripts-control-interpreters-paths (binary): maintainer-script-interpreter 
/usr/local/bin/bash [preinst]
 scripts-control-interpreters-paths (binary): maintainer-script-interpreter 
/usr/bin/bash [postinst]



View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/9266486e228fa9dcc20e6500f909c7b3c07b93b0

-- 
View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/9266486e228fa9dcc20e6500f909c7b3c07b93b0
You're receiving this email because of your account on salsa.debian.org.


Reply via email to