From 7756d44436cd5caad6e12846658712f0d21b9e45 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 16 Sep 2010 23:48:32 +0200 Subject: [PATCH 1/3] Basic menuentry-retrieveing jail --- grub-core/commands/configfile.c | 35 ++++++++++++---- grub-core/commands/menuentry.c | 3 +- grub-core/commands/search_wrap.c | 2 +- grub-core/commands/test.c | 2 + grub-core/kern/corecmd.c | 9 ++-- grub-core/normal/context.c | 71 +++++++++++++++++++++++++------- grub-core/script/execute.c | 7 +++- include/grub/command.h | 2 + include/grub/env.h | 9 +++- include/grub/err.h | 3 +- include/grub/normal.h | 2 + 11 files changed, 115 insertions(+), 30 deletions(-) diff --git a/grub-core/commands/configfile.c b/grub-core/commands/configfile.c index 469447711..4d54ae682 100644 --- a/grub-core/commands/configfile.c +++ b/grub-core/commands/configfile.c @@ -27,28 +27,34 @@ static grub_err_t grub_cmd_source (grub_command_t cmd, int argc, char **args) { - int new_env; + int new_env, jail; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); - new_env = (cmd->name[0] == 'c'); + jail = (cmd->name[0] == 'j'); + new_env = (cmd->name[jail ? 5 : 0] == 'c'); if (new_env) - { - grub_cls (); - grub_env_context_open (1); - } + grub_cls (); + + if (new_env && !jail) + grub_env_context_open (); + if (jail) + grub_env_jail_open (!new_env); grub_normal_execute (args[0], 1, ! new_env); - if (new_env) + if (new_env && !jail) grub_env_context_close (); + if (jail) + grub_env_jail_close (!new_env); return 0; } static grub_command_t cmd_configfile, cmd_source, cmd_dot; +static grub_command_t cmd_jail_source, cmd_jail_configfile; GRUB_MOD_INIT(configfile) { @@ -60,6 +66,19 @@ GRUB_MOD_INIT(configfile) N_("FILE"), N_("Load another config file without changing context.") ); + + cmd_jail_source = + grub_register_command ("jail_source", grub_cmd_source, + N_("FILE"), + N_("Load another config file without changing context but take only menuentries.") + ); + + cmd_jail_configfile = + grub_register_command ("jail_configfile", grub_cmd_source, + N_("FILE"), + N_("Load another config file without changing context but take only menuentries.") + ); + cmd_dot = grub_register_command (".", grub_cmd_source, N_("FILE"), @@ -71,5 +90,7 @@ GRUB_MOD_FINI(configfile) { grub_unregister_command (cmd_configfile); grub_unregister_command (cmd_source); + grub_unregister_command (cmd_jail_configfile); + grub_unregister_command (cmd_jail_source); grub_unregister_command (cmd_dot); } diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 9c4139d7d..3f6f295bc 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -274,7 +274,8 @@ void grub_menu_init (void) { cmd = grub_register_extcmd ("menuentry", grub_cmd_menuentry, - GRUB_COMMAND_FLAG_BLOCKS, + GRUB_COMMAND_FLAG_BLOCKS + | GRUB_COMMAND_FLAG_UNJAILED, N_("BLOCK"), N_("Define a menuentry."), options); } diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c index 402421f65..a06399ac6 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -90,7 +90,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(search) { cmd = - grub_register_extcmd ("search", grub_cmd_search, 0, + grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_UNJAILED, N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]" " NAME"), N_("Search devices by file, filesystem label" diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index 97b7fe6e4..3affab9c5 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -423,8 +423,10 @@ GRUB_MOD_INIT(test) { cmd_1 = grub_register_command ("[", grub_cmd_test, N_("EXPRESSION ]"), N_("Evaluate an expression.")); + cmd_1->flags |= GRUB_COMMAND_FLAG_UNJAILED; cmd_2 = grub_register_command ("test", grub_cmd_test, N_("EXPRESSION"), N_("Evaluate an expression.")); + cmd_2->flags |= GRUB_COMMAND_FLAG_UNJAILED; } GRUB_MOD_FINI(test) diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c index 8675248d3..f1d060cef 100644 --- a/grub-core/kern/corecmd.c +++ b/grub-core/kern/corecmd.c @@ -178,9 +178,12 @@ grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)), void grub_register_core_commands (void) { - grub_register_command ("set", grub_core_cmd_set, - N_("[ENVVAR=VALUE]"), - N_("Set an environment variable.")); + grub_command_t cmd; + cmd = grub_register_command ("set", grub_core_cmd_set, + N_("[ENVVAR=VALUE]"), + N_("Set an environment variable.")); + if (cmd) + cmd->flags |= GRUB_COMMAND_FLAG_UNJAILED; grub_register_command ("unset", grub_core_cmd_unset, N_("ENVVAR"), N_("Remove an environment variable.")); diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index ec718952d..3b182dde7 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -52,8 +52,8 @@ grub_env_set_menu (grub_menu_t nmenu) current_menu->menu = nmenu; } -grub_err_t -grub_env_context_open (int export) +static grub_err_t +grub_env_new_context (int export_all) { struct grub_env_context *context; int i; @@ -78,23 +78,36 @@ grub_env_context_open (int export) struct grub_env_var *var; for (var = context->prev->vars[i]; var; var = var->next) - { - if (export && var->global) - { - if (grub_env_set (var->name, var->value) != GRUB_ERR_NONE) - { - grub_env_context_close (); - return grub_errno; - } - grub_env_export (var->name); - grub_register_variable_hook (var->name, var->read_hook, var->write_hook); - } - } + if (var->global || export_all) + { + if (grub_env_set (var->name, var->value) != GRUB_ERR_NONE) + { + grub_env_context_close (); + return grub_errno; + } + grub_env_export (var->name); + grub_register_variable_hook (var->name, var->read_hook, var->write_hook); + } } return GRUB_ERR_NONE; } +grub_err_t +grub_env_context_open (void) +{ + return grub_env_new_context (0); +} + +int grub_jail_level = 0; + +grub_err_t +grub_env_jail_open (int source) +{ + grub_jail_level++; + return grub_env_new_context (source); +} + grub_err_t grub_env_context_close (void) { @@ -132,6 +145,36 @@ grub_env_context_close (void) return GRUB_ERR_NONE; } +grub_err_t +grub_env_jail_close (int source) +{ + grub_menu_t menu, menu2; + grub_menu_entry_t *last; + grub_err_t err; + + if (source) + { + menu = grub_env_get_menu (); + grub_env_unset_menu (); + } + err = grub_env_context_close (); + + if (source) + { + menu2 = grub_env_get_menu (); + + last = &menu2->entry_list; + while (*last) + last = &(*last)->next; + + *last = menu->entry_list; + menu2->size += menu->size; + } + + grub_jail_level--; + return err; +} + grub_err_t grub_env_export (const char *name) { diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index e24c4b1af..8d64962f8 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -611,8 +611,11 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) /* Execute the GRUB command or function. */ if (grubcmd) { - if ((grubcmd->flags & GRUB_COMMAND_FLAG_BLOCKS) && - (grubcmd->flags & GRUB_COMMAND_FLAG_EXTCMD)) + if (grub_jail_level && !(grubcmd->flags & GRUB_COMMAND_FLAG_UNJAILED)) + ret = grub_error (GRUB_ERR_JAIL, "%s isn't allowed to execute in jail", + cmdname); + else if ((grubcmd->flags & GRUB_COMMAND_FLAG_BLOCKS) && + (grubcmd->flags & GRUB_COMMAND_FLAG_EXTCMD)) ret = grub_extcmd_dispatcher (grubcmd, argc, args, argv.script); else ret = (grubcmd->func) (grubcmd, argc, args); diff --git a/include/grub/command.h b/include/grub/command.h index 3b7bf0a10..b17b1aa94 100644 --- a/include/grub/command.h +++ b/include/grub/command.h @@ -35,6 +35,8 @@ typedef enum grub_command_flags GRUB_COMMAND_ACCEPT_DASH = 0x80, /* This command accepts only options preceding direct arguments. */ GRUB_COMMAND_OPTIONS_AT_START = 0x100, + /* Can be executed in a jail. */ + GRUB_COMMAND_FLAG_UNJAILED = 0x200 } grub_command_flags_t; struct grub_command; diff --git a/include/grub/env.h b/include/grub/env.h index ae4fd8745..ee0e0546e 100644 --- a/include/grub/env.h +++ b/include/grub/env.h @@ -51,7 +51,7 @@ grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name, grub_env_read_hook_t read_hook, grub_env_write_hook_t write_hook); -grub_err_t grub_env_context_open (int export); +grub_err_t grub_env_context_open (void); grub_err_t grub_env_context_close (void); grub_err_t grub_env_export (const char *name); @@ -59,4 +59,11 @@ void grub_env_unset_menu (void); grub_menu_t grub_env_get_menu (void); void grub_env_set_menu (grub_menu_t nmenu); +grub_err_t +grub_env_jail_open (int source); + +grub_err_t +grub_env_jail_close (int source); + + #endif /* ! GRUB_ENV_HEADER */ diff --git a/include/grub/err.h b/include/grub/err.h index d35bba474..18dc91efe 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -54,7 +54,8 @@ typedef enum GRUB_ERR_MENU, GRUB_ERR_TIMEOUT, GRUB_ERR_IO, - GRUB_ERR_ACCESS_DENIED + GRUB_ERR_ACCESS_DENIED, + GRUB_ERR_JAIL } grub_err_t; diff --git a/include/grub/normal.h b/include/grub/normal.h index 51ab46b12..7c99951c6 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -115,4 +115,6 @@ void grub_normal_reset_more (void); void grub_xputs_normal (const char *str); +extern int grub_jail_level; + #endif /* ! GRUB_NORMAL_HEADER */ From a38b701cbf0a9d3b84bcfc2daef36a964273a5a0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 20 Sep 2010 23:01:34 +0200 Subject: [PATCH 2/3] Rename jail to extractor --- grub-core/commands/configfile.c | 32 ++++++++++++++++---------------- grub-core/commands/legacycfg.c | 2 +- grub-core/commands/menuentry.c | 2 +- grub-core/commands/search_wrap.c | 2 +- grub-core/commands/test.c | 4 ++-- grub-core/kern/corecmd.c | 2 +- grub-core/normal/context.c | 10 +++++----- grub-core/script/execute.c | 6 ++++-- include/grub/command.h | 4 ++-- include/grub/env.h | 4 ++-- include/grub/err.h | 2 +- include/grub/normal.h | 2 +- 12 files changed, 37 insertions(+), 35 deletions(-) diff --git a/grub-core/commands/configfile.c b/grub-core/commands/configfile.c index 4d54ae682..2568b7ee6 100644 --- a/grub-core/commands/configfile.c +++ b/grub-core/commands/configfile.c @@ -27,34 +27,34 @@ static grub_err_t grub_cmd_source (grub_command_t cmd, int argc, char **args) { - int new_env, jail; + int new_env, extractor; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); - jail = (cmd->name[0] == 'j'); - new_env = (cmd->name[jail ? 5 : 0] == 'c'); + extractor = (cmd->name[0] == 'e'); + new_env = (cmd->name[extractor ? sizeof ("extract_entries_") - 1 : 0] == 'c'); if (new_env) grub_cls (); - if (new_env && !jail) + if (new_env && !extractor) grub_env_context_open (); - if (jail) - grub_env_jail_open (!new_env); + if (extractor) + grub_env_extractor_open (!new_env); grub_normal_execute (args[0], 1, ! new_env); - if (new_env && !jail) + if (new_env && !extractor) grub_env_context_close (); - if (jail) - grub_env_jail_close (!new_env); + if (extractor) + grub_env_extractor_close (!new_env); return 0; } static grub_command_t cmd_configfile, cmd_source, cmd_dot; -static grub_command_t cmd_jail_source, cmd_jail_configfile; +static grub_command_t cmd_extractor_source, cmd_extractor_configfile; GRUB_MOD_INIT(configfile) { @@ -67,14 +67,14 @@ GRUB_MOD_INIT(configfile) N_("Load another config file without changing context.") ); - cmd_jail_source = - grub_register_command ("jail_source", grub_cmd_source, + cmd_extractor_source = + grub_register_command ("extract_entries_source", grub_cmd_source, N_("FILE"), N_("Load another config file without changing context but take only menuentries.") ); - cmd_jail_configfile = - grub_register_command ("jail_configfile", grub_cmd_source, + cmd_extractor_configfile = + grub_register_command ("extract_entries_configfile", grub_cmd_source, N_("FILE"), N_("Load another config file without changing context but take only menuentries.") ); @@ -90,7 +90,7 @@ GRUB_MOD_FINI(configfile) { grub_unregister_command (cmd_configfile); grub_unregister_command (cmd_source); - grub_unregister_command (cmd_jail_configfile); - grub_unregister_command (cmd_jail_source); + grub_unregister_command (cmd_extractor_configfile); + grub_unregister_command (cmd_extractor_source); grub_unregister_command (cmd_dot); } diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 463297810..c183c5a5c 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -201,7 +201,7 @@ grub_cmd_legacy_configfile (struct grub_command *cmd __attribute__ ((unused)), return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); grub_cls (); - grub_env_context_open (1); + grub_env_context_open (); ret = legacy_file (args[0]); grub_env_context_close (); diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 01f6c010d..f10e05dc3 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -289,7 +289,7 @@ grub_menu_init (void) { cmd = grub_register_extcmd ("menuentry", grub_cmd_menuentry, GRUB_COMMAND_FLAG_BLOCKS - | GRUB_COMMAND_FLAG_UNJAILED, + | GRUB_COMMAND_FLAG_EXTRACTOR, N_("BLOCK"), N_("Define a menuentry."), options); } diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c index a06399ac6..80741d7ab 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -90,7 +90,7 @@ static grub_extcmd_t cmd; GRUB_MOD_INIT(search) { cmd = - grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_UNJAILED, + grub_register_extcmd ("search", grub_cmd_search, GRUB_COMMAND_FLAG_EXTRACTOR, N_("[-f|-l|-u|-s|-n] [--hint HINT [--hint HINT] ...]" " NAME"), N_("Search devices by file, filesystem label" diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index 3affab9c5..e981c945a 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -423,10 +423,10 @@ GRUB_MOD_INIT(test) { cmd_1 = grub_register_command ("[", grub_cmd_test, N_("EXPRESSION ]"), N_("Evaluate an expression.")); - cmd_1->flags |= GRUB_COMMAND_FLAG_UNJAILED; + cmd_1->flags |= GRUB_COMMAND_FLAG_EXTRACTOR; cmd_2 = grub_register_command ("test", grub_cmd_test, N_("EXPRESSION"), N_("Evaluate an expression.")); - cmd_2->flags |= GRUB_COMMAND_FLAG_UNJAILED; + cmd_2->flags |= GRUB_COMMAND_FLAG_EXTRACTOR; } GRUB_MOD_FINI(test) diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c index f1d060cef..687692f3c 100644 --- a/grub-core/kern/corecmd.c +++ b/grub-core/kern/corecmd.c @@ -183,7 +183,7 @@ grub_register_core_commands (void) N_("[ENVVAR=VALUE]"), N_("Set an environment variable.")); if (cmd) - cmd->flags |= GRUB_COMMAND_FLAG_UNJAILED; + cmd->flags |= GRUB_COMMAND_FLAG_EXTRACTOR; grub_register_command ("unset", grub_core_cmd_unset, N_("ENVVAR"), N_("Remove an environment variable.")); diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 3b182dde7..75beeefda 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -99,12 +99,12 @@ grub_env_context_open (void) return grub_env_new_context (0); } -int grub_jail_level = 0; +int grub_extractor_level = 0; grub_err_t -grub_env_jail_open (int source) +grub_env_extractor_open (int source) { - grub_jail_level++; + grub_extractor_level++; return grub_env_new_context (source); } @@ -146,7 +146,7 @@ grub_env_context_close (void) } grub_err_t -grub_env_jail_close (int source) +grub_env_extractor_close (int source) { grub_menu_t menu, menu2; grub_menu_entry_t *last; @@ -171,7 +171,7 @@ grub_env_jail_close (int source) menu2->size += menu->size; } - grub_jail_level--; + grub_extractor_level--; return err; } diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index 8d64962f8..2cadb0e1b 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -611,8 +611,10 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) /* Execute the GRUB command or function. */ if (grubcmd) { - if (grub_jail_level && !(grubcmd->flags & GRUB_COMMAND_FLAG_UNJAILED)) - ret = grub_error (GRUB_ERR_JAIL, "%s isn't allowed to execute in jail", + if (grub_extractor_level && !(grubcmd->flags + & GRUB_COMMAND_FLAG_EXTRACTOR)) + ret = grub_error (GRUB_ERR_EXTRACTOR, + "%s isn't allowed to execute in an extractor", cmdname); else if ((grubcmd->flags & GRUB_COMMAND_FLAG_BLOCKS) && (grubcmd->flags & GRUB_COMMAND_FLAG_EXTCMD)) diff --git a/include/grub/command.h b/include/grub/command.h index b17b1aa94..19622752e 100644 --- a/include/grub/command.h +++ b/include/grub/command.h @@ -35,8 +35,8 @@ typedef enum grub_command_flags GRUB_COMMAND_ACCEPT_DASH = 0x80, /* This command accepts only options preceding direct arguments. */ GRUB_COMMAND_OPTIONS_AT_START = 0x100, - /* Can be executed in a jail. */ - GRUB_COMMAND_FLAG_UNJAILED = 0x200 + /* Can be executed in an entries extractor. */ + GRUB_COMMAND_FLAG_EXTRACTOR = 0x200 } grub_command_flags_t; struct grub_command; diff --git a/include/grub/env.h b/include/grub/env.h index ee0e0546e..6d1f0de6e 100644 --- a/include/grub/env.h +++ b/include/grub/env.h @@ -60,10 +60,10 @@ grub_menu_t grub_env_get_menu (void); void grub_env_set_menu (grub_menu_t nmenu); grub_err_t -grub_env_jail_open (int source); +grub_env_extractor_open (int source); grub_err_t -grub_env_jail_close (int source); +grub_env_extractor_close (int source); #endif /* ! GRUB_ENV_HEADER */ diff --git a/include/grub/err.h b/include/grub/err.h index b2527cea0..22334038d 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -55,7 +55,7 @@ typedef enum GRUB_ERR_TIMEOUT, GRUB_ERR_IO, GRUB_ERR_ACCESS_DENIED, - GRUB_ERR_JAIL + GRUB_ERR_EXTRACTOR } grub_err_t; diff --git a/include/grub/normal.h b/include/grub/normal.h index 390dbb1da..2fc289373 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -114,7 +114,7 @@ void grub_normal_reset_more (void); void grub_xputs_normal (const char *str); -extern int grub_jail_level; +extern int grub_extractor_level; grub_err_t grub_normal_add_menu_entry (int argc, const char **args, char **classes, From 57f20e67a042893ceecc01fa9ec4eca44866749c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Mon, 20 Sep 2010 23:10:29 +0200 Subject: [PATCH 3/3] Support extraction of legacy entries --- grub-core/commands/legacycfg.c | 69 +++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index c183c5a5c..d69dad75b 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -184,27 +184,33 @@ legacy_file (const char *filename) } static grub_err_t -grub_cmd_legacy_source (struct grub_command *cmd __attribute__ ((unused)), +grub_cmd_legacy_source (struct grub_command *cmd, int argc, char **args) { - if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); - return legacy_file (args[0]); -} - -static grub_err_t -grub_cmd_legacy_configfile (struct grub_command *cmd __attribute__ ((unused)), - int argc, char **args) -{ + int new_env, extractor; grub_err_t ret; + if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); - grub_cls (); - grub_env_context_open (); + extractor = (cmd->name[0] == 'e'); + new_env = (cmd->name[extractor ? sizeof ("extract_legacy_entries_") - 1 + : sizeof ("legacy_") - 1] == 'c'); + + if (new_env) + grub_cls (); + + if (new_env && !extractor) + grub_env_context_open (); + if (extractor) + grub_env_extractor_open (!new_env); ret = legacy_file (args[0]); - grub_env_context_close (); + + if (new_env && !extractor) + grub_env_context_close (); + if (extractor) + grub_env_extractor_close (!new_env); return ret; } @@ -730,18 +736,33 @@ grub_cmd_legacy_check_password (struct grub_command *mycmd __attribute__ ((unuse return GRUB_ERR_NONE; } -static grub_command_t cmd_source, cmd_configfile, cmd_kernel, cmd_initrd; -static grub_command_t cmd_password, cmd_check_password, cmd_initrdnounzip; +static grub_command_t cmd_source, cmd_configfile; +static grub_command_t cmd_source_extract, cmd_configfile_extract; +static grub_command_t cmd_kernel, cmd_initrd, cmd_initrdnounzip; +static grub_command_t cmd_password, cmd_check_password; GRUB_MOD_INIT(legacycfg) { - cmd_source = grub_register_command ("legacy_source", - grub_cmd_legacy_source, - N_("FILE"), N_("Parse legacy config")); - cmd_configfile = grub_register_command ("legacy_configfile", - grub_cmd_legacy_configfile, - N_("FILE"), - N_("Parse legacy config")); + cmd_source + = grub_register_command ("legacy_source", + grub_cmd_legacy_source, + N_("FILE"), + N_("Parse legacy config in same context")); + cmd_configfile + = grub_register_command ("legacy_configfile", + grub_cmd_legacy_source, + N_("FILE"), + N_("Parse legacy config in new context")); + cmd_source_extract + = grub_register_command ("extract_legacy_entries_source", + grub_cmd_legacy_source, + N_("FILE"), + N_("Parse legacy config in same context taking onl entries")); + cmd_configfile_extract + = grub_register_command ("extract_legacy_entries_configfile", + grub_cmd_legacy_source, + N_("FILE"), + N_("Parse legacy config in new context taking onl entries")); cmd_kernel = grub_register_command ("legacy_kernel", grub_cmd_legacy_kernel, @@ -773,9 +794,13 @@ GRUB_MOD_FINI(legacycfg) { grub_unregister_command (cmd_source); grub_unregister_command (cmd_configfile); + grub_unregister_command (cmd_source_extract); + grub_unregister_command (cmd_configfile_extract); + grub_unregister_command (cmd_kernel); grub_unregister_command (cmd_initrd); grub_unregister_command (cmd_initrdnounzip); + grub_unregister_command (cmd_password); grub_unregister_command (cmd_check_password); }