* util/grub-script-check.c: Fail on scripts containing no
commands, to guard against corrupted grub-mkconfig setups that produce no useful output. * tests/grub_script_no_commands.in: New test. * Makefile.util.def (grub_script_no_commands): Add. Reported by Hans Putter. Fixes Debian bug #713886.
This commit is contained in:
parent
a4c89b1731
commit
e639c204e0
4 changed files with 45 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2013-06-25 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* util/grub-script-check.c: Fail on scripts containing no
|
||||||
|
commands, to guard against corrupted grub-mkconfig setups that
|
||||||
|
produce no useful output.
|
||||||
|
* tests/grub_script_no_commands.in: New test.
|
||||||
|
* Makefile.util.def (grub_script_no_commands): Add.
|
||||||
|
Reported by Hans Putter. Fixes Debian bug #713886.
|
||||||
|
|
||||||
2013-06-16 Andrey Borzenkov <arvidjaar@gmail.com>
|
2013-06-16 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
* grub-core/disk/diskfilter.c: Forgot to remove comment
|
* grub-core/disk/diskfilter.c: Forgot to remove comment
|
||||||
|
|
|
@ -748,6 +748,12 @@ script = {
|
||||||
common = tests/grub_script_not.in;
|
common = tests/grub_script_not.in;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
script = {
|
||||||
|
testcase;
|
||||||
|
name = grub_script_no_commands;
|
||||||
|
common = tests/grub_script_no_commands.in;
|
||||||
|
};
|
||||||
|
|
||||||
script = {
|
script = {
|
||||||
testcase;
|
testcase;
|
||||||
name = partmap_test;
|
name = partmap_test;
|
||||||
|
|
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
|
|
@ -143,7 +143,7 @@ main (int argc, char *argv[])
|
||||||
.file = 0
|
.file = 0
|
||||||
};
|
};
|
||||||
char *input;
|
char *input;
|
||||||
int found_input = 0;
|
int found_input = 0, found_cmd = 0;
|
||||||
struct grub_script *script = NULL;
|
struct grub_script *script = NULL;
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
|
@ -188,6 +188,8 @@ main (int argc, char *argv[])
|
||||||
script = grub_script_parse (input, get_config_line, &ctx);
|
script = grub_script_parse (input, get_config_line, &ctx);
|
||||||
if (script)
|
if (script)
|
||||||
{
|
{
|
||||||
|
if (script->cmd)
|
||||||
|
found_cmd = 1;
|
||||||
grub_script_execute (script);
|
grub_script_execute (script);
|
||||||
grub_script_free (script);
|
grub_script_free (script);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +204,12 @@ main (int argc, char *argv[])
|
||||||
fprintf (stderr, _("Syntax error at line %u\n"), ctx.lineno);
|
fprintf (stderr, _("Syntax error at line %u\n"), ctx.lineno);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (! found_cmd)
|
||||||
|
{
|
||||||
|
fprintf (stderr, _("Script contains no commands and will do nothing\n"),
|
||||||
|
ctx.arguments.filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue