mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
core/load-fragment: refuse units with errors in RootDirectory/RootImage/DynamicUser
Behaviour of the service is completely different with the option off, so the service would probably mess up state on disk and do unexpected things.
This commit is contained in:
parent
bb28e68477
commit
2c75fb7330
@ -18,8 +18,8 @@ struct ConfigPerfItem;
|
||||
m4_dnl Define the context options only once
|
||||
m4_define(`EXEC_CONTEXT_CONFIG_ITEMS',
|
||||
`$1.WorkingDirectory, config_parse_working_directory, 0, offsetof($1, exec_context)
|
||||
$1.RootDirectory, config_parse_unit_path_printf, 0, offsetof($1, exec_context.root_directory)
|
||||
$1.RootImage, config_parse_unit_path_printf, 0, offsetof($1, exec_context.root_image)
|
||||
$1.RootDirectory, config_parse_unit_path_printf, true, offsetof($1, exec_context.root_directory)
|
||||
$1.RootImage, config_parse_unit_path_printf, true, offsetof($1, exec_context.root_image)
|
||||
$1.User, config_parse_user_group, 0, offsetof($1, exec_context.user)
|
||||
$1.Group, config_parse_user_group, 0, offsetof($1, exec_context.group)
|
||||
$1.SupplementaryGroups, config_parse_user_group_strv, 0, offsetof($1, exec_context.supplementary_groups)
|
||||
@ -35,7 +35,7 @@ $1.UMask, config_parse_mode, 0,
|
||||
$1.Environment, config_parse_environ, 0, offsetof($1, exec_context.environment)
|
||||
$1.EnvironmentFile, config_parse_unit_env_file, 0, offsetof($1, exec_context.environment_files)
|
||||
$1.PassEnvironment, config_parse_pass_environ, 0, offsetof($1, exec_context.pass_environment)
|
||||
$1.DynamicUser, config_parse_bool, 0, offsetof($1, exec_context.dynamic_user)
|
||||
$1.DynamicUser, config_parse_bool, true, offsetof($1, exec_context.dynamic_user)
|
||||
$1.StandardInput, config_parse_exec_input, 0, offsetof($1, exec_context)
|
||||
$1.StandardOutput, config_parse_exec_output, 0, offsetof($1, exec_context)
|
||||
$1.StandardError, config_parse_exec_output, 0, offsetof($1, exec_context)
|
||||
|
@ -242,6 +242,7 @@ int config_parse_unit_path_printf(
|
||||
_cleanup_free_ char *k = NULL;
|
||||
Unit *u = userdata;
|
||||
int r;
|
||||
bool fatal = ltype;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -250,8 +251,10 @@ int config_parse_unit_path_printf(
|
||||
|
||||
r = unit_full_printf(u, rvalue, &k);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to resolve unit specifiers on %s, ignoring: %m", rvalue);
|
||||
return 0;
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to resolve unit specifiers on %s%s: %m",
|
||||
fatal ? "" : ", ignoring", rvalue);
|
||||
return fatal ? -ENOEXEC : 0;
|
||||
}
|
||||
|
||||
return config_parse_path(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata);
|
||||
|
@ -615,6 +615,7 @@ int config_parse_bool(const char* unit,
|
||||
|
||||
int k;
|
||||
bool *b = data;
|
||||
bool fatal = ltype;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -623,8 +624,10 @@ int config_parse_bool(const char* unit,
|
||||
|
||||
k = parse_boolean(rvalue);
|
||||
if (k < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
log_syntax(unit, LOG_ERR, filename, line, k,
|
||||
"Failed to parse boolean value%s: %s",
|
||||
fatal ? "" : ", ignoring", rvalue);
|
||||
return fatal ? -ENOEXEC : 0;
|
||||
}
|
||||
|
||||
*b = !!k;
|
||||
@ -715,6 +718,7 @@ int config_parse_path(
|
||||
void *userdata) {
|
||||
|
||||
char **s = data, *n;
|
||||
bool fatal = ltype;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -723,12 +727,14 @@ int config_parse_path(
|
||||
|
||||
if (!utf8_is_valid(rvalue)) {
|
||||
log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
|
||||
return 0;
|
||||
return fatal ? -ENOEXEC : 0;
|
||||
}
|
||||
|
||||
if (!path_is_absolute(rvalue)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Not an absolute path, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"Not an absolute path%s: %s",
|
||||
fatal ? "" : ", ignoring", rvalue);
|
||||
return fatal ? -ENOEXEC : 0;
|
||||
}
|
||||
|
||||
n = strdup(rvalue);
|
||||
|
Loading…
x
Reference in New Issue
Block a user