From 4f6ef13f43aed654cbadb2785afee1ce567d710d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 24 Nov 2025 12:36:42 +0100 Subject: [PATCH] run0: Stay in cwd if --empower is specified without a user If we run "run0 --empower", the expectation is to stay in the current working directory, not switch to ~. --- src/run/run.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/run/run.c b/src/run/run.c index 510d4c51ab..9ee539b5ed 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -1098,6 +1098,12 @@ static int parse_argv_sudo_mode(int argc, char *argv[]) { arg_exec_user = getusername_malloc(); if (!arg_exec_user) return log_oom(); + + if (arg_empower && !arg_working_directory) { + r = safe_getcwd(&arg_working_directory); + if (r < 0) + return log_error_errno(r, "Failed to get current working directory: %m"); + } } if (!arg_working_directory) {