diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-10-03 10:01:21 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-10-03 10:01:21 +0000 |
commit | 9a05644e2d024a07d1eda60e390b1dc4b818acd3 (patch) | |
tree | cd94e18057a95170c8d80257a8abbcd9bedcbbaa | |
parent | 3c558a41cc3000d747751be05b7d42dc389325b7 (diff) |
use realpath() for homedir, too. from jinmei@isl.rdc.toshiba.co.jp
-rw-r--r-- | usr.bin/ssh/auth.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/ssh/auth.c b/usr.bin/ssh/auth.c index 1385a1b667c..19e4f57ed75 100644 --- a/usr.bin/ssh/auth.c +++ b/usr.bin/ssh/auth.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth.c,v 1.27 2001/07/11 18:26:15 markus Exp $"); +RCSID("$OpenBSD: auth.c,v 1.28 2001/10/03 10:01:20 markus Exp $"); #include <libgen.h> @@ -311,7 +311,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, char *err, size_t errlen) { uid_t uid = pw->pw_uid; - char buf[MAXPATHLEN]; + char buf[MAXPATHLEN], homedir[MAXPATHLEN]; char *cp; struct stat st; @@ -320,6 +320,11 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, strerror(errno)); return -1; } + if (realpath(pw->pw_dir, homedir) == NULL) { + snprintf(err, errlen, "realpath %s failed: %s", pw->pw_dir, + strerror(errno)); + return -1; + } /* check the open file to avoid races */ if (fstat(fileno(f), &st) < 0 || @@ -348,7 +353,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, } /* If are passed the homedir then we can stop */ - if (strcmp(pw->pw_dir, buf) == 0) { + if (strcmp(homedir, buf) == 0) { debug3("secure_filename: terminating check at '%s'", buf); break; |