load-fragment: config_parse_emergency_action() doesn't ever get a Manager pointer passed in

In 'data' we get the location passed in we write stuff, and that's not
the Manager object.

And we neither get the Manager passed in via 'userdata', because at the
time we parse the emergency action for the manager the Manager is not
actually allocated yet.

hence, let's fix this differently, and pass in the user/system mode
descriptor via the 'ltype' argument.

Fixes: #25933
This commit is contained in:
Lennart Poettering
2023-01-06 16:15:46 +01:00
parent 2ae6917a1a
commit 724f061db6
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -5581,25 +5581,26 @@ int config_parse_emergency_action(
void *data,
void *userdata) {
Manager *m = NULL;
EmergencyAction *x = ASSERT_PTR(data);
bool is_system;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
/* If we have a unit determine the scope based on it */
if (unit)
m = ((Unit*) userdata)->manager;
is_system = MANAGER_IS_SYSTEM(((Unit*) ASSERT_PTR(userdata))->manager);
else
m = data;
is_system = ltype; /* otherwise, assume the scope is passed in via ltype */
r = parse_emergency_action(rvalue, MANAGER_IS_SYSTEM(m), x);
r = parse_emergency_action(rvalue, is_system, x);
if (r < 0) {
if (r == -EOPNOTSUPP)
log_syntax(unit, LOG_WARNING, filename, line, r,
"%s= specified as %s mode action, ignoring: %s",
lvalue, MANAGER_IS_SYSTEM(m) ? "user" : "system", rvalue);
lvalue, is_system ? "user" : "system", rvalue);
else
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=, ignoring: %s", lvalue, rvalue);
+1 -1
View File
@@ -683,7 +683,7 @@ static int parse_config_file(void) {
{ "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting },
{ "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting },
{ "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max },
{ "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action },
{ "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, arg_system, &arg_cad_burst_action },
{ "Manager", "DefaultOOMPolicy", config_parse_oom_policy, 0, &arg_default_oom_policy },
{ "Manager", "DefaultOOMScoreAdjust", config_parse_oom_score_adjust, 0, NULL },
{ "Manager", "ReloadLimitIntervalSec", config_parse_sec, 0, &arg_reload_limit_interval_sec },