Use getpwuid()->pw_dir instead of $HOME when expanding ``~''.

This commit is contained in:
Brian Somers 1999-12-20 20:30:47 +00:00
parent 8b50b30fa7
commit 687d9f5709

View File

@ -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;