chiark / gitweb /
core: actually make SwitchRoot() bus call do the deed
[elogind.git] / src / core / dbus-manager.c
index d7936fff2047c3b46f1084620ed903664575886c..c560cac18fa47a6b3bac6f16de96e878ce256773 100644 (file)
@@ -547,11 +547,11 @@ static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, voi
         if (mode < 0)
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s is invalid.", smode);
 
-        r = manager_load_unit(m, name, NULL, error, &u);
+        r = selinux_access_check(bus, message, "start", error);
         if (r < 0)
                 return r;
 
-        r = selinux_unit_access_check(u, bus, message, "start", error);
+        r = manager_load_unit(m, name, NULL, error, &u);
         if (r < 0)
                 return r;
 
@@ -774,8 +774,9 @@ static int method_list_jobs(sd_bus *bus, sd_bus_message *message, void *userdata
                 r = sd_bus_message_append(
                                 reply, "(usssoo)",
                                 j->id,
-                                job_state_to_string(j->state),
+                                j->unit->id,
                                 job_type_to_string(j->type),
+                                job_state_to_string(j->state),
                                 job_path,
                                 unit_path);
                 if (r < 0)
@@ -1120,7 +1121,7 @@ static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userda
         if (!isempty(init)) {
                 ri = strdup(init);
                 if (!ri) {
-                        free(ri);
+                        free(rt);
                         return -ENOMEM;
                 }
         }
@@ -1131,6 +1132,8 @@ static int method_switch_root(sd_bus *bus, sd_bus_message *message, void *userda
         free(m->switch_root_init);
         m->switch_root_init = ri;
 
+        m->exit_code = MANAGER_SWITCH_ROOT;
+
         return sd_bus_reply_method_return(message, NULL);
 }
 
@@ -1367,7 +1370,7 @@ static int reply_unit_file_changes_and_free(
 
         for (i = 0; i < n_changes; i++) {
                 r = sd_bus_message_append(
-                                message, "(sss)",
+                                reply, "(sss)",
                                 unit_file_change_type_to_string(changes[i].type),
                                 changes[i].path,
                                 changes[i].source);
@@ -1379,7 +1382,7 @@ static int reply_unit_file_changes_and_free(
         if (r < 0)
                 goto fail;
 
-        return sd_bus_send(bus, message, NULL);
+        return sd_bus_send(bus, reply, NULL);
 
 fail:
         unit_file_changes_free(changes, n_changes);