---
Changes in v4
- renamed install_dependency -> dependency
- removed the enum with dependencies and used the general one instead
- add an error meesage in the case that --root is used and it fails
- changes in manpage
TODO | 1 -
man/systemctl.xml | 19 +++
src/core/dbus-manager.c| 83 +--
src/core/org.freedesktop.systemd1.conf | 4 ++
src/core/selinux-access.c | 29 ++
src/core/selinux-access.h | 3 +
src/core/unit.c| 29 --
src/core/unit.h| 51 -
src/shared/install.c | 89 ++---
src/shared/install.h | 2 +
src/shared/unit-name.c | 29 ++
src/shared/unit-name.h | 51 +
src/systemctl/systemctl.c | 100 +
13 files changed, 370 insertions(+), 120 deletions(-)
diff --git a/TODO b/TODO
index 0c648f9..c12d55f 100644
--- a/TODO
+++ b/TODO
@@ -453,7 +453,6 @@ Features:
- "systemctl mask" should find all names by which a unit is accessible
(i.e. by scanning for symlinks to it) and link them all to /dev/null
- systemctl list-unit-files should list generated files (and probably with a
new state "generated" for them, or so)
- - systemctl: maybe add "systemctl add-wants" or so...
* timer units:
- timer units should get the ability to trigger when:
diff --git a/man/systemctl.xml b/man/systemctl.xml
index b28a3b7..b2aa17f 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -1098,6 +1098,25 @@ kobject-uevent 1 systemd-udevd-kernel.socket
systemd-udevd.service
+ add-wants TARGET
+ NAME...
+ add-requires TARGET
+ NAME...
+
+
+Adds Wants= resp.
Requires=
+dependency to the specified TARGET for
+one or more units.
+
+This command honors --system,
+--user, --runtime and
+--global in a similar way as
+enable.
+
+
+
+
+
link
FILENAME...
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 533ce43..57db1c9 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1562,9 +1562,6 @@ static int method_enable_unit_files_generic(
sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
-#ifdef HAVE_SELINUX
-char **i;
-#endif
UnitFileChange *changes = NULL;
unsigned n_changes = 0;
UnitFileScope scope;
@@ -1588,18 +1585,9 @@ static int method_enable_unit_files_generic(
if (r < 0)
return r;
-#ifdef HAVE_SELINUX
-STRV_FOREACH(i, l) {
-Unit *u;
-
-u = manager_get_unit(m, *i);
-if (u) {
-r = selinux_unit_access_check(u, message, verb, error);
-if (r < 0)
-return r;
-}
-}
-#endif
+r = selinux_unit_access_check_strv(l, message, m, verb, error);
+if (r < 0)
+return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM :
UNIT_FILE_USER;
@@ -1637,9 +1625,6 @@ static int method_mask_unit_files(sd_bus *bus,
sd_bus_message *message, void *us
static int method_preset_unit_files_with_mode(sd_bus *bus, sd_bus_message
*message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
-#ifdef HAVE_SELINUX
-char **i;
-#endif
UnitFileChange *changes = NULL;
unsigned n_changes = 0;
Manager *m = userdata;
@@ -1674,18 +1659,9 @@ static int method_preset_unit_files_with_mode(sd_bus
*bus, sd_bus_message *messa
return -EINVAL;
}
-#ifdef HAVE_SELINUX
-STRV_FOREACH(i, l) {
-Unit *u;
-
-u = manager_get_unit(m, *i);
-if (u) {
-r = selinux_unit_access_check(u, message, "enable",
error);
-if (r < 0)
-return r;
-}
-}
-#endif
+r = selinux_unit_access_check_strv(l, message, m, "enable", error);
+if (r < 0)
+return r;
scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM :
UNIT_FILE_USER;
@@ -1828,6 +1804,52 @@ static int method_preset_all_unit_files(sd_bus *bus,
sd_bus_message *message, vo
return reply_unit_file_changes_and_free(m, bus, message, -1, changes,
n_changes);
}
+static int method_add_dependency_unit_files(sd_bus *bus, sd_bus_message
*message, void *userdata, sd_bus_error *error) {
+_cleanup_strv_free_ char **l = NULL;
+Manager *m = userdata;
+UnitFileChange *changes = NU