]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: Stop agents before we drop privileges
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 17 Mar 2025 15:01:26 +0000 (16:01 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 19 Mar 2025 09:01:19 +0000 (10:01 +0100)
After dropping privileges, we won't be able to stop agents anymore
as our signals will get ignored.

src/run/run.c

index cdb5cfefd629371c22406b524eec640c8c74f76c..e4ae5373b92e4c9be89c38774d224c070f6e7197 100644 (file)
@@ -2483,6 +2483,11 @@ static int start_transient_scope(sd_bus *bus) {
                         return log_oom();
         }
 
+        /* Stop agents before we pass control away and before we drop privileges, to avoid TTY conflicts and
+         * before we become unable to stop agents. */
+        polkit_agent_close();
+        ask_password_agent_close();
+
         if (arg_nice_set) {
                 if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0)
                         return log_error_errno(errno, "Failed to set nice level: %m");
@@ -2571,10 +2576,6 @@ static int start_transient_scope(sd_bus *bus) {
                 }
         }
 
-        /* Stop agents before we pass control away, to avoid TTY conflicts */
-        polkit_agent_close();
-        ask_password_agent_close();
-
         execvpe(arg_cmdline[0], arg_cmdline, env);
 
         return log_error_errno(errno, "Failed to execute: %m");