- markus@cvs.openbsd.org 2001/10/03 10:01:20
[auth.c] use realpath() for homedir, too. from jinmei@isl.rdc.toshiba.co.jp
This commit is contained in:
parent
1bae404457
commit
c3e49e7b31
|
@ -37,6 +37,9 @@
|
||||||
- stevesk@cvs.openbsd.org 2001/10/02 22:56:09
|
- stevesk@cvs.openbsd.org 2001/10/02 22:56:09
|
||||||
[sshd.c]
|
[sshd.c]
|
||||||
#include "channels.h" for channel_set_af()
|
#include "channels.h" for channel_set_af()
|
||||||
|
- markus@cvs.openbsd.org 2001/10/03 10:01:20
|
||||||
|
[auth.c]
|
||||||
|
use realpath() for homedir, too. from jinmei@isl.rdc.toshiba.co.jp
|
||||||
|
|
||||||
20011001
|
20011001
|
||||||
- (stevesk) loginrec.c: fix type conversion problems exposed when using
|
- (stevesk) loginrec.c: fix type conversion problems exposed when using
|
||||||
|
@ -6629,4 +6632,4 @@
|
||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1580 2001/10/03 17:46:39 mouring Exp $
|
$Id: ChangeLog,v 1.1581 2001/10/03 17:55:26 mouring Exp $
|
||||||
|
|
11
auth.c
11
auth.c
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#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 $");
|
||||||
|
|
||||||
#ifdef HAVE_LOGIN_H
|
#ifdef HAVE_LOGIN_H
|
||||||
#include <login.h>
|
#include <login.h>
|
||||||
|
@ -363,7 +363,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
|
||||||
char *err, size_t errlen)
|
char *err, size_t errlen)
|
||||||
{
|
{
|
||||||
uid_t uid = pw->pw_uid;
|
uid_t uid = pw->pw_uid;
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN], homedir[MAXPATHLEN];
|
||||||
char *cp;
|
char *cp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -372,6 +372,11 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
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 */
|
/* check the open file to avoid races */
|
||||||
if (fstat(fileno(f), &st) < 0 ||
|
if (fstat(fileno(f), &st) < 0 ||
|
||||||
|
@ -400,7 +405,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If are passed the homedir then we can stop */
|
/* 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'",
|
debug3("secure_filename: terminating check at '%s'",
|
||||||
buf);
|
buf);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue