Starting service as @user chdir() to their $HOME

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-07-28 23:48:39 +02:00
1 parent 0710fdd2a3
commit 57514130fc
3 files changed
+11 -4

No files matched your search

+4 -2
View File
@@ -189,9 +189,10 @@ int print_result(int fail)
return fail;
}
int getuser(char *username)
int getuser(char *username, char **home)
{
#ifdef ENABLE_STATIC
home = NULL; /* XXX: Fixme */
return fgetint("/etc/passwd", "x:\n", username);
#else
struct passwd *usr;
@@ -199,7 +200,8 @@ int getuser(char *username)
if (!username || (usr = getpwnam(username)) == NULL)
return -1;
return usr->pw_uid;
*home = usr->pw_dir;
return usr->pw_uid;
#endif
}