summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-16 19:31:53 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-16 21:51:09 -0400
commit9a0a413a195a21888cf926be5595d0efc1eef0fe (patch)
tree80034840b635cecbb8d2fff9416a833e244b0e01 /src
parent76ec966f0e33685f8331603805c0349adceea836 (diff)
systemctl/core: ignore masked units in preset-all
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/dbus-manager.c12
-rw-r--r--src/shared/bus-util.c10
-rw-r--r--src/shared/install.c4
-rw-r--r--src/shared/install.h5
-rw-r--r--src/systemctl/systemctl.c16
5 files changed, 36 insertions, 11 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 0b12aae2ef..9a913a6c91 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1565,11 +1565,13 @@ static int reply_unit_file_changes_and_free(
unsigned i;
int r;
- if (n_changes > 0) {
- r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
- if (r < 0)
- log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
- }
+ for (i = 0; i < n_changes; i++)
+ if (unit_file_change_is_modification(changes[i].type)) {
+ r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
+ if (r < 0)
+ log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
+ break;
+ }
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
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 35d83dd16c..74de8141f1 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -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;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4942dbb6ad..0c64cbab80 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1989,12 +1989,20 @@ static void dump_unit_file_changes(const UnitFileChange *changes, unsigned n_cha
assert(changes || n_changes == 0);
- for (i = 0; i < n_changes; i++) {
- if (changes[i].type == UNIT_FILE_SYMLINK)
+ for (i = 0; i < n_changes; i++)
+ switch(changes[i].type) {
+ case UNIT_FILE_SYMLINK:
log_info("Created symlink %s, pointing to %s.", changes[i].path, changes[i].source);
- else
+ break;
+ case UNIT_FILE_UNLINK:
log_info("Removed %s.", changes[i].path);
- }
+ break;
+ case UNIT_FILE_IS_MASKED:
+ log_info("Unit %s is masked, ignoring.", changes[i].path);
+ break;
+ default:
+ assert_not_reached("bad change type");
+ }
}
static int set_default(int argc, char *argv[], void *userdata) {