diff options
| author | Martin Winter <mwinter@opensourcerouting.org> | 2017-01-21 02:48:06 +0700 |
|---|---|---|
| committer | Martin Winter <mwinter@opensourcerouting.org> | 2017-01-26 00:44:31 +0700 |
| commit | f38e9e49f5dcab8ff40118b8020fbb086ce03ccb (patch) | |
| tree | 446ba643d56e48a25aac5dc94aad19c44331aa0c /vtysh/vtysh_user.c | |
| parent | 87d79a9f79015421d8bf7cd07f8486a2bae15ef2 (diff) | |
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/vtysh_user.c')
| -rw-r--r-- | vtysh/vtysh_user.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |
