diff options
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: auth.c,v 1.45 2002/09/20 18:41:29 stevesk Exp $"); | 26 | RCSID("$OpenBSD: auth.c,v 1.46 2002/11/04 10:07:53 markus Exp $"); |
27 | 27 | ||
28 | #ifdef HAVE_LOGIN_H | 28 | #ifdef HAVE_LOGIN_H |
29 | #include <login.h> | 29 | #include <login.h> |
@@ -423,6 +423,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
423 | uid_t uid = pw->pw_uid; | 423 | uid_t uid = pw->pw_uid; |
424 | char buf[MAXPATHLEN], homedir[MAXPATHLEN]; | 424 | char buf[MAXPATHLEN], homedir[MAXPATHLEN]; |
425 | char *cp; | 425 | char *cp; |
426 | int comparehome = 0; | ||
426 | struct stat st; | 427 | struct stat st; |
427 | 428 | ||
428 | if (realpath(file, buf) == NULL) { | 429 | if (realpath(file, buf) == NULL) { |
@@ -430,11 +431,8 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
430 | strerror(errno)); | 431 | strerror(errno)); |
431 | return -1; | 432 | return -1; |
432 | } | 433 | } |
433 | if (realpath(pw->pw_dir, homedir) == NULL) { | 434 | if (realpath(pw->pw_dir, homedir) != NULL) |
434 | snprintf(err, errlen, "realpath %s failed: %s", pw->pw_dir, | 435 | comparehome = 1; |
435 | strerror(errno)); | ||
436 | return -1; | ||
437 | } | ||
438 | 436 | ||
439 | /* check the open file to avoid races */ | 437 | /* check the open file to avoid races */ |
440 | if (fstat(fileno(f), &st) < 0 || | 438 | if (fstat(fileno(f), &st) < 0 || |
@@ -463,7 +461,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
463 | } | 461 | } |
464 | 462 | ||
465 | /* If are passed the homedir then we can stop */ | 463 | /* If are passed the homedir then we can stop */ |
466 | if (strcmp(homedir, buf) == 0) { | 464 | if (comparehome && strcmp(homedir, buf) == 0) { |
467 | debug3("secure_filename: terminating check at '%s'", | 465 | debug3("secure_filename: terminating check at '%s'", |
468 | buf); | 466 | buf); |
469 | break; | 467 | break; |