From: Daan De Meyer Date: Mon, 24 Nov 2025 11:36:42 +0000 (+0100) Subject: run0: Stay in cwd if --empower is specified without a user X-Git-Tag: v259-rc2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f6ef13f43aed654cbadb2785afee1ce567d710d;p=thirdparty%2Fsystemd.git 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 ~. --- diff --git a/src/run/run.c b/src/run/run.c index 510d4c51ab0..9ee539b5edb 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) {