From f38e9e49f5dcab8ff40118b8020fbb086ce03ccb Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 21 Jan 2017 02:48:06 +0700 Subject: [PATCH] vtysh: Use HOME environment variable to get homedir and only fallback to passed entry if no HOME is defined Snap packages have a local HOME defined inside the SNAP container, but don't get access to passwd entry. Signed-off-by: Martin Winter --- vtysh/vtysh_user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index 3a64ae0a96..73f7c1be98 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -218,7 +218,12 @@ char * vtysh_get_home (void) { struct passwd *passwd; + char * homedir; + if ((homedir = getenv("HOME")) != 0) + return homedir; + + /* Fallback if HOME is undefined */ passwd = getpwuid (getuid ()); return passwd ? passwd->pw_dir : NULL;