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 ~.
This commit is contained in:
Daan De Meyer
2025-11-24 12:36:42 +01:00
parent c746488537
commit 4f6ef13f43

View File

@@ -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) {