diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-06-15 18:31:13 -0300 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-10-19 10:56:54 +0200 |
commit | 95e77e9a0bac0827e8b8efdb9565063566d22587 (patch) | |
tree | afe29bfd5049d5b63487af35c144247164a217ca /src/openrc-run | |
parent | f3ad53c0ce8676a075af23b108f430a035d78270 (diff) |
openrc-run: in user mode, change to homedir instead of /
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/openrc-run')
-rw-r--r-- | src/openrc-run/openrc-run.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/openrc-run/openrc-run.c b/src/openrc-run/openrc-run.c index ac2b498f..daece676 100644 --- a/src/openrc-run/openrc-run.c +++ b/src/openrc-run/openrc-run.c @@ -1123,6 +1123,7 @@ int main(int argc, char **argv) char *pidstr = NULL; size_t l = 0, ll; const char *file; + const char *changedir = "/"; struct stat stbuf; /* Show help if insufficient args */ @@ -1183,8 +1184,12 @@ int main(int argc, char **argv) if (argc < 3) usage(EXIT_FAILURE); - /* Change dir to / to ensure all init scripts don't use stuff in pwd */ - if (chdir("/") == -1) + /* Change dir to / to ensure all init scripts don't use stuff in pwd + * In user scripts mode, we change to the homefolder of the user instead */ + if (rc_is_user()) + changedir = rc_user_home(); + + if (chdir(changedir) == -1) eerror("chdir: %s", strerror(errno)); if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) { |