chiark / gitweb /
machined: sync to /run after job completed
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 13:49:27 +0000 (15:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Jul 2013 13:49:27 +0000 (15:49 +0200)
src/core/dbus-unit.c
src/core/unit.c
src/login/logind-dbus.c
src/machine/machined-dbus.c

index ad6d5a603885694ab13c0f9829438c60167e0fd0..58310463056e1a571a2fc02275794b5ed47e9b02 100644 (file)
@@ -778,16 +778,18 @@ static int bus_unit_set_transient_property(
         assert(i);
 
         if (streq(name, "Description")) {
-                const char *description;
-
                 if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING)
                         return -EINVAL;
 
-                dbus_message_iter_get_basic(i, &description);
+                if (mode != UNIT_CHECK) {
+                        const char *description;
 
-                r = unit_set_description(u, description);
-                if (r < 0)
-                        return r;
+                        dbus_message_iter_get_basic(i, &description);
+
+                        r = unit_set_description(u, description);
+                        if (r < 0)
+                                return r;
+                }
 
                 return 1;
 
@@ -800,14 +802,20 @@ static int bus_unit_set_transient_property(
 
                 dbus_message_iter_get_basic(i, &s);
 
-                r = manager_load_unit(u->manager, s, NULL, error, &slice);
-                if (r < 0)
-                        return r;
+                if (isempty(s)) {
+                        if (mode != UNIT_CHECK)
+                                unit_ref_unset(&u->slice);
+                } else {
+                        r = manager_load_unit(u->manager, s, NULL, error, &slice);
+                        if (r < 0)
+                                return r;
 
-                if (slice->type != UNIT_SLICE)
-                        return -EINVAL;
+                        if (slice->type != UNIT_SLICE)
+                                return -EINVAL;
 
-                unit_ref_set(&u->slice, slice);
+                        if (mode != UNIT_CHECK)
+                                unit_ref_set(&u->slice, slice);
+                }
                 return 1;
         }
 
index 991111ab31facaad6fcf4c8f9e29f7ca41e3986e..acc575b6e0adc1691d4bed568f745a8d18dc8183 100644 (file)
@@ -231,8 +231,13 @@ int unit_set_description(Unit *u, const char *description) {
 
         assert(u);
 
-        if (!(s = strdup(description)))
-                return -ENOMEM;
+        if (isempty(description))
+                s = NULL;
+        else {
+                s = strdup(description);
+                if (!s)
+                        return -ENOMEM;
+        }
 
         free(u->description);
         u->description = s;
index 9a19932af45db541d7144422b301bc9d4771ef89..e61ec7afd5ef1882dd43aa2367388d9677485f01 100644 (file)
@@ -2356,6 +2356,7 @@ DBusHandlerResult bus_message_filter(
                                 if (streq_ptr(path, s->scope_job)) {
                                         free(s->scope_job);
                                         s->scope_job = NULL;
+                                        session_save(s);
 
                                         if (s->started) {
                                                 if (streq(result, "done"))
@@ -2382,6 +2383,7 @@ DBusHandlerResult bus_message_filter(
                                         u->slice_job = NULL;
                                 }
 
+                                user_save(u);
                                 user_add_to_gc_queue(u);
                         }
                 }
index 83a45b63baa0b54eaa379de909bf7d50848a0573..a81f37c5ca249cacf147942c29b3eab712ad2217 100644 (file)
@@ -116,7 +116,7 @@ static bool valid_machine_name(const char *p) {
 
 static int bus_manager_create_machine(Manager *manager, DBusMessage *message) {
 
-        const char *name, *service, *class, *slice, *root_directory;
+        const char *name, *service, *class, *root_directory;
         _cleanup_free_ char *p = NULL;
         DBusMessageIter iter, sub;
         MachineClass c;
@@ -537,6 +537,7 @@ DBusHandlerResult bus_message_filter(
                         if (streq_ptr(path, mm->scope_job)) {
                                 free(mm->scope_job);
                                 mm->scope_job = NULL;
+                                machine_save(mm);
 
                                 if (mm->started) {
                                         if (streq(result, "done"))