core: confirm_spawn: always accept units with same_pgrp set for now
authorFranck Bui <fbui@suse.com>
Mon, 14 Nov 2016 16:37:40 +0000 (17:37 +0100)
committerFranck Bui <fbui@suse.com>
Thu, 17 Nov 2016 17:16:51 +0000 (18:16 +0100)
For some reasons units remaining in the same process group as PID 1
(same_pgrp=true) fail to acquire the console even if it's not taken by anyone.

So always accept for units with same_pgrp set for now.

src/core/execute.c
src/core/unit.c
src/core/unit.h

index c7b324f..53aed1f 100644 (file)
@@ -2385,7 +2385,7 @@ static int exec_child(
 
         exec_context_tty_reset(context, params);
 
-        if (!manager_is_confirm_spawn_disabled(unit->manager)) {
+        if (unit_shall_confirm_spawn(unit)) {
                 const char *vc = params->confirm_spawn;
                 _cleanup_free_ char *cmdline = NULL;
 
index bba0f5d..7b78ba9 100644 (file)
@@ -1515,6 +1515,17 @@ int unit_start_limit_test(Unit *u) {
         return emergency_action(u->manager, u->start_limit_action, u->reboot_arg, "unit failed");
 }
 
+bool unit_shall_confirm_spawn(Unit *u) {
+
+        if (manager_is_confirm_spawn_disabled(u->manager))
+                return false;
+
+        /* For some reasons units remaining in the same process group
+         * as PID 1 fail to acquire the console even if it's not used
+         * by any process. So skip the confirmation question for them. */
+        return !unit_get_exec_context(u)->same_pgrp;
+}
+
 /* Errors:
  *         -EBADR:      This unit type does not support starting.
  *         -EALREADY:   Unit is already started.
index 9915436..1ef92f3 100644 (file)
@@ -654,6 +654,8 @@ void unit_notify_user_lookup(Unit *u, uid_t uid, gid_t gid);
 int unit_set_invocation_id(Unit *u, sd_id128_t id);
 int unit_acquire_invocation_id(Unit *u);
 
+bool unit_shall_confirm_spawn(Unit *u);
+
 /* Macros which append UNIT= or USER_UNIT= to the message */
 
 #define log_unit_full(unit, level, error, ...)                          \