menu enhancements
Hi all,
Attached is a patch that adds a similar check for commands prefixed with
(/usr)?/bin/ in menu files (just noticed I forgot to implement it also
for .desktop files, will do so in a separate patch), and adds a sort of
exception for sh and sensible-{browser,editor,pager} for
menu-command-not-in-package as they are provided by Essential: yes
packages.
Cheers,
--
Atomo64 - Raphael
Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
diff --git a/checks/menu-format b/checks/menu-format
index ecd2d7b..ba2510f 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -626,6 +626,11 @@ sub VerifyLine {
or ($tested_packages >= 2)
or ($section =~ m:^(WindowManagers/Modules|FVWM Modules|Window Maker):));
+ if ($vals{'command'} =~ m,^(/(?:usr/)?s?bin/\w+),
+ || ($command && $command =~ m,^(/(?:usr/)?s?bin/\w+),)) {
+ tag 'menu-command-with-path', "$fullname:$linecount $1";
+ }
+
if (exists($vals{'icon'})) {
VerifyIcon($menufile, $fullname, $linecount, $vals{'icon'}, 32);
}
@@ -895,7 +900,7 @@ sub VerifyCmd {
} else {
$cmd = $com[0];
}
- my $okay = $cmd && ($cmd =~ /^[\'\"]/ || $file_index{$cmd} || grep { $file_index{$_ . $cmd} } @path);
+ my $okay = $cmd && ($cmd =~ /^[\'\"]/ || $file_index{$cmd} || $cmd =~ m,^(/bin/)?sh, || $cmd =~ m,^(/usr/bin/)?sensible-(pager|editor|browser), || grep { $file_index{$_ . $cmd} } @path);
return ($okay, $cmd);
}
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index d1f6d65..1c4cc8f 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -270,3 +270,10 @@ Info: The desktop entry specifies a command that is not available in the
desktop file after the install location of the binary was changed. A
desktop file for a command should be included in the same package as that
command.
+
+Tag: menu-command-with-path
+Type: warning
+Info: The menu command entry has a prepended path. Programs called from menu
+ files normally should not have a path prepended. Prepending a path may prevent
+ the local administrator or user from using a replacement version of a command
+ for some local reason.
diff --git a/testset/binary/debian/menu b/testset/binary/debian/menu
index 652381a..e8972f4 100644
--- a/testset/binary/debian/menu
+++ b/testset/binary/debian/menu
@@ -23,3 +23,4 @@
?package(binary):needs="fvwmmodule" section="Window Maker" title="Fake Module"\
command="hello"
?package(binary):needs="x11" section="Applications/System/Hardware" title="Run xfdisk" command="su-to-root -c 'xfdisk -f'"
+?package(binary):needs="text" section="Applications/System/Administration" title="foo" command="sh /path/to/foo"
diff --git a/testset/tags.binary b/testset/tags.binary
index 7819d9c..4ffa527 100644
--- a/testset/tags.binary
+++ b/testset/tags.binary
@@ -95,6 +95,12 @@ W: binary: menu-command-not-in-package /usr/share/menu/binary:18 imnothere
W: binary: menu-command-not-in-package /usr/share/menu/binary:20 cfdisk
W: binary: menu-command-not-in-package /usr/share/menu/binary:4 xfdisk
W: binary: menu-command-not-in-package /usr/share/menu/binary:7 /imnothere
+W: binary: menu-command-with-path /usr/lib/menu/binary:2 /usr/bin/su
+W: binary: menu-command-with-path /usr/lib/menu/binary:21 /usr/bin/hello
+W: binary: menu-command-with-path /usr/lib/menu/binary:4 /usr/sbin/su
+W: binary: menu-command-with-path /usr/share/menu/binary:2 /usr/bin/su
+W: binary: menu-command-with-path /usr/share/menu/binary:21 /usr/bin/hello
+W: binary: menu-command-with-path /usr/share/menu/binary:4 /usr/sbin/su
W: binary: menu-file-in-usr-lib usr/lib/menu/binary
W: binary: menu-item-creates-new-section Applications/System /usr/lib/menu/binary:2
W: binary: menu-item-creates-new-section Applications/System /usr/share/menu/binary:2
Reply to: