From 5b99bd5fd4274c5fac86c82a38ca3334e55df543 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2020 20:33:57 +0200 Subject: [PATCH 1/2] core: some minor clean-ups/modernizations --- src/core/service.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 53dbd5509c..861d82041a 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2569,6 +2569,8 @@ static unsigned service_exec_command_index(Unit *u, ServiceExecCommand id, ExecC ExecCommand *first, *c; assert(s); + assert(id >= 0); + assert(id < _SERVICE_EXEC_COMMAND_MAX); first = s->exec_command[id]; @@ -2632,10 +2634,12 @@ static int service_serialize_exec_command(Unit *u, FILE *f, ExecCommand *command p = cescape(command->path); if (!p) - return -ENOMEM; + return log_oom(); key = strjoina(type, "-command"); - return serialize_item_format(f, key, "%s %u %s %s", service_exec_command_to_string(id), idx, p, args); + (void) serialize_item_format(f, key, "%s %u %s %s", service_exec_command_to_string(id), idx, p, args); + + return 0; } static int service_serialize(Unit *u, FILE *f, FDSet *fds) { @@ -2737,7 +2741,11 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) { return 0; } -static int service_deserialize_exec_command(Unit *u, const char *key, const char *value) { +static int service_deserialize_exec_command( + Unit *u, + const char *key, + const char *value) { + Service *s = SERVICE(u); int r; unsigned idx = 0, i; From e9da62b18af647bfa73807e1c7fc3bfa4bb4b2ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2020 20:34:02 +0200 Subject: [PATCH 2/2] core: make sure to restore the control command id, too Fixes: #15356 --- src/core/service.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 861d82041a..7d5928e455 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2834,9 +2834,10 @@ static int service_deserialize_exec_command( break; } - if (command && control) + if (command && control) { s->control_command = command; - else if (command) + s->control_command_id = id; + } else if (command) s->main_command = command; else log_unit_warning(u, "Current command vanished from the unit file, execution of the command list won't be resumed.");