[systemd-commits] 2 commits - src/core

Lennart Poettering lennart at kemper.freedesktop.org
Sun Jun 30 17:48:41 PDT 2013


 src/core/dbus-mount.c   |    2 ++
 src/core/dbus-scope.c   |   14 ++++++++++----
 src/core/dbus-service.c |    2 ++
 src/core/dbus-slice.c   |    2 ++
 src/core/dbus-socket.c  |    6 ++++--
 src/core/dbus-swap.c    |    2 ++
 src/core/dbus-unit.c    |    7 +++++--
 src/core/dbus-unit.h    |    7 +++++--
 8 files changed, 32 insertions(+), 10 deletions(-)

New commits:
commit adb3a45d9a1cebdec30406cc2c04503fc5e735be
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jul 1 02:47:11 2013 +0200

    scope: properly implement passive validity checking of PIDs field when creating transient scopes

diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c
index 30b9c00..bddf8f4 100644
--- a/src/core/dbus-scope.c
+++ b/src/core/dbus-scope.c
@@ -93,6 +93,7 @@ static int bus_scope_set_transient_property(
 
         if (streq(name, "PIDs")) {
                 DBusMessageIter sub;
+                unsigned n;
 
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_ARRAY ||
                     dbus_message_iter_get_element_type(i) != DBUS_TYPE_UINT32)
@@ -111,14 +112,17 @@ static int bus_scope_set_transient_property(
                         if (pid <= 1)
                                 return -EINVAL;
 
-                        r = set_put(s->pids, LONG_TO_PTR(pid));
-                        if (r < 0 && r != -EEXIST)
-                                return r;
+                        if (mode != UNIT_CHECK) {
+                                r = set_put(s->pids, LONG_TO_PTR(pid));
+                                if (r < 0 && r != -EEXIST)
+                                        return r;
+                        }
 
                         dbus_message_iter_next(&sub);
+                        n++;
                 }
 
-                if (set_size(s->pids) <= 0)
+                if (n <= 0)
                         return -EINVAL;
 
                 return 1;

commit d7550a6752be85f98408a86b7ae23a033e9b2983
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Jul 1 02:45:02 2013 +0200

    core: move ControlGroup and Slice properties out of the dbus "Unit" interface
    
    Slice/ControlGroup only really makes sense for unit types which actually
    have cgroups attached to them, hence move them out of the generic Unit
    interface and into the specific unit type interfaces.
    
    These fields will continue to be part of Unit though, simply because
    things are a log easier that way. However, regardless how this looks
    internally we should keep things clean and independent of the specific
    implementation of the inside.

diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c
index ef55fcb..72e1870 100644
--- a/src/core/dbus-mount.c
+++ b/src/core/dbus-mount.c
@@ -36,6 +36,7 @@
         "  <property name=\"Options\" type=\"s\" access=\"read\"/>\n"   \
         "  <property name=\"Type\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecMount")                         \
         BUS_EXEC_COMMAND_INTERFACE("ExecUnmount")                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecRemount")                       \
@@ -158,6 +159,7 @@ DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMess
 
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit",  bus_unit_properties,           u },
+                { "org.freedesktop.systemd1.Mount", bus_unit_cgroup_properties,    u },
                 { "org.freedesktop.systemd1.Mount", bus_mount_properties,          m },
                 { "org.freedesktop.systemd1.Mount", bus_exec_context_properties,   &m->exec_context },
                 { "org.freedesktop.systemd1.Mount", bus_kill_context_properties,   &m->kill_context },
diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c
index 604d147..30b9c00 100644
--- a/src/core/dbus-scope.c
+++ b/src/core/dbus-scope.c
@@ -30,6 +30,7 @@
 
 #define BUS_SCOPE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Scope\">\n"        \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         "  <property name=\"TimeoutStopUSec\" type=\"t\" access=\"read\"/>\n" \
         BUS_KILL_CONTEXT_INTERFACE                                      \
         BUS_CGROUP_CONTEXT_INTERFACE                                    \
