From 36b69c31312007f522a2a7ae5087ae90bd7867cc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 2 Oct 2017 16:03:55 +0200 Subject: [PATCH 1/6] logind: add Halt() and CanHalt() APIs This adds new method calls Halt() and CanHalt() to the logind bus APIs. They aren't overly useful (as the whole concept of halting isn't really too useful), however they clean up one major asymmetry: currently, using the "shutdown" legacy commands it is possibly to enqueue a "halt" operation through logind, while logind officially doesn't actually support this. Moreover, the path through "shutdown" currently ultimately fails, since the referenced "halt" action isn't actually defined in PolicyKit. Finally, the current logic results in an unexpected asymmetry in systemctl: "systemctl poweroff", "systemctl reboot" are currently asynchronous (due to the logind involvement) while "systemctl halt" isnt. Let's clean this up, and make all three APIs implemented by logind natively, and all three hence asynchronous in "systemctl". Moreover, let's add the missing PK action. Fixes: #6957 --- src/login/logind-dbus.c | 59 +++++++++++++++++----- src/login/org.freedesktop.login1.conf | 8 +++ src/login/org.freedesktop.login1.policy.in | 33 ++++++++++++ src/systemctl/systemctl.c | 14 +++-- 4 files changed, 98 insertions(+), 16 deletions(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 1aa6760665..b346ab5278 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1409,12 +1409,12 @@ static int bus_manager_log_shutdown( if (streq(unit_name, SPECIAL_POWEROFF_TARGET)) { p = "MESSAGE=System is powering down"; q = "SHUTDOWN=power-off"; - } else if (streq(unit_name, SPECIAL_HALT_TARGET)) { - p = "MESSAGE=System is halting"; - q = "SHUTDOWN=halt"; } else if (streq(unit_name, SPECIAL_REBOOT_TARGET)) { p = "MESSAGE=System is rebooting"; q = "SHUTDOWN=reboot"; + } else if (streq(unit_name, SPECIAL_HALT_TARGET)) { + p = "MESSAGE=System is halting"; + q = "SHUTDOWN=halt"; } else if (streq(unit_name, SPECIAL_KEXEC_TARGET)) { p = "MESSAGE=System is rebooting with kexec"; q = "SHUTDOWN=kexec"; @@ -1822,6 +1822,20 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error * error); } +static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + + return method_do_shutdown_or_sleep( + m, message, + SPECIAL_HALT_TARGET, + INHIBIT_SHUTDOWN, + "org.freedesktop.login1.halt", + "org.freedesktop.login1.halt-multiple-sessions", + "org.freedesktop.login1.halt-ignore-inhibit", + NULL, + error); +} + static int method_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; @@ -1911,9 +1925,12 @@ fail: } static void reset_scheduled_shutdown(Manager *m) { + assert(m); + m->scheduled_shutdown_timeout_source = sd_event_source_unref(m->scheduled_shutdown_timeout_source); m->wall_message_timeout_source = sd_event_source_unref(m->wall_message_timeout_source); m->nologin_timeout_source = sd_event_source_unref(m->nologin_timeout_source); + m->scheduled_shutdown_type = mfree(m->scheduled_shutdown_type); m->scheduled_shutdown_timeout = 0; m->shutdown_dry_run = false; @@ -1922,6 +1939,7 @@ static void reset_scheduled_shutdown(Manager *m) { (void) unlink("/run/nologin"); m->unlink_nologin = false; } + (void) unlink("/run/systemd/shutdown/scheduled"); } @@ -1940,12 +1958,14 @@ static int manager_scheduled_shutdown_handler( if (isempty(m->scheduled_shutdown_type)) return 0; - if (streq(m->scheduled_shutdown_type, "halt")) - target = SPECIAL_HALT_TARGET; - else if (streq(m->scheduled_shutdown_type, "poweroff")) + if (streq(m->scheduled_shutdown_type, "poweroff")) target = SPECIAL_POWEROFF_TARGET; - else + else if (streq(m->scheduled_shutdown_type, "reboot")) target = SPECIAL_REBOOT_TARGET; + else if (streq(m->scheduled_shutdown_type, "halt")) + target = SPECIAL_HALT_TARGET; + else + assert_not_reached("unexpected shutdown type"); /* Don't allow multiple jobs being executed at the same time */ if (m->action_what) { @@ -2002,7 +2022,11 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_ m->shutdown_dry_run = true; } - if (streq(type, "reboot")) { + if (streq(type, "poweroff")) { + action = "org.freedesktop.login1.power-off"; + action_multiple_sessions = "org.freedesktop.login1.power-off-multiple-sessions"; + action_ignore_inhibit = "org.freedesktop.login1.power-off-ignore-inhibit"; + } else if (streq(type, "reboot")) { action = "org.freedesktop.login1.reboot"; action_multiple_sessions = "org.freedesktop.login1.reboot-multiple-sessions"; action_ignore_inhibit = "org.freedesktop.login1.reboot-ignore-inhibit"; @@ -2010,10 +2034,6 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_ action = "org.freedesktop.login1.halt"; action_multiple_sessions = "org.freedesktop.login1.halt-multiple-sessions"; action_ignore_inhibit = "org.freedesktop.login1.halt-ignore-inhibit"; - } else if (streq(type, "poweroff")) { - action = "org.freedesktop.login1.power-off"; - action_multiple_sessions = "org.freedesktop.login1.power-off-multiple-sessions"; - action_ignore_inhibit = "org.freedesktop.login1.power-off-ignore-inhibit"; } else return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unsupported shutdown type"); @@ -2260,6 +2280,19 @@ static int method_can_reboot(sd_bus_message *message, void *userdata, sd_bus_err error); } +static int method_can_halt(sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + + return method_can_shutdown_or_sleep( + m, message, + INHIBIT_SHUTDOWN, + "org.freedesktop.login1.halt", + "org.freedesktop.login1.halt-multiple-sessions", + "org.freedesktop.login1.halt-ignore-inhibit", + NULL, + error); +} + static int method_can_suspend(sd_bus_message *message, void *userdata, sd_bus_error *error) { Manager *m = userdata; @@ -2612,11 +2645,13 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("FlushDevices", "b", NULL, method_flush_devices, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("PowerOff", "b", NULL, method_poweroff, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Reboot", "b", NULL, method_reboot, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("Halt", "b", NULL, method_halt, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Suspend", "b", NULL, method_suspend, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Hibernate", "b", NULL, method_hibernate, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("HybridSleep", "b", NULL, method_hybrid_sleep, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CanPowerOff", NULL, "s", method_can_poweroff, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CanReboot", NULL, "s", method_can_reboot, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("CanHalt", NULL, "s", method_can_halt, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CanSuspend", NULL, "s", method_can_suspend, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CanHibernate", NULL, "s", method_can_hibernate, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CanHybridSleep", NULL, "s", method_can_hybrid_sleep, SD_BUS_VTABLE_UNPRIVILEGED), diff --git a/src/login/org.freedesktop.login1.conf b/src/login/org.freedesktop.login1.conf index c89e40457e..27aac0dd7c 100644 --- a/src/login/org.freedesktop.login1.conf +++ b/src/login/org.freedesktop.login1.conf @@ -132,6 +132,10 @@ send_interface="org.freedesktop.login1.Manager" send_member="Reboot"/> + + @@ -152,6 +156,10 @@ send_interface="org.freedesktop.login1.Manager" send_member="CanReboot"/> + + diff --git a/src/login/org.freedesktop.login1.policy.in b/src/login/org.freedesktop.login1.policy.in index 66cbce393c..3e8a9bbe3f 100644 --- a/src/login/org.freedesktop.login1.policy.in +++ b/src/login/org.freedesktop.login1.policy.in @@ -218,6 +218,39 @@ org.freedesktop.login1.reboot + + <_description>Halt the system + <_message>Authentication is required for halting the system. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + org.freedesktop.login1.set-wall-message + + + + <_description>Halt the system while other users are logged in + <_message>Authentication is required for halting the system while other users are logged in. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + org.freedesktop.login1.halt + + + + <_description>Halt the system while an application asked to inhibit it + <_message>Authentication is required for halting the system while an application asked to inhibit it. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + org.freedesktop.login1.halt + + <_description>Suspend the system <_message>Authentication is required for suspending the system. diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 280d786daa..2a385bf350 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -3267,14 +3267,19 @@ static int logind_reboot(enum action a) { switch (a) { + case ACTION_POWEROFF: + method = "PowerOff"; + description = "power off system"; + break; + case ACTION_REBOOT: method = "Reboot"; description = "reboot system"; break; - case ACTION_POWEROFF: - method = "PowerOff"; - description = "power off system"; + case ACTION_HALT: + method = "Halt"; + description = "halt system"; break; case ACTION_SUSPEND: @@ -3568,6 +3573,7 @@ static int start_special(int argc, char *argv[], void *userdata) { if (IN_SET(a, ACTION_POWEROFF, ACTION_REBOOT, + ACTION_HALT, ACTION_SUSPEND, ACTION_HIBERNATE, ACTION_HYBRID_SLEEP)) { @@ -8503,7 +8509,7 @@ static int halt_main(void) { /* Try logind if we are a normal user and no special * mode applies. Maybe PolicyKit allows us to shutdown * the machine. */ - if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT)) { + if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT, ACTION_HALT)) { r = logind_reboot(arg_action); if (r >= 0) return r; From 130246d2e8d7a0c91dbaa1110fa7a6d6e6f86a50 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Sep 2017 16:07:11 +0200 Subject: [PATCH 2/6] systemctl: make sure "reboot", "suspend" and friends are always asynchronous Currently, "systemctl reboot" behaves differently in setups with and without logind. If logind is used (which is probably the more common case) the operation is asynchronous, and otherwise synchronous (though subject to --no-block in this case). Let's clean this up, and always expose the same behaviour, regardless if logind is used or not: let's always make it asynchronous. It might make sense to add a "--block" mode in a future PR that makes these operations synchronous, but this requires non-trivial work in logind, and is outside of the scope of this change. See: #6479 --- src/systemctl/systemctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 2a385bf350..dd0ebff179 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -3585,8 +3585,16 @@ static int start_special(int argc, char *argv[], void *userdata) { /* requested operation is not supported or already in progress */ return r; - /* On all other errors, try low-level operation */ - } + /* On all other errors, try low-level operation. In order to minimize the difference between + * operation with and without logind, we explicitly enable non-blocking mode for this, as + * logind's shutdown operations are always non-blocking. */ + + arg_no_block = true; + + } else if (IN_SET(a, ACTION_EXIT, ACTION_KEXEC)) + /* Since exit/kexec are so close in behaviour to power-off/reboot, let's also make them + * asynchronous, in order to not confuse the user needlessly with unexpected behaviour. */ + arg_no_block = true; r = start_unit(argc, argv, userdata); } From 15e99a4392730593f2b3c3513306ae7ed1fdb94e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 2 Oct 2017 16:08:49 +0200 Subject: [PATCH 3/6] logind: reorder things a bit Let's keep the three sleep method implementations close to each other. --- src/login/logind-dbus.c | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b346ab5278..61029580e2 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1850,6 +1850,34 @@ static int method_suspend(sd_bus_message *message, void *userdata, sd_bus_error error); } +static int method_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + + return method_do_shutdown_or_sleep( + m, message, + SPECIAL_HIBERNATE_TARGET, + INHIBIT_SLEEP, + "org.freedesktop.login1.hibernate", + "org.freedesktop.login1.hibernate-multiple-sessions", + "org.freedesktop.login1.hibernate-ignore-inhibit", + "hibernate", + error); +} + +static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) { + Manager *m = userdata; + + return method_do_shutdown_or_sleep( + m, message, + SPECIAL_HYBRID_SLEEP_TARGET, + INHIBIT_SLEEP, + "org.freedesktop.login1.hibernate", + "org.freedesktop.login1.hibernate-multiple-sessions", + "org.freedesktop.login1.hibernate-ignore-inhibit", + "hybrid-sleep", + error); +} + static int nologin_timeout_handler( sd_event_source *s, uint64_t usec, @@ -2134,34 +2162,6 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd return sd_bus_reply_method_return(message, "b", cancelled); } -static int method_hibernate(sd_bus_message *message, void *userdata, sd_bus_error *error) { - Manager *m = userdata; - - return method_do_shutdown_or_sleep( - m, message, - SPECIAL_HIBERNATE_TARGET, - INHIBIT_SLEEP, - "org.freedesktop.login1.hibernate", - "org.freedesktop.login1.hibernate-multiple-sessions", - "org.freedesktop.login1.hibernate-ignore-inhibit", - "hibernate", - error); -} - -static int method_hybrid_sleep(sd_bus_message *message, void *userdata, sd_bus_error *error) { - Manager *m = userdata; - - return method_do_shutdown_or_sleep( - m, message, - SPECIAL_HYBRID_SLEEP_TARGET, - INHIBIT_SLEEP, - "org.freedesktop.login1.hibernate", - "org.freedesktop.login1.hibernate-multiple-sessions", - "org.freedesktop.login1.hibernate-ignore-inhibit", - "hybrid-sleep", - error); -} - static int method_can_shutdown_or_sleep( Manager *m, sd_bus_message *message, From d13f5e164e3c2352d96dccc2ced4ca3af62cc9f1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 2 Oct 2017 16:09:24 +0200 Subject: [PATCH 4/6] logind: don's change dry-run boolean before we actually enqueue the operation Let's not affect change before the PK check. --- src/login/logind-dbus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 61029580e2..c6f184e080 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2037,6 +2037,7 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_ uint64_t elapse; char *type; int r; + bool dry_run = false; assert(m); assert(message); @@ -2047,7 +2048,7 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_ if (startswith(type, "dry-")) { type += 4; - m->shutdown_dry_run = true; + dry_run = true; } if (streq(type, "poweroff")) { @@ -2091,6 +2092,8 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_ return log_oom(); } + m->shutdown_dry_run = dry_run; + if (m->nologin_timeout_source) { r = sd_event_source_set_time(m->nologin_timeout_source, elapse); if (r < 0) From 6324a8a7271461efb73dc4fe50ad1ebef82e2405 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Sep 2017 16:10:27 +0200 Subject: [PATCH 5/6] man: document which special "systemctl" commands are synchronous and which asynchronous. This documents the status quo, clarifying when we are synchronous and when asynchronous by default and when --no-block is support to force asynchronous operation. See: #6479 --- man/systemctl.xml | 142 +++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index f514ab64dd..4abee60790 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -407,8 +407,7 @@ - Do not send wall message before halt, power-off, - reboot. + Do not send wall message before halt, power-off and reboot. @@ -525,7 +524,7 @@ twice with any of these operations might result in data loss. Note that when is specified twice the selected operation is executed by systemctl itself, and the system manager is not contacted. This means the command should - succeed even when the system manager hangs or crashed. + succeed even when the system manager has crashed. @@ -533,11 +532,9 @@ - When used with halt, - poweroff, reboot or - kexec, set a short message explaining the reason - for the operation. The message will be logged together with the - default shutdown message. + When used with halt, poweroff or reboot, set a + short message explaining the reason for the operation. The message will be logged together with the default + shutdown message. @@ -1690,8 +1687,8 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err default - Enter default mode. This is mostly equivalent to - isolate default.target. + Enter default mode. This is equivalent to systemctl isolate default.target. This + operation is blocking by default, use to request asynchronous behavior. @@ -1699,72 +1696,77 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err rescue - Enter rescue mode. This is mostly equivalent to - isolate rescue.target, but also prints a - wall message to all users. + Enter rescue mode. This is equivalent to systemctl isolate rescue.target. This + operation is blocking by default, use to request asynchronous behavior. emergency - Enter emergency mode. This is mostly equivalent to - isolate emergency.target, but also prints - a wall message to all users. + Enter emergency mode. This is equivalent to systemctl isolate + emergency.target. This operation is blocking by default, use to + request asynchronous behavior. halt - Shut down and halt the system. This is mostly equivalent to start halt.target - --job-mode=replace-irreversibly, but also prints a wall message to all users. If combined with - , shutdown of all running services is skipped, however all processes are killed and - all file systems are unmounted or mounted read-only, immediately followed by the system halt. If - is specified twice, the operation is immediately executed without terminating any - processes or unmounting any file systems. This may result in data loss. Note that when - is specified twice the halt operation is executed by - systemctl itself, and the system manager is not contacted. This means the command should - succeed even when the system manager hangs or crashed. + Shut down and halt the system. This is mostly equivalent to systemctl start halt.target + --job-mode=replace-irreversibly --no-block, but also prints a wall message to all users. This command is + asynchronous; it will return after the halt operation is enqueued, without waiting for it to complete. Note + that this operation will simply halt the OS kernel after shutting down, leaving the hardware powered + on. Use systemctl poweroff for powering off the system (see below). + + If combined with , shutdown of all running services is skipped, however all + processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the + system halt. If is specified twice, the operation is immediately executed without + terminating any processes or unmounting any file systems. This may result in data loss. Note that when + is specified twice the halt operation is executed by systemctl + itself, and the system manager is not contacted. This means the command should succeed even when the system + manager has crashed. poweroff - Shut down and power-off the system. This is mostly equivalent to start poweroff.target - --job-mode=replace-irreversibly, but also prints a wall message to all users. If combined with - , shutdown of all running services is skipped, however all processes are killed and - all file systems are unmounted or mounted read-only, immediately followed by the powering off. If - is specified twice, the operation is immediately executed without terminating any - processes or unmounting any file systems. This may result in data loss. Note that when + Shut down and power-off the system. This is mostly equivalent to systemctl start + poweroff.target --job-mode=replace-irreversibly --no-block, but also prints a wall message to all + users. This command is asynchronous; it will return after the power-off operation is enqueued, without + waiting for it to complete. + + If combined with , shutdown of all running services is skipped, however all + processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the + powering off. If is specified twice, the operation is immediately executed without + terminating any processes or unmounting any file systems. This may result in data loss. Note that when is specified twice the power-off operation is executed by systemctl itself, and the system manager is not contacted. This means the command should - succeed even when the system manager hangs or crashed. + succeed even when the system manager has crashed. reboot arg - Shut down and reboot the system. This is mostly equivalent to start reboot.target - --job-mode=replace-irreversibly, but also prints a wall message to all users. If combined with - , shutdown of all running services is skipped, however all processes are killed and - all file systems are unmounted or mounted read-only, immediately followed by the reboot. If - is specified twice, the operation is immediately executed without terminating any - processes or unmounting any file systems. This may result in data loss. Note that when + Shut down and reboot the system. This is mostly equivalent to systemctl start reboot.target + --job-mode=replace-irreversibly --no-block, but also prints a wall message to all users. This + command is asynchronous; it will return after the reboot operation is enqueued, without waiting for it to + complete. + + If combined with , shutdown of all running services is skipped, however all + processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the + reboot. If is specified twice, the operation is immediately executed without + terminating any processes or unmounting any file systems. This may result in data loss. Note that when is specified twice the reboot operation is executed by systemctl itself, and the system manager is not contacted. This means the command should - succeed even when the system manager hangs or crashed. + succeed even when the system manager has crashed. - If the optional argument - arg is given, it will be passed - as the optional argument to the - reboot2 - system call. The value is architecture and firmware - specific. As an example, recovery might - be used to trigger system recovery, and - fota might be used to trigger a + If the optional argument arg is given, it will be passed as the optional + argument to the reboot2 + system call. The value is architecture and firmware specific. As an example, recovery + might be used to trigger system recovery, and fota might be used to trigger a firmware over the air update. @@ -1773,13 +1775,14 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err kexec - Shut down and reboot the system via kexec. This is - mostly equivalent to start kexec.target --job-mode=replace-irreversibly, - but also prints a wall message to all users. If combined - with , shutdown of all running - services is skipped, however all processes are killed and - all file systems are unmounted or mounted read-only, - immediately followed by the reboot. + Shut down and reboot the system via kexec. This is equivalent to + systemctl start kexec.target --job-mode=replace-irreversibly --no-block. This command is + asynchronous; it will return after the reboot operation is enqueued, without waiting for it to + complete. + + If combined with , shutdown of all running services is skipped, however all + processes are killed and all file systems are unmounted or mounted read-only, immediately followed by the + reboot. @@ -1787,14 +1790,13 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err exit EXIT_CODE - Ask the systemd manager to quit. This is only - supported for user service managers (i.e. in conjunction - with the option) or in containers - and is equivalent to poweroff otherwise. + Ask the service manager to quit. This is only supported for user service managers (i.e. in + conjunction with the option) or in containers and is equivalent to + poweroff otherwise. This command is asynchronous; it will return after the exit + operation is enqueued, without waiting for it to complete. - The systemd manager can exit with a non-zero exit - code if the optional argument - EXIT_CODE is given. + The service manager will exit with the the specified exit code, if + EXIT_CODE is passed. @@ -1818,9 +1820,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err suspend - Suspend the system. This will trigger activation of - the special suspend.target target. - + Suspend the system. This will trigger activation of the special target unit + suspend.target. This command is asynchronous, and will return after the suspend + operation is successfully enqueued. It will not wait for the suspend/resume cycle to complete. @@ -1828,9 +1830,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err hibernate - Hibernate the system. This will trigger activation of - the special hibernate.target target. - + Hibernate the system. This will trigger activation of the special target unit + hibernate.target. This command is asynchronous, and will return after the hibernation + operation is successfully enqueued. It will not wait for the hibernate/thaw cycle to complete. @@ -1838,9 +1840,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err hybrid-sleep - Hibernate and suspend the system. This will trigger - activation of the special - hybrid-sleep.target target. + Hibernate and suspend the system. This will trigger activation of the special target unit + hybrid-sleep.target. This command is asynchronous, and will return after the hybrid + sleep operation is successfully enqueued. It will not wait for the sleep/wake-up cycle to complete. From e06fafb2d7e7155b1333ee59de5768c8ea0772e8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 2 Oct 2017 16:30:01 +0200 Subject: [PATCH 6/6] NEWS: add comment about change sync/async behaviour for shutdown commands --- NEWS | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index e639f4878f..8f43c59e72 100644 --- a/NEWS +++ b/NEWS @@ -190,6 +190,20 @@ CHANGES WITH 235: used to control how the kernel keyring is set up for executed processes. + * "systemctl poweroff", "systemctl reboot", "systemctl halt", + "systemctl kexec" and "systemctl exit" are now always asynchronous in + behaviour (that is: these commands return immediately after the + operation was enqueued instead of waiting until the operation was + completed). Previously, "systemctl poweroff" and "systemctl reboot" + were asynchronous on systems using systemd-logind (i.e. almost + always, and like they were on sysvinit), and the other three commands + were unconditionally synchronous. With this release this is cleaned + up, and callers will see the same asynchronous behaviour on all + systems for all five operations. + + * systemd-logind gained new Halt() and CanHalt() bus calls for halting + the system. + * .timer units now accept calendar specifications in other timezones than UTC or the local timezone. @@ -213,7 +227,7 @@ CHANGES WITH 235: userwithuid, Vito Caputo, vliaskov, WaLyong Cho, William Douglas, Xiang Fan, Yu Watanabe, Zbigniew Jędrzejewski-Szmek - — Berlin, 2017-09-XX + — Berlin, 2017-10-XX CHANGES WITH 234: