From d43c1b3cc15df9031f7f27dbcd7bb1ab8ad6cc58 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 4 Dec 2020 14:34:43 +0100 Subject: [PATCH] Change to user's home directory before starting session This is what display managers do, so it is expected by many environments. --- unix/vncserver/vncsession.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unix/vncserver/vncsession.c b/unix/vncserver/vncsession.c index f78c096f..956a8f4b 100644 --- a/unix/vncserver/vncsession.c +++ b/unix/vncserver/vncsession.c @@ -431,6 +431,9 @@ run_script(const char *username, const char *display, char **envp) switch_user(pwent->pw_name, pwent->pw_uid, pwent->pw_gid); + if (chdir(pwent->pw_dir) == -1) + chdir("/"); + close_fds(); redir_stdio(pwent->pw_dir, display); -- 2.39.5