mirror of
https://git.proxmox.com/git/grub2
synced 2025-07-26 23:41:40 +00:00
Make grub-script-check fail on scripts containing no commands (closes:
#713886).
This commit is contained in:
parent
854efa1e2b
commit
87b245fc65
@ -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;
|
||||
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -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).
|
||||
|
87
debian/patches/script_check_no_commands.patch
vendored
Normal file
87
debian/patches/script_check_no_commands.patch
vendored
Normal file
@ -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 <cjwatson@debian.org>
|
||||
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 <<EOF && exit 1
|
||||
+
|
||||
+EOF
|
||||
+
|
||||
+@builddir@/grub-script-check <<EOF && exit 1
|
||||
+# comment
|
||||
+EOF
|
||||
+
|
||||
+@builddir@/grub-script-check <<EOF && exit 1
|
||||
+# comment 1
|
||||
+# comment 2
|
||||
+
|
||||
+EOF
|
||||
+
|
||||
+exit 0
|
||||
Index: b/util/grub-script-check.c
|
||||
===================================================================
|
||||
--- a/util/grub-script-check.c
|
||||
+++ b/util/grub-script-check.c
|
||||
@@ -92,7 +92,7 @@
|
||||
int lineno = 0;
|
||||
FILE *file = 0;
|
||||
struct arguments arguments;
|
||||
- int found_input = 0;
|
||||
+ int found_input = 0, found_cmd = 0;
|
||||
struct grub_script *script = NULL;
|
||||
|
||||
auto grub_err_t get_config_line (char **line, int cont);
|
||||
@@ -177,6 +177,8 @@
|
||||
script = grub_script_parse (input, get_config_line);
|
||||
if (script)
|
||||
{
|
||||
+ if (script->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;
|
||||
}
|
1
debian/patches/series
vendored
1
debian/patches/series
vendored
@ -46,3 +46,4 @@ install_signed.patch
|
||||
install_bios_setup_path.patch
|
||||
os_prober_efi.patch
|
||||
acpihalt_improvements.patch
|
||||
script_check_no_commands.patch
|
||||
|
21
tests/grub_script_no_commands.in
Normal file
21
tests/grub_script_no_commands.in
Normal file
@ -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 <<EOF && exit 1
|
||||
|
||||
EOF
|
||||
|
||||
@builddir@/grub-script-check <<EOF && exit 1
|
||||
# comment
|
||||
EOF
|
||||
|
||||
@builddir@/grub-script-check <<EOF && exit 1
|
||||
# comment 1
|
||||
# comment 2
|
||||
|
||||
EOF
|
||||
|
||||
exit 0
|
@ -92,7 +92,7 @@ main (int argc, char *argv[])
|
||||
int lineno = 0;
|
||||
FILE *file = 0;
|
||||
struct arguments arguments;
|
||||
int found_input = 0;
|
||||
int found_input = 0, found_cmd = 0;
|
||||
struct grub_script *script = NULL;
|
||||
|
||||
auto grub_err_t get_config_line (char **line, int cont);
|
||||
@ -177,6 +177,8 @@ main (int argc, char *argv[])
|
||||
script = grub_script_parse (input, get_config_line);
|
||||
if (script)
|
||||
{
|
||||
if (script->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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user