From: Zbigniew Jędrzejewski-Szmek Date: Wed, 9 Jun 2021 14:33:23 +0000 (+0200) Subject: shared/install: ignore failures for auxiliary files X-Git-Tag: v249-rc1~42^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3aa96361ed32b4084cdd59caaebca9cbdc66db0f;p=thirdparty%2Fsystemd.git shared/install: ignore failures for auxiliary files If Also= fails, warn, but otherwise ignore the failure. Fixes #19407. --- diff --git a/src/shared/install.c b/src/shared/install.c index b6dc0c6e60b..a97a4ef5c5c 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -269,7 +269,6 @@ int unit_file_changes_add( _cleanup_free_ char *p = NULL, *s = NULL; UnitFileChange *c; - assert(path); assert(!changes == !n_changes); if (type_or_errno >= 0) @@ -285,11 +284,13 @@ int unit_file_changes_add( return -ENOMEM; *changes = c; - p = strdup(path); - if (!p) - return -ENOMEM; + if (path) { + p = strdup(path); + if (!p) + return -ENOMEM; - path_simplify(p); + path_simplify(p); + } if (source) { s = strdup(source); @@ -355,6 +356,10 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang log_warning("Unit %s is added as a dependency to a non-existent unit %s.", changes[i].source, changes[i].path); break; + case UNIT_FILE_AUXILIARY_FAILED: + if (!quiet) + log_warning("Failed to enable auxiliary unit %s, ignoring.", changes[i].source); + break; case -EEXIST: if (changes[i].source) log_error_errno(changes[i].type_or_errno, @@ -2037,6 +2042,13 @@ static int install_context_apply( q = install_info_traverse(scope, c, paths, i, flags, NULL); if (q < 0) { + if (i->auxiliary) { + q = unit_file_changes_add(changes, n_changes, UNIT_FILE_AUXILIARY_FAILED, NULL, i->name); + if (q < 0) + return q; + continue; + } + unit_file_changes_add(changes, n_changes, q, i->name, NULL); return q; } @@ -3493,6 +3505,7 @@ static const char* const unit_file_change_type_table[_UNIT_FILE_CHANGE_TYPE_MAX] [UNIT_FILE_IS_MASKED] = "masked", [UNIT_FILE_IS_DANGLING] = "dangling", [UNIT_FILE_DESTINATION_NOT_PRESENT] = "destination not present", + [UNIT_FILE_AUXILIARY_FAILED] = "auxiliary unit failed", }; DEFINE_STRING_TABLE_LOOKUP(unit_file_change_type, int); diff --git a/src/shared/install.h b/src/shared/install.h index 7ab0a871e04..74a45db04c6 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -33,6 +33,7 @@ enum { UNIT_FILE_IS_MASKED, UNIT_FILE_IS_DANGLING, UNIT_FILE_DESTINATION_NOT_PRESENT, + UNIT_FILE_AUXILIARY_FAILED, _UNIT_FILE_CHANGE_TYPE_MAX, _UNIT_FILE_CHANGE_TYPE_INVALID = -EINVAL, };