On Thu, Apr 12, 2018 at 07:04:23PM +0200, Han Boetes wrote:
> Yes this also works for me.
>
Awesome, any OKs?
Diff again for convenience:
diff --git fileio.c fileio.c
index 0987f6f30de..339088f5e2d 100644
--- fileio.c
+++ fileio.c
@@ -703,7 +703,7 @@ expandtilde(const char *fn)
struct stat statbuf;
const char *cp;
char user[LOGIN_NAME_MAX], path[NFILEN];
- char *un, *ret;
+ char *ret;
size_t ulen, plen;
path[0] = '\0';
@@ -722,16 +722,13 @@ expandtilde(const char *fn)
return (NULL);
return(ret);
}
- if (ulen == 0) { /* ~/ or ~ */
- if ((un = getlogin()) != NULL)
- (void)strlcpy(user, un, sizeof(user));
- else
- user[0] = '\0';
- } else { /* ~user/ or ~user */
+ if (ulen == 0) /* ~/ or ~ */
+ pw = getpwuid(geteuid());
+ else { /* ~user/ or ~user */
memcpy(user, &fn[1], ulen);
user[ulen] = '\0';
+ pw = getpwnam(user);
}
- pw = getpwnam(user);
if (pw != NULL) {
plen = strlcpy(path, pw->pw_dir, sizeof(path));
if (plen == 0 || path[plen - 1] != '/') {
--
I'm not entirely sure you are real.