]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: make --working-directory= work for --scope too 24790/head
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Sep 2022 12:21:46 +0000 (14:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Sep 2022 12:22:21 +0000 (14:22 +0200)
This sounds like a more user-friendly alternative to #24780

src/run/run.c

index e2915fe4defdbe9567227d07cd0eeb9072fbb00c..627a6b11dab1c989669ff6f8e4a8028301ddf2fa 100644 (file)
@@ -1529,6 +1529,9 @@ static int start_transient_scope(sd_bus *bus) {
                         return log_error_errno(errno, "Failed to change UID to " UID_FMT ": %m", uid);
         }
 
+        if (arg_working_directory && chdir(arg_working_directory) < 0)
+                return log_error_errno(errno, "Failed to change directory to '%s': %m", arg_working_directory);
+
         env = strv_env_merge(environ, user_env, arg_environment);
         if (!env)
                 return log_oom();