=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/auth.c,v retrieving revision 1.41.2.5 retrieving revision 1.42 diff -u -r1.41.2.5 -r1.42 --- src/usr.bin/ssh/auth.c 2003/04/03 22:35:16 1.41.2.5 +++ src/usr.bin/ssh/auth.c 2002/05/13 20:44:58 1.42 @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth.c,v 1.41.2.5 2003/04/03 22:35:16 miod Exp $"); +RCSID("$OpenBSD: auth.c,v 1.42 2002/05/13 20:44:58 markus Exp $"); #include @@ -323,7 +323,7 @@ /* * Check a given file for security. This is defined as all components - * of the path to the file must be owned by either the owner of + * of the path to the file must either be owned by either the owner of * of the file or root and no directories must be group or world writable. * * XXX Should any specific check be done for sym links ? @@ -340,7 +340,6 @@ uid_t uid = pw->pw_uid; char buf[MAXPATHLEN], homedir[MAXPATHLEN]; char *cp; - int comparehome = 0; struct stat st; if (realpath(file, buf) == NULL) { @@ -348,8 +347,11 @@ strerror(errno)); return -1; } - if (realpath(pw->pw_dir, homedir) != NULL) - comparehome = 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 || @@ -378,7 +380,7 @@ } /* If are passed the homedir then we can stop */ - if (comparehome && strcmp(homedir, buf) == 0) { + if (strcmp(homedir, buf) == 0) { debug3("secure_filename: terminating check at '%s'", buf); break; @@ -405,13 +407,8 @@ struct passwd *pw; pw = getpwnam(user); - if (pw == NULL) { - log("Illegal user %.100s from %.100s", - user, get_remote_ipaddr()); + if (pw == NULL || !allowed_user(pw)) return (NULL); - } - if (!allowed_user(pw)) - return (NULL); #ifdef HAVE_LOGIN_CAP if ((lc = login_getclass(pw->pw_class)) == NULL) { debug("unable to get login class: %s", user); @@ -419,7 +416,7 @@ } #ifdef BSD_AUTH if ((as = auth_open()) == NULL || auth_setpwd(as, pw) != 0 || - auth_approval(as, lc, pw->pw_name, "ssh") <= 0) { + auth_approval(NULL, lc, pw->pw_name, "ssh") <= 0) { debug("Approval failure for %s", user); pw = NULL; }