]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: ignore failures for auxiliary files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Jun 2021 14:33:23 +0000 (16:33 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Jun 2021 19:39:15 +0000 (21:39 +0200)
If Also= fails, warn, but otherwise ignore the failure.

Fixes #19407.

src/shared/install.c
src/shared/install.h

index b6dc0c6e60b5fb69d3d853f74eb8914524ce9c9f..a97a4ef5c5c7f7b45792692abb74dd874e9be03a 100644 (file)
@@ -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);
index 7ab0a871e04af2fce4577d9c157e6011b85d20b3..74a45db04c6d124f770563940109501434e451e8 100644 (file)
@@ -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,
 };