Re: [systemd-devel] [PATCH v4] systemctl: add add-wants and add-requires verbs

2014-10-08 Thread Lukáš Nykrýn
Zbigniew Jędrzejewski-Szmek píše v Út 07. 10. 2014 v 23:11 +0200:
 On Tue, Oct 07, 2014 at 05:46:48PM +0200, Zbigniew Jędrzejewski-Szmek wrote:
  On Tue, Oct 07, 2014 at 02:09:37PM +0200, Lukas Nykryn wrote:
   ---
   Changes in v4
   - renamed install_dependency - dependency
   - removed the enum with dependencies and used the general one instead
  This part should really be a separate commit. It moves a lot of code
  around and makes it harder to see what is going on.
done
  
   - add an error meesage in the case that --root is used and it fails
   - changes in manpage
  Looks good, please push.
done
 Jan Synacek's patch f7101b7368 adds a check to unit_file_enable().
 An identical check should be applied to the code path you are adding.
done
 
 Zbyszek

Thanks for reviews!
Lukas

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH v4] systemctl: add add-wants and add-requires verbs

2014-10-07 Thread Lukas Nykryn
---
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
 /varlistentry
 
 varlistentry
+  termcommandadd-wants replaceableTARGET/replaceable
+  replaceableNAME/replaceable.../command/term
+  termcommandadd-requires replaceableTARGET/replaceable
+  replaceableNAME/replaceable.../command/term
+
+  listitem
+paraAdds literalWants=/literal resp. 
literalRequires=/literal
+dependency to the specified replaceableTARGET/replaceable for
+one or more units. /para
+
+paraThis command honors option--system/option,
+option--user/option, option--runtime/option and
+option--global/option in a similar way as
+commandenable/command./para
+
+  /listitem
+/varlistentry
+
+varlistentry
   termcommandlink 
replaceableFILENAME/replaceable.../command/term
 
   listitem
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 

Re: [systemd-devel] [PATCH v4] systemctl: add add-wants and add-requires verbs

2014-10-07 Thread Zbigniew Jędrzejewski-Szmek
On Tue, Oct 07, 2014 at 02:09:37PM +0200, Lukas Nykryn wrote:
 ---
 Changes in v4
 - renamed install_dependency - dependency
 - removed the enum with dependencies and used the general one instead
This part should really be a separate commit. It moves a lot of code
around and makes it harder to see what is going on.

 - add an error meesage in the case that --root is used and it fails
 - changes in manpage
Looks good, please push.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v4] systemctl: add add-wants and add-requires verbs

2014-10-07 Thread Zbigniew Jędrzejewski-Szmek
On Tue, Oct 07, 2014 at 05:46:48PM +0200, Zbigniew Jędrzejewski-Szmek wrote:
 On Tue, Oct 07, 2014 at 02:09:37PM +0200, Lukas Nykryn wrote:
  ---
  Changes in v4
  - renamed install_dependency - dependency
  - removed the enum with dependencies and used the general one instead
 This part should really be a separate commit. It moves a lot of code
 around and makes it harder to see what is going on.
 
  - add an error meesage in the case that --root is used and it fails
  - changes in manpage
 Looks good, please push.
Jan Synacek's patch f7101b7368 adds a check to unit_file_enable().
An identical check should be applied to the code path you are adding.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel