diff options
author | brian <brian@FreeBSD.org> | 1999-12-20 20:30:47 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-12-20 20:30:47 +0000 |
commit | 89c7950e1ae2a69f5ac672a8d8d9c1fa6c622e3f (patch) | |
tree | a73ca3d5ce1eac92283d513370585ef7cfa84954 /usr.sbin | |
parent | 540cfa0f957d6aa9f2b0e74c11858fb5bd0fc40a (diff) | |
download | FreeBSD-src-89c7950e1ae2a69f5ac672a8d8d9c1fa6c622e3f.zip FreeBSD-src-89c7950e1ae2a69f5ac672a8d8d9c1fa6c622e3f.tar.gz |
Use getpwuid()->pw_dir instead of $HOME when expanding ``~''.
Diffstat (limited to 'usr.sbin')
-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; |