]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Make sure systemctl exit <X> works outside of a container
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 11 May 2023 06:47:38 +0000 (08:47 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 May 2023 05:48:29 +0000 (07:48 +0200)
When running in a VM, we now support propagating the exit status
via a vsock notify socket, so drop the restrictions on propagating
an exit status when not in a container to make sure this works
properly.

src/core/dbus-manager.c
src/core/main.c

index fb608cd295b33f3c5dcdcc329bd0eff02e86a159..b18aa1d4ff2c61f4f5a2020cb8a5dfe7fe67354a 100644 (file)
@@ -1943,9 +1943,6 @@ static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_
         if (r < 0)
                 return r;
 
-        if (MANAGER_IS_SYSTEM(m) && detect_container() <= 0)
-                return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "ExitCode can only be set for user service managers or in containers.");
-
         m->return_value = code;
 
         return sd_bus_reply_method_return(message, NULL);
index 5274bcc106fb8e3a98db176b3e8a354cc9929de8..e86e0d941ec82048fb3f36853c79471426fc883c 100644 (file)
@@ -1515,10 +1515,8 @@ static int become_shutdown(int objective, int retval) {
         if (log_get_show_time())
                 command_line[pos++] = "--log-time";
 
-        if (objective == MANAGER_EXIT) {
-                xsprintf(exit_code, "--exit-code=%d", retval);
-                command_line[pos++] = exit_code;
-        }
+        xsprintf(exit_code, "--exit-code=%d", retval);
+        command_line[pos++] = exit_code;
 
         assert(pos < ELEMENTSOF(command_line));