diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-03-10 16:46:25 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-03-10 16:46:25 +0000 |
commit | 7b22dadf7f6c7e0dc46dd5420d68e94a63d257b7 (patch) | |
tree | 936963e474733ce485f5666dcfd4e88495873d4a /usr.bin/mg | |
parent | 992db350b89c6a9c9ed40482c41d4992fc5258b4 (diff) |
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.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/fileio.c | 11 |
1 files changed, 7 insertions, 4 deletions
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 |