1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-21 02:50:18 +03:00

install: process all Wants= symlinks even if some of them fail

Follow-up for 94e7298d309fef7710174def820e9d38e512a086.

Fixes CID#1499992.
This commit is contained in:
Yu Watanabe 2022-10-26 00:12:14 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent ee3cbfdbbc
commit f5a0162d20

View File

@ -1973,12 +1973,16 @@ static int install_info_symlink_wants(
n = info->name; n = info->name;
} }
r = 0;
STRV_FOREACH(s, list) { STRV_FOREACH(s, list) {
_cleanup_free_ char *path = NULL, *dst = NULL; _cleanup_free_ char *path = NULL, *dst = NULL;
q = install_name_printf(scope, info, *s, &dst); q = install_name_printf(scope, info, *s, &dst);
if (q < 0) if (q < 0) {
return install_changes_add(changes, n_changes, q, *s, NULL); install_changes_add(changes, n_changes, q, *s, NULL);
if (r >= 0)
r = q;
}
if (!unit_name_is_valid(dst, valid_dst_type)) { if (!unit_name_is_valid(dst, valid_dst_type)) {
/* Generate a proper error here: EUCLEAN if the name is generally bad, EIDRM if the /* Generate a proper error here: EUCLEAN if the name is generally bad, EIDRM if the
@ -1992,9 +1996,11 @@ static int install_info_symlink_wants(
continue; continue;
if (unit_name_is_valid(dst, UNIT_NAME_ANY)) if (unit_name_is_valid(dst, UNIT_NAME_ANY))
return install_changes_add(changes, n_changes, -EIDRM, dst, n); q = install_changes_add(changes, n_changes, -EIDRM, dst, n);
else else
return install_changes_add(changes, n_changes, -EUCLEAN, dst, NULL); q = install_changes_add(changes, n_changes, -EUCLEAN, dst, NULL);
if (r >= 0)
r = q;
continue; continue;
} }
@ -2004,7 +2010,7 @@ static int install_info_symlink_wants(
return -ENOMEM; return -ENOMEM;
q = create_symlink(lp, info->path, path, true, changes, n_changes); q = create_symlink(lp, info->path, path, true, changes, n_changes);
if (r == 0) if ((q < 0 && r >= 0) || r == 0)
r = q; r = q;
if (unit_file_exists(scope, lp, dst) == 0) { if (unit_file_exists(scope, lp, dst) == 0) {