summaryrefslogtreecommitdiff
path: root/src/core/emergency-action.c
Commit message (Collapse)AuthorAgeFilesLines
* basic: add RuntimeScope enumLennart Poettering2023-03-101-2/+2
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* feature to honor first shutdown request to completionJay Burger2020-06-241-11/+24
| | | | | | Create unit tests per established norm at position 52 check in_set first before getting unit
* core: add new API for enqueing a job with returning the transaction dataLennart Poettering2019-03-271-4/+3
|
* systemctl: restore "systemctl reboot ARG" functionalityVesa Jääskeläinen2019-03-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | Commit d85515edcf9700dc068201ab9f7103f04f3b25b2 changed logic how reboot is executed. That commit changed behavior to use emergency action reboot code path to perform the reboot. This inadvertently broke rebooting with argument: $ systemctl reboot custom-reason Restore original behavior so that if reboot service unit similar to systemd-reboot.service is executed it is possible to override reboot reason with "systemctl reboot ARG". When "systemctl reboot ARG" is executed ARG is placed in file /run/systemd/reboot-param and reboot is issued using logind's Reboot dbus-service. If RebootArgument is specified in systemd-reboot.service it takes precedence over what systemctl sets. Fixes: #11828
* core: change emergency_action() to return voidLennart Poettering2019-03-181-5/+3
| | | | | | | | | | | | | | The function so far always returned -ECANCELLED, which is ignored in all cases the function is invoked, except one: in unit_test_start_limit() where -ECANCELLED is returned when the start limit is hit, which is part of unit_start()'s protocol of return values. Since the emergency_action() logic should be relatively generic and is used in many places, let's drop the return value from it, since it's constant anyway, and in alll cases useless. Instead, let's return it in unit_test_start_limit(), where it's part of the protocol. No change in behaviour.
* core: allow to set exit status when using SuccessAction=/FailureAction=exit ↵Lennart Poettering2018-11-271-0/+9
| | | | | | | | | | | in units This adds SuccessActionExitStatus= and FailureActionExitStatus= that may be used to configure the exit status to propagate in when SuccessAction=exit or FailureAction=exit is used. When not specified let's also propagate the exit status of the main process we fork off for the unit.
* core: do not "warn" about mundane emergency actionsZbigniew Jędrzejewski-Szmek2018-10-171-13/+16
| | | | | | | | | | | | | | For example in a container we'd log: Oct 17 17:01:10 rawhide systemd[1]: Started Power-Off. Oct 17 17:01:10 rawhide systemd[1]: Forcibly powering off: unit succeeded Oct 17 17:01:10 rawhide systemd[1]: Reached target Power-Off. Oct 17 17:01:10 rawhide systemd[1]: Shutting down. and on the console we'd write (in red) [ !! ] Forcibly powering off: unit succeeded This is not useful in any way, and the fact that we're calling an "emergency action" is an internal implementation detail. Let's log about c-a-d and the watchdog actions only.
* units: allow and use SuccessAction=exit-force in system systemd-exit.serviceZbigniew Jędrzejewski-Szmek2018-10-171-11/+16
| | | | | | | | | C.f. 287419c119ef961db487a281162ab037eba70c61: 'systemctl exit 42' can be used to set an exit value and pulls in exit.target, which pulls in systemd-exit.service, which calls org.fdo.Manager.Exit, which calls method_exit(), which sets the objective to MANAGER_EXIT. Allow the same to happen through SuccessAction=exit. v2: update for 'exit' and 'exit-force'
* core: limit service-watchdogs=no to actual "watchdog" commandsZbigniew Jędrzejewski-Szmek2018-10-171-1/+2
| | | | | | | | The setting is now only looked at when considering an action for a job timeout or unit start limit. It is ignored for ctrl-alt-del, SuccessAction, SuccessFailure. v2: turn the parameter into a flag field v3: rename Options to Flags
* core: define "exit" and "exit-force" actions for user units and only accept thatZbigniew Jędrzejewski-Szmek2018-10-171-10/+37
| | | | | | | | | | We would accept e.g. FailureAction=reboot-force in user units and then do an exit in the user manager. Let's be stricter, and define "exit"/"exit-force" as the only supported actions in user units. v2: - rename 'exit' to 'exit-force' and add new 'exit' - add test for the parsing function
* core: rename ManagerExitCode → ManagerObjectiveLennart Poettering2018-10-091-3/+3
| | | | | | | | | | | | | | "ExitCode" is a bit of a misnomer in two ways: it suggests this was about the "exit code" concept that exit()/waitid() deal with, but really isn't. Moreover, it's not event just about exiting either, but more often about reloading/reexecing or rebooting. Let's hence pick a new name for this that is a bit more correct. I initially thought about naming this the "state", but that'd be a misnomer too, as the value really encodes a "goal" more than a current state. Also we already have the externally visible ManagerState. No actual changes in behaviour, just the rename.
* Drop more copyright headersZbigniew Jędrzejewski-Szmek2018-07-241-3/+0
|
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-1/+1
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* basic: split out update_reboot_parameter_and_warn() into its own .c/.h filesLennart Poettering2018-02-221-0/+1
| | | | | | This is primarily preparation for a follow-up commit that adds a common implementation of the other side of the reboot parameter file, i.e. the code that reads the file and issues reboot() for it.
* tree-wide: voidify reboot() invocationsLennart Poettering2018-02-221-2/+2
| | | | | We use (void) in most cases for reboot() already, let's add it to the others as well.
* basic: add a common syscall wrapper around reboot()Lennart Poettering2018-02-221-2/+2
| | | | | | | | | | | | | | | This mimics the raw_clone() call we have in place already and establishes a new syscall wrapper raw_reboot() that wraps the kernel's reboot() system call in a bit more low-level fashion that glibc's reboot() wrapper. The main difference is that the extra "arg" argument is supported. Ultimately this just replaces the syscall wrapper implementation we currently have at three places in our codebase by a single one. With this change this means that all our syscall() invocations are neatly separated out in static inline system call wrappers in our header functions.
* pid1: add option to disable service watchdogsJan Klötzke2018-01-221-0/+5
| | | | | Add a "systemd.service_watchdogs=" option to the command line which disables all service runtime watchdogs and emergency actions.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* core: add missing error_message cases (#6911)Alan Jenkins2017-11-101-1/+1
| | | | | | | | | | | | | | We neglected to set error_message for errors which occur _after_ the `finish` label. These fatal errors only happen in paths where `finish` was reached successfully, i.e. error_message has not already been set (and this analysis is simple enough that this need not cause too much headaches. Also our new assignments to error_message come immediately after execve() calls, which would have lost the error_message if it had been set). Also print a status message when we fail to exec init, otherwise the only sign the user will see is `# ` :). This addresses the lack of error messages pointed out in issue #6827.
* failure-action: generalize failure action to emergency actionLukas Nykryn2016-10-211-0/+128