@@ -65,6 +66,7 @@ DBusHandlerResult bus_scope_message_handler(Unit *u, DBusConnection *c, DBusMess
 
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit",  bus_unit_properties,           u },
+                { "org.freedesktop.systemd1.Scope", bus_unit_cgroup_properties,    u },
                 { "org.freedesktop.systemd1.Scope", bus_scope_properties,          s },
                 { "org.freedesktop.systemd1.Scope", bus_cgroup_context_properties, &s->cgroup_context },
                 { "org.freedesktop.systemd1.Scope", bus_kill_context_properties,   &s->kill_context   },
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index 3bedda6..c2e0220 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -46,6 +46,7 @@
         "  <property name=\"StartLimitInterval\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitBurst\" type=\"u\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitAction\" type=\"s\" access=\"readwrite\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPre")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecStart")                         \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPost")                     \
@@ -152,6 +153,7 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connectio
 
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit",    bus_unit_properties,             u },
+                { "org.freedesktop.systemd1.Service", bus_unit_cgroup_properties,      u },
                 { "org.freedesktop.systemd1.Service", bus_service_properties,          s },
                 { "org.freedesktop.systemd1.Service", bus_exec_context_properties,     &s->exec_context },
                 { "org.freedesktop.systemd1.Service", bus_kill_context_properties,     &s->kill_context },
diff --git a/src/core/dbus-slice.c b/src/core/dbus-slice.c
index 3b67779..dac9fbd 100644
--- a/src/core/dbus-slice.c
+++ b/src/core/dbus-slice.c
@@ -29,6 +29,7 @@
 
 #define BUS_SLICE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Slice\">\n"        \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_CGROUP_CONTEXT_INTERFACE                                    \
         " </interface>\n"
 
@@ -53,6 +54,7 @@ DBusHandlerResult bus_slice_message_handler(Unit *u, DBusConnection *c, DBusMess
 
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit",  bus_unit_properties,           u },
+                { "org.freedesktop.systemd1.Slice", bus_unit_cgroup_properties,    u },
                 { "org.freedesktop.systemd1.Slice", bus_cgroup_context_properties, &s->cgroup_context },
                 {}
         };
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index a431fa1..da317ed 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -34,6 +34,7 @@
         "  <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n"   \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPre")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPost")                     \
         BUS_EXEC_COMMAND_INTERFACE("ExecStopPre")                       \
@@ -196,18 +197,19 @@ static const BusProperty bus_socket_properties[] = {
         { "SmackLabel",     bus_property_append_string,        "s", offsetof(Socket, smack),          true },
         { "SmackLabelIPIn", bus_property_append_string,        "s", offsetof(Socket, smack_ip_in),    true },
         { "SmackLabelIPOut",bus_property_append_string,        "s", offsetof(Socket, smack_ip_out),   true },
-        { NULL, }
+        {}
 };
 
 DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         Socket *s = SOCKET(u);
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit",   bus_unit_properties,           u },
+                { "org.freedesktop.systemd1.Socket", bus_unit_cgroup_properties,    u },
                 { "org.freedesktop.systemd1.Socket", bus_socket_properties,         s },
                 { "org.freedesktop.systemd1.Socket", bus_exec_context_properties,   &s->exec_context },
                 { "org.freedesktop.systemd1.Socket", bus_kill_context_properties,   &s->kill_context },
                 { "org.freedesktop.systemd1.Socket", bus_cgroup_context_properties, &s->cgroup_context },
-                { NULL, }
+                {}
         };
 
         SELINUX_UNIT_ACCESS_CHECK(u, c, message, "status");
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c
index d854e0f..86fcf16 100644
--- a/src/core/dbus-swap.c
+++ b/src/core/dbus-swap.c
@@ -35,6 +35,7 @@
         "  <property name=\"What\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"Priority\" type=\"i\" access=\"read\"/>\n"  \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecActivate")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecDeactivate")                    \
         BUS_EXEC_CONTEXT_INTERFACE                                      \
