diff options
Diffstat (limited to 'usr.sbin/ppp/systems.c')
-rw-r--r-- | usr.sbin/ppp/systems.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index 6fe6a8e..b12a46c 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -73,24 +73,20 @@ InterpretArg(const char *from, char *to) from++; if (*from == '~') { + struct passwd *pwd; + ptr = strchr(++from, '/'); len = ptr ? ptr - from : strlen(from); if (len == 0) { - if ((env = getenv("HOME")) == NULL) - env = _PATH_PPP; - strncpy(to, env, endto - to); + pwd = getpwuid(getuid()); } else { - struct passwd *pwd; - strncpy(to, from, len); to[len] = '\0'; pwd = getpwnam(to); - if (pwd) - strncpy(to, pwd->pw_dir, endto-to); - else - strncpy(to, _PATH_PPP, endto - to); - endpwent(); } + strncpy(to, pwd ? pwd->pw_dir : _PATH_PPP, endto - to); + endpwent(); + *endto = '\0'; to += strlen(to); from += len; |