Rename jail to extractor
This commit is contained in:
parent
1b71d7500b
commit
a38b701cbf
12 changed files with 37 additions and 35 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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."));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue