chiark / gitweb /
systemctl/core: ignore masked units in preset-all
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 16 Apr 2016 23:31:53 +0000 (19:31 -0400)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:57 +0000 (10:12 +0200)
With any masked unit that would that would be enabled by presets, we'd get:

test@rawhide $ sudo systemctl preset-all
Failed to execute operation: Unit file is masked.

test@rawhide $ sudo systemctl --root=/ preset-all
Operation failed: Cannot send after transport endpoint shutdown

Simply ignore those units:

test@rawhide $ sudo systemctl preset-all
Unit xxx.service is masked, ignoring.

src/shared/bus-util.c

index c8092e0e586f3619704d841452ba04854efd70eb..800657ccde18a21d2ed566a57f0c6c11f6819f93 100644 (file)
@@ -2206,11 +2206,17 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
                 if (!quiet) {
                         if (streq(type, "symlink"))
                                 log_info("Created symlink from %s to %s.", path, source);
-                        else
+                        else if (streq(type, "unlink"))
                                 log_info("Removed symlink %s.", path);
+                        else if (streq(type, "masked"))
+                                log_info("Unit %s is masked, ignoring.", path);
+                        else
+                                log_notice("Manager reported unknown change type \"%s\" for %s.", type, path);
                 }
 
-                r = unit_file_changes_add(changes, n_changes, streq(type, "symlink") ? UNIT_FILE_SYMLINK : UNIT_FILE_UNLINK, path, source);
+                r = unit_file_changes_add(changes, n_changes,
+                                          unit_file_change_type_from_string(type),
+                                          path, source);
                 if (r < 0)
                         return r;
         }