1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-27 01:57:35 +03:00

Merge pull request #30095 from yuwata/kernel-install-exit-code

kernel-install: exit code
This commit is contained in:
Luca Boccassi 2023-11-20 13:33:06 +00:00 committed by GitHub
commit ad470cc155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions

View File

@ -1043,7 +1043,7 @@ static int context_prepare_execution(Context *c) {
}
static int context_execute(Context *c) {
int r;
int r, ret;
assert(c);
@ -1062,7 +1062,7 @@ static int context_execute(Context *c) {
log_debug("Plugin arguments: %s", strna(z));
}
r = execute_strv(
ret = execute_strv(
/* name = */ NULL,
c->plugins,
/* root = */ NULL,
@ -1072,14 +1072,13 @@ static int context_execute(Context *c) {
c->argv,
c->envp,
EXEC_DIR_SKIP_REMAINING);
if (r < 0)
return r;
r = context_remove_entry_dir(c);
if (r < 0)
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) {
@ -1254,10 +1253,10 @@ static int verb_add_all(int argc, char *argv[], void *userdata) {
/* version= */ (*d)->d_name,
/* kernel= */ full,
/* initrds= */ NULL);
RET_GATHER(ret, r);
if (r >= 0)
if (r == 0)
n++;
else if (ret == 0)
ret = r;
}
if (n > 0)
@ -1715,4 +1714,4 @@ static int run(int argc, char* argv[]) {
return dispatch_verb(argc, argv, verbs, &c);
}
DEFINE_MAIN_FUNCTION(run);
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);

View File

@ -306,3 +306,28 @@ diff -u <(echo "$output") - <<EOF
]
}
EOF
###########################################
# tests for propagation of plugin failure (issue #30087)
###########################################
cat >"$D/00-plugin-skip" <<EOF
#!/usr/bin/env bash
exit 77
EOF
chmod +x "$D/00-plugin-skip"
cat >"$D/10-plugin-fail" <<EOF
#!/usr/bin/env bash
exit 42
EOF
chmod +x "$D/10-plugin-fail"
# Exit code 77 means remaining plugins will be skipped.
KERNEL_INSTALL_PLUGINS="$D/00-plugin-skip $D/10-plugin-fail" "$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
# Other non-zero exit code will be propagated.
set +e
KERNEL_INSTALL_PLUGINS="$D/10-plugin-fail" "$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"
ret=$?
set -e
test "$ret" -eq "42"