diff --git a/Makefile.util.def b/Makefile.util.def index 0afbda269..cbac10c8c 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -699,6 +699,12 @@ script = { common = tests/grub_script_not.in; }; +script = { + testcase; + name = grub_script_no_commands; + common = tests/grub_script_no_commands.in; +}; + script = { testcase; name = partmap_test; diff --git a/debian/changelog b/debian/changelog index 760a235e1..d3c8c09fe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ grub2 (2.00-15) UNRELEASED; urgency=low * Install reportbug presubj and script files in all binary packages. * Make grub-yeeloong.postinst explicitly install with --target=mipsel-loongson (closes: #708204). + * Make grub-script-check fail on scripts containing no commands (closes: + #713886). [ Debconf translations ] * Hungarian (Dr. Nagy Elemér Károly). diff --git a/debian/patches/script_check_no_commands.patch b/debian/patches/script_check_no_commands.patch new file mode 100644 index 000000000..789ce8337 --- /dev/null +++ b/debian/patches/script_check_no_commands.patch @@ -0,0 +1,87 @@ +Description: Guard against scripts containing no commands + Make grub-script-check fail on scripts containing no commands, to guard + against corrupted grub-mkconfig setups that produce no useful output. +Origin: backport, http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/5044 +Author: Colin Watson +Bug-Debian: http://bugs.debian.org/713886 +Forwarded: not-needed +Last-Update: 2013-06-25 + +Index: b/Makefile.util.def +=================================================================== +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -701,6 +701,12 @@ + + script = { + testcase; ++ name = grub_script_no_commands; ++ common = tests/grub_script_no_commands.in; ++}; ++ ++script = { ++ testcase; + name = partmap_test; + common = tests/partmap_test.in; + }; +Index: b/tests/grub_script_no_commands.in +=================================================================== +--- /dev/null ++++ b/tests/grub_script_no_commands.in +@@ -0,0 +1,21 @@ ++#! /bin/sh ++set -e ++ ++# grub-script-check refuses to pass a file with no commands; this usually ++# indicates a bug in the code generating that file. ++ ++@builddir@/grub-script-check <cmd) ++ found_cmd = 1; + grub_script_execute (script); + grub_script_free (script); + } +@@ -191,6 +193,12 @@ + fprintf (stderr, _("Syntax error at line %u\n"), lineno); + return 1; + } ++ if (! found_cmd) ++ { ++ fprintf (stderr, _("Script contains no commands and will do nothing\n"), ++ ctx.arguments.filename); ++ return 1; ++ } + + return 0; + } diff --git a/debian/patches/series b/debian/patches/series index a6188ccc1..774634b4e 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -46,3 +46,4 @@ install_signed.patch install_bios_setup_path.patch os_prober_efi.patch acpihalt_improvements.patch +script_check_no_commands.patch diff --git a/tests/grub_script_no_commands.in b/tests/grub_script_no_commands.in new file mode 100644 index 000000000..c31d267e5 --- /dev/null +++ b/tests/grub_script_no_commands.in @@ -0,0 +1,21 @@ +#! /bin/sh +set -e + +# grub-script-check refuses to pass a file with no commands; this usually +# indicates a bug in the code generating that file. + +@builddir@/grub-script-check <cmd) + found_cmd = 1; grub_script_execute (script); grub_script_free (script); } @@ -191,6 +193,12 @@ main (int argc, char *argv[]) fprintf (stderr, _("Syntax error at line %u\n"), lineno); return 1; } + if (! found_cmd) + { + fprintf (stderr, _("Script contains no commands and will do nothing\n"), + ctx.arguments.filename); + return 1; + } return 0; }