From f5a0162d2007b549bcf9f6c60fdfd96ee593569f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 26 Oct 2022 00:12:14 +0900 Subject: [PATCH] install: process all Wants= symlinks even if some of them fail Follow-up for 94e7298d309fef7710174def820e9d38e512a086. Fixes CID#1499992. --- src/shared/install.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/shared/install.c b/src/shared/install.c index 6d91a02f11..834a1c59e3 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1973,12 +1973,16 @@ static int install_info_symlink_wants( n = info->name; } + r = 0; STRV_FOREACH(s, list) { _cleanup_free_ char *path = NULL, *dst = NULL; q = install_name_printf(scope, info, *s, &dst); - if (q < 0) - return install_changes_add(changes, n_changes, q, *s, NULL); + if (q < 0) { + install_changes_add(changes, n_changes, q, *s, NULL); + if (r >= 0) + r = q; + } if (!unit_name_is_valid(dst, valid_dst_type)) { /* 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; 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 - 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; } @@ -2004,7 +2010,7 @@ static int install_info_symlink_wants( return -ENOMEM; q = create_symlink(lp, info->path, path, true, changes, n_changes); - if (r == 0) + if ((q < 0 && r >= 0) || r == 0) r = q; if (unit_file_exists(scope, lp, dst) == 0) {