chiark / gitweb /
journal-file: protect against alloca(0)
[elogind.git] / src / core / dbus-unit.c
index 5fca7653e0b2a795f47070a531468a359aaadeb3..e95a5292773dde92113950a762c008d3162f361e 100644 (file)
@@ -32,6 +32,7 @@
 #include "dbus-client-track.h"
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_load_state, unit_load_state, UnitLoadState);
+static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_job_mode, job_mode, JobMode);
 
 static int property_get_names(
                 sd_bus *bus,
@@ -326,7 +327,10 @@ static int property_get_conditions(
                 return r;
 
         LIST_FOREACH(conditions, c, u->conditions) {
-                r = sd_bus_message_append(reply, "sbbsi", condition_type_to_string(c->type), c->trigger, c->negate, c->parameter, c->state);
+                r = sd_bus_message_append(reply, "(sbbsi)",
+                                          condition_type_to_string(c->type),
+                                          c->trigger, c->negate,
+                                          c->parameter, c->state);
                 if (r < 0)
                         return r;
 
@@ -476,18 +480,10 @@ int bus_unit_method_set_properties(sd_bus *bus, sd_bus_message *message, void *u
         if (r < 0)
                 return r;
 
-        r = sd_bus_message_enter_container(message, 'a', "(sv)");
-        if (r < 0)
-                return r;
-
         r = bus_unit_set_properties(u, message, runtime ? UNIT_RUNTIME : UNIT_PERSISTENT, true, error);
         if (r < 0)
                 return r;
 
-        r = sd_bus_message_exit_container(message);
-        if (r < 0)
-                return r;
-
         return sd_bus_reply_method_return(message, NULL);
 }
 
@@ -518,6 +514,7 @@ const sd_bus_vtable bus_unit_vtable[] = {
         SD_BUS_PROPERTY("TriggeredBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_TRIGGERED_BY]), 0),
         SD_BUS_PROPERTY("PropagatesReloadTo", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_PROPAGATES_RELOAD_TO]), 0),
         SD_BUS_PROPERTY("ReloadPropagatedFrom", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_RELOAD_PROPAGATED_FROM]), 0),
+        SD_BUS_PROPERTY("JoinsNamespaceOf", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_JOINS_NAMESPACE_OF]), 0),
         SD_BUS_PROPERTY("RequiresMountsFor", "as", NULL, offsetof(Unit, requires_mounts_for), 0),
         SD_BUS_PROPERTY("Documentation", "as", NULL, offsetof(Unit, documentation), 0),
         SD_BUS_PROPERTY("Description", "s", property_get_description, 0, 0),
@@ -542,7 +539,7 @@ const sd_bus_vtable bus_unit_vtable[] = {
         SD_BUS_PROPERTY("RefuseManualStop", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_stop), 0),
         SD_BUS_PROPERTY("AllowIsolate", "b", bus_property_get_bool, offsetof(Unit, allow_isolate), 0),
         SD_BUS_PROPERTY("DefaultDependencies", "b", bus_property_get_bool, offsetof(Unit, default_dependencies), 0),
-        SD_BUS_PROPERTY("OnFailureIsolate", "b", bus_property_get_bool, offsetof(Unit, on_failure_isolate), 0),
+        SD_BUS_PROPERTY("OnFailureJobMode", "s", property_get_job_mode, offsetof(Unit, on_failure_job_mode), 0),
         SD_BUS_PROPERTY("IgnoreOnIsolate", "b", bus_property_get_bool, offsetof(Unit, ignore_on_isolate), 0),
         SD_BUS_PROPERTY("IgnoreOnSnapshot", "b", bus_property_get_bool, offsetof(Unit, ignore_on_snapshot), 0),
         SD_BUS_PROPERTY("NeedDaemonReload", "b", property_get_need_daemon_reload, 0, 0),
@@ -664,7 +661,6 @@ static int send_changed_signal(sd_bus *bus, const char *destination, void *userd
 
 void bus_unit_send_change_signal(Unit *u) {
         int r;
-
         assert(u);
 
         if (u->in_dbus_queue) {
@@ -677,7 +673,7 @@ void bus_unit_send_change_signal(Unit *u) {
 
         r = bus_manager_foreach_client(u->manager, u->sent_dbus_new_signal ? send_changed_signal : send_new_signal, u);
         if (r < 0)
-                log_warning("Failed to send unit change signal for %s: %s", u->id, strerror(-r));
+                log_debug("Failed to send unit change signal for %s: %s", u->id, strerror(-r));
 
         u->sent_dbus_new_signal = true;
 }
@@ -713,7 +709,6 @@ static int send_removed_signal(sd_bus *bus, const char *destination, void *userd
 
 void bus_unit_send_removed_signal(Unit *u) {
         int r;
-
         assert(u);
 
         if (!u->sent_dbus_new_signal)
@@ -724,7 +719,7 @@ void bus_unit_send_removed_signal(Unit *u) {
 
         r = bus_manager_foreach_client(u->manager, send_removed_signal, u);
         if (r < 0)
-                log_warning("Failed to send unit change signal for %s: %s", u->id, strerror(-r));
+                log_debug("Failed to send unit remove signal for %s: %s", u->id, strerror(-r));
 }
 
 int bus_unit_queue_job(
@@ -780,7 +775,7 @@ int bus_unit_queue_job(
 
         path = job_dbus_path(j);
         if (!path)
-                return r;
+                return -ENOMEM;
 
         return sd_bus_reply_method_return(message, "o", path);
 }
@@ -895,6 +890,10 @@ static int bus_unit_set_transient_property(
                 if (r < 0)
                         return r;
 
+                r = sd_bus_message_exit_container(message);
+                if (r < 0)
+                        return r;
+
                 return 1;
         }
 
@@ -941,6 +940,7 @@ int bus_unit_set_properties(
                         r = sd_bus_message_rewind(message, false);
                         if (r < 0)
                                 return r;
+
                         for_real = true;
                         continue;
                 }
@@ -975,6 +975,10 @@ int bus_unit_set_properties(
                 n += for_real;
         }
 
+        r = sd_bus_message_exit_container(message);
+        if (r < 0)
+                return r;
+
         if (commit && n > 0 && UNIT_VTABLE(u)->bus_commit_properties)
                 UNIT_VTABLE(u)->bus_commit_properties(u);