chiark / gitweb /
systemd: do not output status messages once gettys are running
[elogind.git] / src / core / dbus-unit.c
index 4605b2fe07de723e06cbc8a389ac946da6527c2a..ba4d42652ee1c6fab268e0d2e35c89ebe0e0dd88 100644 (file)
@@ -801,13 +801,14 @@ static int bus_unit_set_transient_property(
                         r = unit_set_description(u, description);
                         if (r < 0)
                                 return r;
+
+                        unit_write_drop_in_format(u, mode, name, "[Unit]\nDescription=%s\n", description);
                 }
 
                 return 1;
 
         } else if (streq(name, "Slice") && unit_get_cgroup_context(u)) {
                 const char *s;
-                Unit *slice;
 
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING)
                         return -EINVAL;
@@ -815,9 +816,13 @@ static int bus_unit_set_transient_property(
                 dbus_message_iter_get_basic(i, &s);
 
                 if (isempty(s)) {
-                        if (mode != UNIT_CHECK)
+                        if (mode != UNIT_CHECK) {
                                 unit_ref_unset(&u->slice);
+                                unit_remove_drop_in(u, mode, name);
+                        }
                 } else {
+                        Unit *slice;
+
                         r = manager_load_unit(u->manager, s, NULL, error, &slice);
                         if (r < 0)
                                 return r;
@@ -825,9 +830,65 @@ static int bus_unit_set_transient_property(
                         if (slice->type != UNIT_SLICE)
                                 return -EINVAL;
 
-                        if (mode != UNIT_CHECK)
+                        if (mode != UNIT_CHECK) {
                                 unit_ref_set(&u->slice, slice);
+                                unit_write_drop_in_private_format(u, mode, name, "Slice=%s\n", s);
+                        }
+                }
+
+                return 1;
+
+        } else if (streq(name, "Requires") ||
+                   streq(name, "RequiresOverridable") ||
+                   streq(name, "Requisite") ||
+                   streq(name, "RequisiteOverridable") ||
+                   streq(name, "Wants") ||
+                   streq(name, "BindsTo") ||
+                   streq(name, "Conflicts") ||
+                   streq(name, "Before") ||
+                   streq(name, "After") ||
+                   streq(name, "OnFailure") ||
+                   streq(name, "PropagatesReloadTo") ||
+                   streq(name, "ReloadPropagatedFrom") ||
+                   streq(name, "PartOf")) {
+
+                UnitDependency d;
+                DBusMessageIter sub;
+
+                d = unit_dependency_from_string(name);
+                if (d < 0)
+                        return -EINVAL;
+
+                if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_ARRAY ||
+                    dbus_message_iter_get_element_type(i) != DBUS_TYPE_STRING)
+                        return -EINVAL;
+
+                dbus_message_iter_recurse(i, &sub);
+                while (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) {
+                        const char *other;
+
+                        dbus_message_iter_get_basic(&sub, &other);
+
+                        if (!unit_name_is_valid(other, false))
+                                return -EINVAL;
+
+                        if (mode != UNIT_CHECK) {
+                                _cleanup_free_ char *label = NULL;
+
+                                r = unit_add_dependency_by_name(u, d, other, NULL, true);
+                                if (r < 0)
+                                        return r;
+
+                                label = strjoin(name, "-", other, NULL);
+                                if (!label)
+                                        return -ENOMEM;
+
+                                unit_write_drop_in_format(u, mode, label, "[Unit]\n%s=%s\n", name, other);
+                        }
+
+                        dbus_message_iter_next(&sub);
                 }
+
                 return 1;
         }
 
@@ -976,10 +1037,11 @@ const BusProperty bus_unit_properties[] = {
         { "ConditionResult",      bus_property_append_bool,           "b", offsetof(Unit, condition_result)                   },
         { "LoadError",            bus_unit_append_load_error,      "(ss)", 0 },
         { "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 },
+        {}
 };