summaryrefslogtreecommitdiff
path: root/auth1.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth1.c')
-rw-r--r--auth1.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/auth1.c b/auth1.c
index ca288958e..8553bfa2f 100644
--- a/auth1.c
+++ b/auth1.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: auth1.c,v 1.38 2002/03/18 17:50:31 provos Exp $"); 13RCSID("$OpenBSD: auth1.c,v 1.39 2002/03/19 14:27:39 markus Exp $");
14 14
15#include "xmalloc.h" 15#include "xmalloc.h"
16#include "rsa.h" 16#include "rsa.h"
@@ -24,7 +24,6 @@ RCSID("$OpenBSD: auth1.c,v 1.38 2002/03/18 17:50:31 provos Exp $");
24#include "auth.h" 24#include "auth.h"
25#include "channels.h" 25#include "channels.h"
26#include "session.h" 26#include "session.h"
27#include "misc.h"
28#include "uidswap.h" 27#include "uidswap.h"
29#include "monitor_wrap.h" 28#include "monitor_wrap.h"
30 29
@@ -359,7 +358,6 @@ Authctxt *
359do_authentication(void) 358do_authentication(void)
360{ 359{
361 Authctxt *authctxt; 360 Authctxt *authctxt;
362 struct passwd *pw = NULL, *pwent;
363 u_int ulen; 361 u_int ulen;
364 char *p, *user, *style = NULL; 362 char *p, *user, *style = NULL;
365 363
@@ -382,21 +380,12 @@ do_authentication(void)
382 authctxt->style = style; 380 authctxt->style = style;
383 381
384 /* Verify that the user is a valid user. */ 382 /* Verify that the user is a valid user. */
385 pwent = PRIVSEP(getpwnamallow(user)); 383 if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL)
386 if (pwent) {
387 authctxt->valid = 1; 384 authctxt->valid = 1;
388 pw = pwcopy(pwent); 385 else
389 } else {
390 debug("do_authentication: illegal user %s", user); 386 debug("do_authentication: illegal user %s", user);
391 pw = NULL;
392 }
393 /* Free memory */
394 if (use_privsep && pwent != NULL)
395 pwfree(pwent);
396
397 authctxt->pw = pw;
398 387
399 setproctitle("%s%s", pw ? user : "unknown", 388 setproctitle("%s%s", authctxt->pw ? user : "unknown",
400 use_privsep ? " [net]" : ""); 389 use_privsep ? " [net]" : "");
401 390
402#ifdef USE_PAM 391#ifdef USE_PAM
@@ -408,7 +397,8 @@ do_authentication(void)
408 * the server. (Unless you are running Windows) 397 * the server. (Unless you are running Windows)
409 */ 398 */
410#ifndef HAVE_CYGWIN 399#ifndef HAVE_CYGWIN
411 if (!use_privsep && getuid() != 0 && pw && pw->pw_uid != getuid()) 400 if (!use_privsep && getuid() != 0 && authctxt->pw &&
401 authctxt->pw->pw_uid != getuid())
412 packet_disconnect("Cannot change user when server not running as root."); 402 packet_disconnect("Cannot change user when server not running as root.");
413#endif 403#endif
414 404