From 7b22dadf7f6c7e0dc46dd5420d68e94a63d257b7 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Thu, 10 Mar 2005 16:46:25 +0000 Subject: the realpath() was needed to do do relative to absolute path conversion. revert my diff that takes it out, and instead, on realpath() failure (like when you have no perms on pwd) just return the unexpanded path. everything still fine with that, just tab completeion and the like does not work (obviously). this was mainly for "sudo mg /etc/something" from ~ where ~ is nfs-mounted with root mapped to -2 and now, that case works as well as tab completion on insert-file etc. --- usr.bin/mg/fileio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'usr.bin/mg') diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 230da21c12d..91b3cc72444 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.46 2005/03/09 16:20:48 jfb Exp $ */ +/* $OpenBSD: fileio.c,v 1.47 2005/03/10 16:46:24 henning Exp $ */ /* * POSIX fileio.c @@ -244,9 +244,9 @@ extern char *wdir; char * adjustname(const char *fn) { - static char path[MAXPATHLEN]; + static char fnb[MAXPATHLEN]; const char *cp; - char user[LOGIN_NAME_MAX + 1]; + char user[LOGIN_NAME_MAX + 1], path[MAXPATHLEN]; int len; path[0] = '\0'; @@ -283,7 +283,10 @@ adjustname(const char *fn) } strlcat(path, fn, sizeof path); - return (path); + if (realpath(path, fnb) == NULL) + strlcpy(fnb, path, sizeof(fnb)); + + return (fnb); } #ifndef NO_STARTUP -- cgit v1.2.3