@@ -105,6 +106,7 @@ DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessa
         Swap *s = SWAP(u);
         const BusBoundProperties bps[] = {
                 { "org.freedesktop.systemd1.Unit", bus_unit_properties,           u },
+                { "org.freedesktop.systemd1.Swap", bus_unit_cgroup_properties,    u },
                 { "org.freedesktop.systemd1.Swap", bus_swap_properties,           s },
                 { "org.freedesktop.systemd1.Swap", bus_exec_context_properties,   &s->exec_context },
                 { "org.freedesktop.systemd1.Swap", bus_kill_context_properties,   &s->kill_context },
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 36c3abd..6273e46 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -878,7 +878,6 @@ const BusProperty bus_unit_properties[] = {
         { "Id",                   bus_property_append_string,         "s", offsetof(Unit, id),                                         true },
         { "Names",                bus_unit_append_names,             "as", 0 },
         { "Following",            bus_unit_append_following,          "s", 0 },
-        { "Slice",                bus_unit_append_slice,              "s", 0 },
         { "Requires",             bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUIRES]),                true },
         { "RequiresOverridable",  bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUIRES_OVERRIDABLE]),    true },
         { "Requisite",            bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUISITE]),               true },
@@ -937,7 +936,11 @@ const BusProperty bus_unit_properties[] = {
         { "ConditionTimestampMonotonic", bus_property_append_usec,    "t", offsetof(Unit, condition_timestamp.monotonic)      },
         { "ConditionResult",      bus_property_append_bool,           "b", offsetof(Unit, condition_result)                   },
         { "LoadError",            bus_unit_append_load_error,      "(ss)", 0 },
-        { "ControlGroup",         bus_property_append_string,         "s", offsetof(Unit, cgroup_path),                                true },
         { "Transient",            bus_property_append_bool,           "b", offsetof(Unit, transient)                          },
         { NULL, }
 };
+
+const BusProperty bus_unit_cgroup_properties[] = {
+        { "Slice",                bus_unit_append_slice,              "s", 0 },
+        { "ControlGroup",         bus_property_append_string,         "s", offsetof(Unit, cgroup_path),                                true },
+};
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
index 18f7c4f..d3f7ec6 100644
--- a/src/core/dbus-unit.h
+++ b/src/core/dbus-unit.h
@@ -68,7 +68,6 @@
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"Names\" type=\"as\" access=\"read\"/>\n"    \
         "  <property name=\"Following\" type=\"s\" access=\"read\"/>\n" \
-        "  <property name=\"Slice\" type=\"s\" access=\"read\"/>\n"     \
         "  <property name=\"Requires\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"RequiresOverridable\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"Requisite\" type=\"as\" access=\"read\"/>\n" \
@@ -127,15 +126,19 @@
         "  <property name=\"ConditionTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"ConditionResult\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"LoadError\" type=\"(ss)\" access=\"read\"/>\n" \
-        "  <property name=\"ControlGroup\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"Transient\" type=\"b\" access=\"read\"/>\n" \
         " </interface>\n"
 
+#define BUS_UNIT_CGROUP_INTERFACE                                       \
+        "  <property name=\"Slice\" type=\"s\" access=\"read\"/>\n"     \
+        "  <property name=\"ControlGroup\" type=\"s\" access=\"read\"/>\n"
+
 #define BUS_UNIT_INTERFACES_LIST                \
         BUS_GENERIC_INTERFACES_LIST             \
         "org.freedesktop.systemd1.Unit\0"
 
 extern const BusProperty bus_unit_properties[];
+extern const BusProperty bus_unit_cgroup_properties[];
 
 void bus_unit_send_change_signal(Unit *u);
 void bus_unit_send_removed_signal(Unit *u);



More information about the systemd-commits mailing list