* 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
|
@ -143,7 +143,7 @@ main (int argc, char *argv[])
|
|||
.file = 0
|
||||
};
|
||||
char *input;
|
||||
int found_input = 0;
|
||||
int found_input = 0, found_cmd = 0;
|
||||
struct grub_script *script = NULL;
|
||||
|
||||
set_program_name (argv[0]);
|
||||
|
@ -188,6 +188,8 @@ main (int argc, char *argv[])
|
|||
script = grub_script_parse (input, get_config_line, &ctx);
|
||||
if (script)
|
||||
{
|
||||
if (script->cmd)
|
||||
found_cmd = 1;
|
||||
grub_script_execute (script);
|
||||
grub_script_free (script);
|
||||
}
|
||||
|
@ -202,6 +204,12 @@ main (int argc, char *argv[])
|
|||
fprintf (stderr, _("Syntax error at line %u\n"), ctx.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…
Add table
Add a link
Reference in a new issue