mirror of
https://github.com/troglobit/finit.git
synced 2026-11-01 13:10:32 +00:00
Starting service as @user chdir() to their $HOME
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
0710fdd2a3
commit
57514130fc
3 files changed
+11
-4
No files matched your search
@@ -151,10 +151,11 @@ static int service_start(svc_t *svc)
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
int status;
|
||||
char *home = NULL;
|
||||
#ifdef ENABLE_STATIC
|
||||
int uid = 0; /* XXX: Fix better warning that dropprivs is disabled. */
|
||||
#else
|
||||
int uid = getuser(svc->username);
|
||||
int uid = getuser(svc->username, &home);
|
||||
#endif
|
||||
char *args[MAX_NUM_SVC_ARGS];
|
||||
|
||||
@@ -165,6 +166,10 @@ static int service_start(svc_t *svc)
|
||||
/* Set default path for regular users */
|
||||
if (uid > 0)
|
||||
setenv("PATH", _PATH_DEFPATH, 1);
|
||||
if (home) {
|
||||
setenv("HOME", home, 1);
|
||||
chdir(home);
|
||||
}
|
||||
}
|
||||
|
||||
/* Serve copy of args to process in case it modifies them. */
|
||||
|
||||
Reference in new issue
Block a user