1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-28 05:57:33 +03:00

kernel-install: propagate failures in plugins

This fixes a regression introduced by
42551ea7e923bac5df12b20e3e735a487d38dcd5.

In the shell script version, plugin failures are propagated to the
caller. But after the commit, failures in plugins are logged, but never
propagated as the exit code of the execution.

Fixes #30087.
This commit is contained in:
Yu Watanabe 2023-11-20 09:55:49 +09:00
parent a3f5976ded
commit e42931b0ac

View File

@ -1043,7 +1043,7 @@ static int context_prepare_execution(Context *c) {
} }
static int context_execute(Context *c) { static int context_execute(Context *c) {
int r; int r, ret;
assert(c); assert(c);
@ -1062,7 +1062,7 @@ static int context_execute(Context *c) {
log_debug("Plugin arguments: %s", strna(z)); log_debug("Plugin arguments: %s", strna(z));
} }
r = execute_strv( ret = execute_strv(
/* name = */ NULL, /* name = */ NULL,
c->plugins, c->plugins,
/* root = */ NULL, /* root = */ NULL,
@ -1072,14 +1072,13 @@ static int context_execute(Context *c) {
c->argv, c->argv,
c->envp, c->envp,
EXEC_DIR_SKIP_REMAINING); EXEC_DIR_SKIP_REMAINING);
if (r < 0)
return r;
r = context_remove_entry_dir(c); r = context_remove_entry_dir(c);
if (r < 0) if (r < 0)
return r; return r;
return 0; /* This returns 0 on success, positive exit code on plugin failure, negative errno on other failures. */
return ret;
} }
static bool bypass(void) { static bool bypass(void) {
@ -1254,10 +1253,10 @@ static int verb_add_all(int argc, char *argv[], void *userdata) {
/* version= */ (*d)->d_name, /* version= */ (*d)->d_name,
/* kernel= */ full, /* kernel= */ full,
/* initrds= */ NULL); /* initrds= */ NULL);
RET_GATHER(ret, r); if (r == 0)
if (r >= 0)
n++; n++;
else if (ret == 0)
ret = r;
} }
if (n > 0) if (n > 0)
@ -1715,4 +1714,4 @@ static int run(int argc, char* argv[]) {
return dispatch_verb(argc, argv, verbs, &c); return dispatch_verb(argc, argv, verbs, &c);
} }
DEFINE_MAIN_FUNCTION(run); DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);