From 2bcc330942d526b6004a67c92e284ad842bd5e59 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Sun, 13 Nov 2016 09:32:52 +0100 Subject: core: in confirm_spawn, the meaning of 'n' and 's' choices are confusing Before this patch we had: - "no" which gives "failing execution" but the command is actually assumed as succeed. - "skip" which gives "skipping", but the command is assumed to have failed, which ends up with "Failed to start ..." on the console. Now we have: - "fail" which gives "failing execution" and the command is indeed assumed as failed. - "skip" which gives "skipping execution" and the command is assumed as succeed. --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index b10a6f538f..fbd9afa2cb 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,17 @@ systemd System and Service Manager +CHANGES WITH 233 in spe + + * The confirmation spawn prompt has been reworked to offer the + following choices: + + (f)ail, don't execute the command and pretend it failed + (s)kip, don't execute the command and pretend it succeeded + (y)es, execute the command + + The 'n' choice for the confirmation spawn prompt has been removed, + because its meaning was confusing. + CHANGES WITH 232: * The new RemoveIPC= option can be used to remove IPC objects owned by -- cgit v1.2.3-54-g00ecf From d172b175f6d43d68929975e3baa3837da677bc68 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 7 Nov 2016 17:14:59 +0100 Subject: core: rework the confirmation spawn prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously it was "[Yes, Fail, Skip]" which is pretty misleading because it suggests that the whole word needs to be entered instead of a single char. Also this won't fit well when we'll extend the number of choices. This patch addresses this by changing the choice hint with "[y, f, s – h for help]" so it's now clear that a single letter has to be entered. It also introduces a new choice 'h' which describes all possible choices since a single letter can be not descriptive enough for new users. It also allow to stick with the same hint string regardless of how many choices we will support. --- NEWS | 1 + src/core/execute.c | 47 ++++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index fbd9afa2cb..fde3d6caf6 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ CHANGES WITH 233 in spe following choices: (f)ail, don't execute the command and pretend it failed + (h)elp (s)kip, don't execute the command and pretend it succeeded (y)es, execute the command diff --git a/src/core/execute.c b/src/core/execute.c index 0273b1966f..65ba9acf7a 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -739,27 +739,36 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) { goto restore_stdio; } - r = ask_char(&c, "yfs", "Execute %s? [Yes, Fail, Skip] ", e); - if (r < 0) { - write_confirm_error_fd(r, STDOUT_FILENO); - r = CONFIRM_EXECUTE; - goto restore_stdio; - } + for (;;) { + r = ask_char(&c, "yfsh", "Execute %s? [y, f, s – h for help] ", e); + if (r < 0) { + write_confirm_error_fd(r, STDOUT_FILENO); + r = CONFIRM_EXECUTE; + goto restore_stdio; + } - switch (c) { - case 'f': - printf("Failing execution.\n"); - r = CONFIRM_PRETEND_FAILURE; - break; - case 's': - printf("Skipping execution.\n"); - r = CONFIRM_PRETEND_SUCCESS; - break; - case 'y': - r = CONFIRM_EXECUTE; + switch (c) { + case 'f': + printf("Failing execution.\n"); + r = CONFIRM_PRETEND_FAILURE; + break; + case 'h': + printf(" f - fail, don't execute the command and pretend it failed\n" + " h - help\n" + " s - skip, don't execute the command and pretend it succeeded\n" + " y - yes, execute the command\n"); + continue; + case 's': + printf("Skipping execution.\n"); + r = CONFIRM_PRETEND_SUCCESS; + break; + case 'y': + r = CONFIRM_EXECUTE; + break; + default: + assert_not_reached("Unhandled choice"); + } break; - default: - assert_not_reached("Unhandled choice"); } restore_stdio: -- cgit v1.2.3-54-g00ecf From eedf223a30cca99b5d82f620437d2366be0eaf30 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Sat, 12 Nov 2016 14:55:12 +0100 Subject: core: add 'i' in confirm spawn to give a short summary of the unit to spawn --- NEWS | 1 + src/core/execute.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index fde3d6caf6..a145c3ab6e 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ CHANGES WITH 233 in spe (f)ail, don't execute the command and pretend it failed (h)elp + (i)nfo, show a short summary of the unit (s)kip, don't execute the command and pretend it succeeded (y)es, execute the command diff --git a/src/core/execute.c b/src/core/execute.c index 65ba9acf7a..b48a5732f3 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -720,7 +720,7 @@ enum { CONFIRM_EXECUTE = 1, }; -static int ask_for_confirmation(const char *vc, const char *cmdline) { +static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { int saved_stdout = -1, saved_stdin = -1, r; _cleanup_free_ char *e = NULL; char c; @@ -740,7 +740,7 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) { } for (;;) { - r = ask_char(&c, "yfsh", "Execute %s? [y, f, s – h for help] ", e); + r = ask_char(&c, "yfshi", "Execute %s? [y, f, s – h for help] ", e); if (r < 0) { write_confirm_error_fd(r, STDOUT_FILENO); r = CONFIRM_EXECUTE; @@ -755,9 +755,16 @@ static int ask_for_confirmation(const char *vc, const char *cmdline) { case 'h': printf(" f - fail, don't execute the command and pretend it failed\n" " h - help\n" + " i - info, show a short summary of the unit\n" " s - skip, don't execute the command and pretend it succeeded\n" " y - yes, execute the command\n"); continue; + case 'i': + printf(" Description: %s\n" + " Unit: %s\n" + " Command: %s\n", + u->id, u->description, cmdline); + continue; /* ask again */ case 's': printf("Skipping execution.\n"); r = CONFIRM_PRETEND_SUCCESS; @@ -2368,7 +2375,7 @@ static int exec_child( return -ENOMEM; } - r = ask_for_confirmation(vc, cmdline); + r = ask_for_confirmation(vc, unit, cmdline); if (r != CONFIRM_EXECUTE) { if (r == CONFIRM_PRETEND_SUCCESS) { *exit_status = EXIT_SUCCESS; -- cgit v1.2.3-54-g00ecf From dd6f9ac0d03d073f5dfbf1166f63c6bb64d7ce0c Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Sat, 12 Nov 2016 15:08:29 +0100 Subject: core: add 'D' in confirmat spawn to show a full dump of the unit to spawn --- NEWS | 1 + src/core/execute.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index a145c3ab6e..45d3336b1b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ CHANGES WITH 233 in spe * The confirmation spawn prompt has been reworked to offer the following choices: + (D)ump, show the state of the unit (f)ail, don't execute the command and pretend it failed (h)elp (i)nfo, show a short summary of the unit diff --git a/src/core/execute.c b/src/core/execute.c index b48a5732f3..6c65bdc361 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -740,7 +740,7 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { } for (;;) { - r = ask_char(&c, "yfshi", "Execute %s? [y, f, s – h for help] ", e); + r = ask_char(&c, "yfshiD", "Execute %s? [y, f, s – h for help] ", e); if (r < 0) { write_confirm_error_fd(r, STDOUT_FILENO); r = CONFIRM_EXECUTE; @@ -748,17 +748,21 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { } switch (c) { + case 'D': + unit_dump(u, stdout, " "); + continue; /* ask again */ case 'f': printf("Failing execution.\n"); r = CONFIRM_PRETEND_FAILURE; break; case 'h': - printf(" f - fail, don't execute the command and pretend it failed\n" + printf(" D - dump, show the state of the unit\n" + " f - fail, don't execute the command and pretend it failed\n" " h - help\n" " i - info, show a short summary of the unit\n" " s - skip, don't execute the command and pretend it succeeded\n" " y - yes, execute the command\n"); - continue; + continue; /* ask again */ case 'i': printf(" Description: %s\n" " Unit: %s\n" -- cgit v1.2.3-54-g00ecf From 56fde33af1101bd7d01f1f8b2472d37ab04490c6 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Sun, 13 Nov 2016 16:28:04 +0100 Subject: core: add 'j' in confirmation_spawn to list the jobs that are in progress --- NEWS | 1 + src/core/execute.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 45d3336b1b..5cb1151b6e 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ CHANGES WITH 233 in spe (f)ail, don't execute the command and pretend it failed (h)elp (i)nfo, show a short summary of the unit + (j)obs, show jobs that are in progress (s)kip, don't execute the command and pretend it succeeded (y)es, execute the command diff --git a/src/core/execute.c b/src/core/execute.c index 6c65bdc361..6a7ad66a21 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -740,7 +740,7 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { } for (;;) { - r = ask_char(&c, "yfshiD", "Execute %s? [y, f, s – h for help] ", e); + r = ask_char(&c, "yfshiDj", "Execute %s? [y, f, s – h for help] ", e); if (r < 0) { write_confirm_error_fd(r, STDOUT_FILENO); r = CONFIRM_EXECUTE; @@ -760,6 +760,7 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { " f - fail, don't execute the command and pretend it failed\n" " h - help\n" " i - info, show a short summary of the unit\n" + " j - jobs, show jobs that are in progress\n" " s - skip, don't execute the command and pretend it succeeded\n" " y - yes, execute the command\n"); continue; /* ask again */ @@ -769,6 +770,9 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { " Command: %s\n", u->id, u->description, cmdline); continue; /* ask again */ + case 'j': + manager_dump_jobs(u->manager, stdout, " "); + continue; /* ask again */ case 's': printf("Skipping execution.\n"); r = CONFIRM_PRETEND_SUCCESS; -- cgit v1.2.3-54-g00ecf From b0eb29449e63799f8b6b3440cd865d51b90a5423 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 15 Nov 2016 09:29:04 +0100 Subject: core: add 'c' in confirmation_spawn to resume the boot process --- NEWS | 1 + src/core/execute.c | 18 +++++++++++++++--- src/core/manager.c | 13 ++++++++++++- src/core/manager.h | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 5cb1151b6e..7ca129db80 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ CHANGES WITH 233 in spe * The confirmation spawn prompt has been reworked to offer the following choices: + (c)ontinue, proceed without asking anymore (D)ump, show the state of the unit (f)ail, don't execute the command and pretend it failed (h)elp diff --git a/src/core/execute.c b/src/core/execute.c index 6a7ad66a21..10f73ee9b5 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -732,6 +732,12 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { return CONFIRM_EXECUTE; } + /* confirm_spawn might have been disabled while we were sleeping. */ + if (manager_is_confirm_spawn_disabled(u->manager)) { + r = 1; + goto restore_stdio; + } + e = ellipsize(cmdline, 60, 100); if (!e) { log_oom(); @@ -740,7 +746,7 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { } for (;;) { - r = ask_char(&c, "yfshiDj", "Execute %s? [y, f, s – h for help] ", e); + r = ask_char(&c, "yfshiDjc", "Execute %s? [y, f, s – h for help] ", e); if (r < 0) { write_confirm_error_fd(r, STDOUT_FILENO); r = CONFIRM_EXECUTE; @@ -748,6 +754,11 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { } switch (c) { + case 'c': + printf("Resuming normal execution.\n"); + manager_disable_confirm_spawn(); + r = 1; + break; case 'D': unit_dump(u, stdout, " "); continue; /* ask again */ @@ -756,7 +767,8 @@ static int ask_for_confirmation(const char *vc, Unit *u, const char *cmdline) { r = CONFIRM_PRETEND_FAILURE; break; case 'h': - printf(" D - dump, show the state of the unit\n" + printf(" c - continue, proceed without asking anymore\n" + " D - dump, show the state of the unit\n" " f - fail, don't execute the command and pretend it failed\n" " h - help\n" " i - info, show a short summary of the unit\n" @@ -2373,7 +2385,7 @@ static int exec_child( exec_context_tty_reset(context, params); - if (params->confirm_spawn) { + if (!manager_is_confirm_spawn_disabled(unit->manager)) { const char *vc = params->confirm_spawn; _cleanup_free_ char *cmdline = NULL; diff --git a/src/core/manager.c b/src/core/manager.c index 6ffbbd7389..b49e3b593a 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -114,7 +114,7 @@ static void manager_watch_jobs_in_progress(Manager *m) { /* We do not want to show the cylon animation if the user * needs to confirm service executions otherwise confirmation * messages will be screwed by the cylon animation. */ - if (m->confirm_spawn) + if (!manager_is_confirm_spawn_disabled(m)) return; if (m->jobs_in_progress_event_source) @@ -3218,6 +3218,17 @@ void manager_set_first_boot(Manager *m, bool b) { m->first_boot = b; } +void manager_disable_confirm_spawn(void) { + (void) touch("/run/systemd/confirm_spawn_disabled"); +} + +bool manager_is_confirm_spawn_disabled(Manager *m) { + if (!m->confirm_spawn) + return true; + + return access("/run/systemd/confirm_spawn_disabled", F_OK) >= 0; +} + void manager_status_printf(Manager *m, StatusType type, const char *status, const char *format, ...) { va_list ap; diff --git a/src/core/manager.h b/src/core/manager.h index 8b3db6e48b..4f17f1eea5 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -405,3 +405,5 @@ const char *manager_state_to_string(ManagerState m) _const_; ManagerState manager_state_from_string(const char *s) _pure_; const char *manager_get_confirm_spawn(Manager *m); +bool manager_is_confirm_spawn_disabled(Manager *m); +void manager_disable_confirm_spawn(void); -- cgit v1.2.3-54-g00ecf