summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2002-03-19 14:27:40 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2002-03-19 14:27:40 +0000
commit2923cda3d87ee0f6f11b3f6a991c5d4088524663 (patch)
tree3e667b7457c6ed6ad3465d145e79f3f0ce4803d1 /usr.bin
parent830af90362f11f32f3e6175d915ec72736413f8b (diff)
make getpwnamallow() allways call pwcopy()
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/auth.c5
-rw-r--r--usr.bin/ssh/auth1.c22
-rw-r--r--usr.bin/ssh/auth2.c16
-rw-r--r--usr.bin/ssh/monitor.c4
-rw-r--r--usr.bin/ssh/monitor_wrap.c14
-rw-r--r--usr.bin/ssh/monitor_wrap.h3
6 files changed, 16 insertions, 48 deletions
diff --git a/usr.bin/ssh/auth.c b/usr.bin/ssh/auth.c
index e1aeb595ea9..028de4801b4 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.39 2002/03/19 10:49:35 markus Exp $");
+RCSID("$OpenBSD: auth.c,v 1.40 2002/03/19 14:27:39 markus Exp $");
#include <libgen.h>
@@ -39,6 +39,7 @@ RCSID("$OpenBSD: auth.c,v 1.39 2002/03/19 10:49:35 markus Exp $");
#include "bufaux.h"
#include "uidswap.h"
#include "tildexpand.h"
+#include "misc.h"
/* import */
extern ServerOptions options;
@@ -417,5 +418,5 @@ getpwnamallow(const char *user)
auth_close(as);
#endif
#endif
- return (pw);
+ return (pwcopy(pw));
}
diff --git a/usr.bin/ssh/auth1.c b/usr.bin/ssh/auth1.c
index 3252cb182ca..9e8d11086f6 100644
--- a/usr.bin/ssh/auth1.c
+++ b/usr.bin/ssh/auth1.c
@@ -10,7 +10,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth1.c,v 1.38 2002/03/18 17:50:31 provos Exp $");
+RCSID("$OpenBSD: auth1.c,v 1.39 2002/03/19 14:27:39 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -24,7 +24,6 @@ RCSID("$OpenBSD: auth1.c,v 1.38 2002/03/18 17:50:31 provos Exp $");
#include "auth.h"
#include "channels.h"
#include "session.h"
-#include "misc.h"
#include "uidswap.h"
#include "monitor_wrap.h"
@@ -323,7 +322,6 @@ Authctxt *
do_authentication(void)
{
Authctxt *authctxt;
- struct passwd *pw = NULL, *pwent;
u_int ulen;
char *p, *user, *style = NULL;
@@ -346,28 +344,20 @@ do_authentication(void)
authctxt->style = style;
/* Verify that the user is a valid user. */
- pwent = PRIVSEP(getpwnamallow(user));
- if (pwent) {
+ if ((authctxt->pw = PRIVSEP(getpwnamallow(user))) != NULL)
authctxt->valid = 1;
- pw = pwcopy(pwent);
- } else {
+ else
debug("do_authentication: illegal user %s", user);
- pw = NULL;
- }
- /* Free memory */
- if (use_privsep && pwent != NULL)
- pwfree(pwent);
-
- authctxt->pw = pw;
- setproctitle("%s%s", pw ? user : "unknown",
+ setproctitle("%s%s", authctxt->pw ? user : "unknown",
use_privsep ? " [net]" : "");
/*
* If we are not running as root, the user must have the same uid as
* the server.
*/
- if (!use_privsep && getuid() != 0 && pw && pw->pw_uid != getuid())
+ if (!use_privsep && getuid() != 0 && authctxt->pw &&
+ authctxt->pw->pw_uid != getuid())
packet_disconnect("Cannot change user when server not running as root.");
/*
diff --git a/usr.bin/ssh/auth2.c b/usr.bin/ssh/auth2.c
index 201e364e42a..c5004b39ee7 100644
--- a/usr.bin/ssh/auth2.c
+++ b/usr.bin/ssh/auth2.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth2.c,v 1.88 2002/03/18 17:50:31 provos Exp $");
+RCSID("$OpenBSD: auth2.c,v 1.89 2002/03/19 14:27:39 markus Exp $");
#include <openssl/evp.h>
@@ -47,7 +47,6 @@ RCSID("$OpenBSD: auth2.c,v 1.88 2002/03/18 17:50:31 provos Exp $");
#include "pathnames.h"
#include "uidswap.h"
#include "auth-options.h"
-#include "misc.h"
#include "hostfile.h"
#include "canohost.h"
#include "match.h"
@@ -183,25 +182,18 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
if (authctxt->attempt++ == 0) {
/* setup auth context */
- struct passwd *pw = NULL;
- pw = PRIVSEP(getpwnamallow(user));
- if (pw && strcmp(service, "ssh-connection")==0) {
- authctxt->pw = pwcopy(pw);
+ authctxt->pw = PRIVSEP(getpwnamallow(user));
+ if (authctxt->pw && strcmp(service, "ssh-connection")==0) {
authctxt->valid = 1;
debug2("input_userauth_request: setting up authctxt for %s", user);
} else {
log("input_userauth_request: illegal user %s", user);
}
- /* Free memory */
- if (use_privsep && pw != NULL)
- pwfree(pw);
-
- setproctitle("%s%s", pw ? user : "unknown",
+ setproctitle("%s%s", authctxt->pw ? user : "unknown",
use_privsep ? " [net]" : "");
authctxt->user = xstrdup(user);
authctxt->service = xstrdup(service);
authctxt->style = style ? xstrdup(style) : NULL;
-
if (use_privsep)
mm_inform_authserv(service, style);
} else if (strcmp(user, authctxt->user) != 0 ||
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c
index 0c03b86f814..6c70d2ebdb9 100644
--- a/usr.bin/ssh/monitor.c
+++ b/usr.bin/ssh/monitor.c
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor.c,v 1.3 2002/03/19 10:41:32 markus Exp $");
+RCSID("$OpenBSD: monitor.c,v 1.4 2002/03/19 14:27:39 markus Exp $");
#include <openssl/dh.h>
@@ -486,7 +486,7 @@ mm_answer_pwnamallow(int socket, Buffer *m)
}
allowed = 1;
- authctxt->pw = pwcopy(pwent);
+ authctxt->pw = pwent;
authctxt->valid = 1;
buffer_put_char(m, 1);
diff --git a/usr.bin/ssh/monitor_wrap.c b/usr.bin/ssh/monitor_wrap.c
index 4036f5d1103..e477cff2514 100644
--- a/usr.bin/ssh/monitor_wrap.c
+++ b/usr.bin/ssh/monitor_wrap.c
@@ -25,7 +25,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor_wrap.c,v 1.3 2002/03/19 10:41:32 markus Exp $");
+RCSID("$OpenBSD: monitor_wrap.c,v 1.4 2002/03/19 14:27:39 markus Exp $");
#include <openssl/bn.h>
#include <openssl/dh.h>
@@ -205,18 +205,6 @@ mm_getpwnamallow(const char *login)
return (pw);
}
-void
-pwfree(struct passwd *pw)
-{
- xfree(pw->pw_name);
- xfree(pw->pw_passwd);
- xfree(pw->pw_gecos);
- xfree(pw->pw_class);
- xfree(pw->pw_dir);
- xfree(pw->pw_shell);
- xfree(pw);
-}
-
/* Inform the privileged process about service and style */
void
diff --git a/usr.bin/ssh/monitor_wrap.h b/usr.bin/ssh/monitor_wrap.h
index 587685540aa..a75b905029a 100644
--- a/usr.bin/ssh/monitor_wrap.h
+++ b/usr.bin/ssh/monitor_wrap.h
@@ -82,7 +82,4 @@ void *mm_zalloc(struct mm_master *, u_int, u_int);
void mm_zfree(struct mm_master *, void *);
void mm_init_compression(struct mm_master *);
-/* Utility functions */
-
-void pwfree(struct passwd *);
#endif /* _MM_H_ */