diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bus-util.c | 10 | ||||
-rw-r--r-- | src/shared/install.c | 34 | ||||
-rw-r--r-- | src/shared/install.h | 5 |
3 files changed, 32 insertions, 17 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 2b86b1fcd6..677970b7f0 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2203,11 +2203,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; } diff --git a/src/shared/install.c b/src/shared/install.c index 8d9f96553b..10c724edbd 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -119,9 +119,9 @@ static int path_is_generator(const LookupPaths *p, const char *path) { if (!parent) return -ENOMEM; - return path_equal(p->generator, parent) || - path_equal(p->generator_early, parent) || - path_equal(p->generator_late, parent); + return path_equal_ptr(parent, p->generator) || + path_equal_ptr(parent, p->generator_early) || + path_equal_ptr(parent, p->generator_late); } static int path_is_transient(const LookupPaths *p, const char *path) { @@ -134,7 +134,7 @@ static int path_is_transient(const LookupPaths *p, const char *path) { if (!parent) return -ENOMEM; - return path_equal(p->transient, parent); + return path_equal_ptr(parent, p->transient); } static int path_is_control(const LookupPaths *p, const char *path) { @@ -147,8 +147,8 @@ static int path_is_control(const LookupPaths *p, const char *path) { if (!parent) return -ENOMEM; - return path_equal(parent, p->persistent_control) || - path_equal(parent, p->runtime_control); + return path_equal_ptr(parent, p->persistent_control) || + path_equal_ptr(parent, p->runtime_control); } static int path_is_config(const LookupPaths *p, const char *path) { @@ -164,8 +164,8 @@ static int path_is_config(const LookupPaths *p, const char *path) { if (!parent) return -ENOMEM; - return path_equal(parent, p->persistent_config) || - path_equal(parent, p->runtime_config); + return path_equal_ptr(parent, p->persistent_config) || + path_equal_ptr(parent, p->runtime_config); } static int path_is_runtime(const LookupPaths *p, const char *path) { @@ -186,12 +186,12 @@ static int path_is_runtime(const LookupPaths *p, const char *path) { if (!parent) return -ENOMEM; - return path_equal(parent, p->runtime_config) || - path_equal(parent, p->generator) || - path_equal(parent, p->generator_early) || - path_equal(parent, p->generator_late) || - path_equal(parent, p->transient) || - path_equal(parent, p->runtime_control); + return path_equal_ptr(parent, p->runtime_config) || + path_equal_ptr(parent, p->generator) || + path_equal_ptr(parent, p->generator_early) || + path_equal_ptr(parent, p->generator_late) || + path_equal_ptr(parent, p->transient) || + path_equal_ptr(parent, p->runtime_control); } static int path_is_vendor(const LookupPaths *p, const char *path) { @@ -754,7 +754,7 @@ static int install_info_may_process(UnitFileInstallInfo *i, const LookupPaths *p * not subject to enable/disable operations. */ if (i->type == UNIT_FILE_TYPE_MASKED) - return -ESHUTDOWN; + return -ERFKILL; if (path_is_generator(paths, i->path)) return -EADDRNOTAVAIL; if (path_is_transient(paths, i->path)) @@ -2539,6 +2539,9 @@ int unit_file_preset_all( continue; r = preset_prepare_one(scope, &plus, &minus, &paths, mode, de->d_name); + if (r == -ERFKILL) + r = unit_file_changes_add(changes, n_changes, + UNIT_FILE_IS_MASKED, de->d_name, NULL); if (r < 0) return r; } @@ -2652,6 +2655,7 @@ DEFINE_STRING_TABLE_LOOKUP(unit_file_state, UnitFileState); static const char* const unit_file_change_type_table[_UNIT_FILE_CHANGE_TYPE_MAX] = { [UNIT_FILE_SYMLINK] = "symlink", [UNIT_FILE_UNLINK] = "unlink", + [UNIT_FILE_IS_MASKED] = "masked", }; DEFINE_STRING_TABLE_LOOKUP(unit_file_change_type, UnitFileChangeType); diff --git a/src/shared/install.h b/src/shared/install.h index 6f8b45d4f6..6b760def9b 100644 --- a/src/shared/install.h +++ b/src/shared/install.h @@ -72,10 +72,15 @@ enum UnitFilePresetMode { enum UnitFileChangeType { UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK, + UNIT_FILE_IS_MASKED, _UNIT_FILE_CHANGE_TYPE_MAX, _UNIT_FILE_CHANGE_TYPE_INVALID = -1 }; +static inline bool unit_file_change_is_modification(UnitFileChangeType type) { + return IN_SET(type, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK); +} + struct UnitFileChange { UnitFileChangeType type; char *path; |