manager: use reboot.target as the default for ctrl-alt-del.target
systemd tries to start ctrl-alt-del.target after receiving a request to reboot in a container (or when ctrl-alt-del is pressed on a real machine). If the alias is missing, this will fail. Let's provide a fallback for this too. I don't think it makes sense to make it configurable: it seems almost everybody is fine with the default mapping. If not, people can always just create the symlink in the filesystem.
This commit is contained in:
@@ -110,6 +110,9 @@
|
||||
#define SPECIAL_SIGPWR_TARGET "sigpwr.target"
|
||||
#define SPECIAL_CTRL_ALT_DEL_TARGET "ctrl-alt-del.target"
|
||||
|
||||
/* The unit to use as fallback if ctrl-alt-del.target (which is usually an alias) cannot be loaded. */
|
||||
#define FALLBACK_CTRL_ALT_DEL_TARGET "reboot.target"
|
||||
|
||||
/* Where we add all our system units, users and machines by default */
|
||||
#define SPECIAL_SYSTEM_SLICE "system.slice"
|
||||
#define SPECIAL_USER_SLICE "user.slice"
|
||||
|
||||
+11
-3
@@ -3220,10 +3220,10 @@ turn_off:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void manager_start_special(Manager *m, const char *name, JobMode mode) {
|
||||
static void manager_start_special_with_fallback(Manager *m, const char *name, const char *fallback, JobMode mode) {
|
||||
Job *job;
|
||||
|
||||
if (manager_add_job_by_name_or_warn(m, JOB_START, name, mode, NULL, &job) < 0)
|
||||
if (manager_add_job_by_name_or_warn_with_fallback(m, JOB_START, name, fallback, mode, /* affected_jobs= */ NULL, &job) < 0)
|
||||
return;
|
||||
|
||||
const char *s = unit_status_string(job->unit, NULL);
|
||||
@@ -3235,6 +3235,10 @@ static void manager_start_special(Manager *m, const char *name, JobMode mode) {
|
||||
m->status_ready = false;
|
||||
}
|
||||
|
||||
static void manager_start_special(Manager *m, const char *name, JobMode mode) {
|
||||
manager_start_special_with_fallback(m, name, /* fallback= */ NULL, mode);
|
||||
}
|
||||
|
||||
static void manager_handle_ctrl_alt_del(Manager *m) {
|
||||
assert(m);
|
||||
|
||||
@@ -3242,7 +3246,11 @@ static void manager_handle_ctrl_alt_del(Manager *m) {
|
||||
* unless it was disabled in system.conf. */
|
||||
|
||||
if (ratelimit_below(&m->ctrl_alt_del_ratelimit) || m->cad_burst_action == EMERGENCY_ACTION_NONE)
|
||||
manager_start_special(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE_IRREVERSIBLY);
|
||||
manager_start_special_with_fallback(
|
||||
m,
|
||||
SPECIAL_CTRL_ALT_DEL_TARGET,
|
||||
FALLBACK_CTRL_ALT_DEL_TARGET,
|
||||
JOB_REPLACE_IRREVERSIBLY);
|
||||
else
|
||||
emergency_action(
|
||||
m,
|
||||
|
||||
Reference in New Issue
Block a user