]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Use HOME environment variable to get homedir and only fallback to passed entry...
authorMartin Winter <mwinter@opensourcerouting.org>
Fri, 20 Jan 2017 19:48:06 +0000 (02:48 +0700)
committerMartin Winter <mwinter@opensourcerouting.org>
Wed, 25 Jan 2017 17:44:31 +0000 (00:44 +0700)
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>
vtysh/vtysh_user.c

index 3a64ae0a966e9ca93867e2a8f7b8377a3c6200e6..73f7c1be980a2d579de9659564f166e77cce374c 100644 (file)
@@ -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;