summaryrefslogtreecommitdiffstats
path: root/vtysh
diff options
context:
space:
mode:
authorMartin Winter <mwinter@opensourcerouting.org>2017-01-20 20:48:06 +0100
committerMartin Winter <mwinter@opensourcerouting.org>2017-01-25 18:44:31 +0100
commitf38e9e49f5dcab8ff40118b8020fbb086ce03ccb (patch)
tree446ba643d56e48a25aac5dc94aad19c44331aa0c /vtysh
parentvtysh: Add vty_socket cli option to override the compiled-in location for the... (diff)
downloadfrr-f38e9e49f5dcab8ff40118b8020fbb086ce03ccb.tar.xz
frr-f38e9e49f5dcab8ff40118b8020fbb086ce03ccb.zip
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 <mwinter@opensourcerouting.org>
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh_user.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c
index 3a64ae0a9..73f7c1be9 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;