diff options
-rw-r--r-- | acconfig.h | 5 | ||||
-rw-r--r-- | auth-chall.c | 42 | ||||
-rw-r--r-- | auth-passwd.c | 14 | ||||
-rw-r--r-- | auth.h | 12 | ||||
-rw-r--r-- | auth1.c | 10 | ||||
-rw-r--r-- | auth2.c | 10 | ||||
-rw-r--r-- | configure.in | 18 | ||||
-rw-r--r-- | session.c | 11 |
8 files changed, 109 insertions, 13 deletions
diff --git a/acconfig.h b/acconfig.h index dc716089a..d27153476 100644 --- a/acconfig.h +++ b/acconfig.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: acconfig.h,v 1.101 2001/02/09 01:55:36 djm Exp $ */ | 1 | /* $Id: acconfig.h,v 1.102 2001/02/18 06:01:00 djm Exp $ */ |
2 | 2 | ||
3 | #ifndef _CONFIG_H | 3 | #ifndef _CONFIG_H |
4 | #define _CONFIG_H | 4 | #define _CONFIG_H |
@@ -290,6 +290,9 @@ | |||
290 | /* Detect IPv4 in IPv6 mapped addresses and treat as IPv4 */ | 290 | /* Detect IPv4 in IPv6 mapped addresses and treat as IPv4 */ |
291 | #undef IPV4_IN_IPV6 | 291 | #undef IPV4_IN_IPV6 |
292 | 292 | ||
293 | /* Define if you have BSD auth support */ | ||
294 | #undef BSD_AUTH | ||
295 | |||
293 | @BOTTOM@ | 296 | @BOTTOM@ |
294 | 297 | ||
295 | /* ******************* Shouldn't need to edit below this line ************** */ | 298 | /* ******************* Shouldn't need to edit below this line ************** */ |
diff --git a/auth-chall.c b/auth-chall.c index b6ec02a38..926c07ede 100644 --- a/auth-chall.c +++ b/auth-chall.c | |||
@@ -26,7 +26,48 @@ | |||
26 | RCSID("$OpenBSD: auth-chall.c,v 1.4 2001/02/04 15:32:22 stevesk Exp $"); | 26 | RCSID("$OpenBSD: auth-chall.c,v 1.4 2001/02/04 15:32:22 stevesk Exp $"); |
27 | 27 | ||
28 | #include "auth.h" | 28 | #include "auth.h" |
29 | #include "log.h" | ||
29 | 30 | ||
31 | #ifdef BSD_AUTH | ||
32 | char * | ||
33 | get_challenge(Authctxt *authctxt, char *devs) | ||
34 | { | ||
35 | char *challenge; | ||
36 | |||
37 | if (authctxt->as != NULL) { | ||
38 | debug2("try reuse session"); | ||
39 | challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE); | ||
40 | if (challenge != NULL) { | ||
41 | debug2("reuse bsd auth session"); | ||
42 | return challenge; | ||
43 | } | ||
44 | auth_close(authctxt->as); | ||
45 | authctxt->as = NULL; | ||
46 | } | ||
47 | debug2("new bsd auth session"); | ||
48 | if (devs == NULL || strlen(devs) == 0) | ||
49 | devs = authctxt->style; | ||
50 | debug3("bsd auth: devs %s", devs ? devs : "<default>"); | ||
51 | authctxt->as = auth_userchallenge(authctxt->user, devs, "auth-ssh", | ||
52 | &challenge); | ||
53 | if (authctxt->as == NULL) | ||
54 | return NULL; | ||
55 | debug2("get_challenge: <%s>", challenge ? challenge : "EMPTY"); | ||
56 | return challenge; | ||
57 | } | ||
58 | int | ||
59 | verify_response(Authctxt *authctxt, char *response) | ||
60 | { | ||
61 | int authok; | ||
62 | |||
63 | if (authctxt->as == 0) | ||
64 | error("verify_response: no bsd auth session"); | ||
65 | authok = auth_userresponse(authctxt->as, response, 0); | ||
66 | authctxt->as = NULL; | ||
67 | debug("verify_response: <%s> = <%d>", response, authok); | ||
68 | return authok != 0; | ||
69 | } | ||
70 | #else | ||
30 | #ifdef SKEY | 71 | #ifdef SKEY |
31 | #include <skey.h> | 72 | #include <skey.h> |
32 | 73 | ||
@@ -60,3 +101,4 @@ verify_response(Authctxt *authctxt, char *response) | |||
60 | return 0; | 101 | return 0; |
61 | } | 102 | } |
62 | #endif | 103 | #endif |
104 | #endif | ||
diff --git a/auth-passwd.c b/auth-passwd.c index c849abdcc..5a91e5585 100644 --- a/auth-passwd.c +++ b/auth-passwd.c | |||
@@ -77,14 +77,17 @@ RCSID("$OpenBSD: auth-passwd.c,v 1.21 2001/02/12 16:16:23 markus Exp $"); | |||
77 | #define is_winnt (GetVersion() < 0x80000000) | 77 | #define is_winnt (GetVersion() < 0x80000000) |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | |||
81 | extern ServerOptions options; | ||
82 | |||
80 | /* | 83 | /* |
81 | * Tries to authenticate the user using password. Returns true if | 84 | * Tries to authenticate the user using password. Returns true if |
82 | * authentication succeeds. | 85 | * authentication succeeds. |
83 | */ | 86 | */ |
84 | int | 87 | int |
85 | auth_password(struct passwd * pw, const char *password) | 88 | auth_password(Authctxt *authctxt, const char *password) |
86 | { | 89 | { |
87 | extern ServerOptions options; | 90 | struct passwd * pw = authctxt->pw; |
88 | char *encrypted_password; | 91 | char *encrypted_password; |
89 | char *pw_password; | 92 | char *pw_password; |
90 | char *salt; | 93 | char *salt; |
@@ -122,6 +125,13 @@ auth_password(struct passwd * pw, const char *password) | |||
122 | #endif | 125 | #endif |
123 | if (*password == '\0' && options.permit_empty_passwd == 0) | 126 | if (*password == '\0' && options.permit_empty_passwd == 0) |
124 | return 0; | 127 | return 0; |
128 | #ifdef BSD_AUTH | ||
129 | if (auth_userokay(pw->pw_name, authctxt->style, "auth-ssh", | ||
130 | (char *)password) == 0) | ||
131 | return 0; | ||
132 | else | ||
133 | return 1; | ||
134 | #endif | ||
125 | 135 | ||
126 | #ifdef HAVE_CYGWIN | 136 | #ifdef HAVE_CYGWIN |
127 | if (is_winnt) { | 137 | if (is_winnt) { |
@@ -28,6 +28,13 @@ | |||
28 | 28 | ||
29 | #include <openssl/rsa.h> | 29 | #include <openssl/rsa.h> |
30 | 30 | ||
31 | #ifdef HAVE_LOGIN_CAP | ||
32 | #include <login_cap.h> | ||
33 | #endif | ||
34 | #ifdef BSD_AUTH | ||
35 | #include <bsd_auth.h> | ||
36 | #endif | ||
37 | |||
31 | typedef struct Authctxt Authctxt; | 38 | typedef struct Authctxt Authctxt; |
32 | struct Authctxt { | 39 | struct Authctxt { |
33 | int success; | 40 | int success; |
@@ -39,6 +46,9 @@ struct Authctxt { | |||
39 | char *service; | 46 | char *service; |
40 | struct passwd *pw; | 47 | struct passwd *pw; |
41 | char *style; | 48 | char *style; |
49 | #ifdef BSD_AUTH | ||
50 | auth_session_t *as; | ||
51 | #endif | ||
42 | }; | 52 | }; |
43 | 53 | ||
44 | /* | 54 | /* |
@@ -59,7 +69,7 @@ auth_rhosts_rsa(struct passwd * pw, const char *client_user, RSA* client_host_ke | |||
59 | * Tries to authenticate the user using password. Returns true if | 69 | * Tries to authenticate the user using password. Returns true if |
60 | * authentication succeeds. | 70 | * authentication succeeds. |
61 | */ | 71 | */ |
62 | int auth_password(struct passwd * pw, const char *password); | 72 | int auth_password(Authctxt *authctxt, const char *password); |
63 | 73 | ||
64 | /* | 74 | /* |
65 | * Performs the RSA authentication dialog with the client. This returns 0 if | 75 | * Performs the RSA authentication dialog with the client. This returns 0 if |
@@ -92,7 +92,7 @@ do_authloop(Authctxt *authctxt) | |||
92 | #elif defined(HAVE_OSF_SIA) | 92 | #elif defined(HAVE_OSF_SIA) |
93 | 0) { | 93 | 0) { |
94 | #else | 94 | #else |
95 | auth_password(pw, "")) { | 95 | auth_password(authctxt, "")) { |
96 | #endif | 96 | #endif |
97 | auth_log(authctxt, 1, "without authentication", ""); | 97 | auth_log(authctxt, 1, "without authentication", ""); |
98 | return; | 98 | return; |
@@ -262,7 +262,7 @@ do_authloop(Authctxt *authctxt) | |||
262 | password); | 262 | password); |
263 | #else /* !USE_PAM && !HAVE_OSF_SIA */ | 263 | #else /* !USE_PAM && !HAVE_OSF_SIA */ |
264 | /* Try authentication with the password. */ | 264 | /* Try authentication with the password. */ |
265 | authenticated = auth_password(pw, password); | 265 | authenticated = auth_password(authctxt, password); |
266 | #endif /* USE_PAM */ | 266 | #endif /* USE_PAM */ |
267 | 267 | ||
268 | memset(password, 0, strlen(password)); | 268 | memset(password, 0, strlen(password)); |
@@ -303,6 +303,12 @@ do_authloop(Authctxt *authctxt) | |||
303 | log("Unknown message during authentication: type %d", type); | 303 | log("Unknown message during authentication: type %d", type); |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | #ifdef BSD_AUTH | ||
307 | if (authctxt->as) { | ||
308 | auth_close(authctxt->as); | ||
309 | authctxt->as = NULL; | ||
310 | } | ||
311 | #endif | ||
306 | if (!authctxt->valid && authenticated) | 312 | if (!authctxt->valid && authenticated) |
307 | fatal("INTERNAL ERROR: authenticated invalid user %s", | 313 | fatal("INTERNAL ERROR: authenticated invalid user %s", |
308 | authctxt->user); | 314 | authctxt->user); |
@@ -218,6 +218,12 @@ input_userauth_request(int type, int plen, void *ctxt) | |||
218 | /* reset state */ | 218 | /* reset state */ |
219 | dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, &protocol_error); | 219 | dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, &protocol_error); |
220 | authctxt->postponed = 0; | 220 | authctxt->postponed = 0; |
221 | #ifdef BSD_AUTH | ||
222 | if (authctxt->as) { | ||
223 | auth_close(authctxt->as); | ||
224 | authctxt->as = NULL; | ||
225 | } | ||
226 | #endif | ||
221 | 227 | ||
222 | /* try to authenticate user */ | 228 | /* try to authenticate user */ |
223 | m = authmethod_lookup(method); | 229 | m = authmethod_lookup(method); |
@@ -341,7 +347,7 @@ userauth_none(Authctxt *authctxt) | |||
341 | #elif defined(HAVE_OSF_SIA) | 347 | #elif defined(HAVE_OSF_SIA) |
342 | return 0; | 348 | return 0; |
343 | #else /* !HAVE_OSF_SIA && !USE_PAM */ | 349 | #else /* !HAVE_OSF_SIA && !USE_PAM */ |
344 | return auth_password(authctxt->pw, ""); | 350 | return auth_password(authctxt, ""); |
345 | #endif /* USE_PAM */ | 351 | #endif /* USE_PAM */ |
346 | } | 352 | } |
347 | 353 | ||
@@ -366,7 +372,7 @@ userauth_passwd(Authctxt *authctxt) | |||
366 | #elif defined(HAVE_OSF_SIA) | 372 | #elif defined(HAVE_OSF_SIA) |
367 | auth_sia_password(authctxt->user, password) == 1) | 373 | auth_sia_password(authctxt->user, password) == 1) |
368 | #else /* !USE_PAM && !HAVE_OSF_SIA */ | 374 | #else /* !USE_PAM && !HAVE_OSF_SIA */ |
369 | auth_password(authctxt->pw, password) == 1) | 375 | auth_password(authctxt, password) == 1) |
370 | #endif /* USE_PAM */ | 376 | #endif /* USE_PAM */ |
371 | authenticated = 1; | 377 | authenticated = 1; |
372 | memset(password, 0, len); | 378 | memset(password, 0, len); |
diff --git a/configure.in b/configure.in index cbc866ad5..a5870f336 100644 --- a/configure.in +++ b/configure.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.in,v 1.246 2001/02/18 04:29:29 djm Exp $ | 1 | # $Id: configure.in,v 1.247 2001/02/18 06:01:00 djm Exp $ |
2 | 2 | ||
3 | AC_INIT(ssh.c) | 3 | AC_INIT(ssh.c) |
4 | 4 | ||
@@ -1411,6 +1411,17 @@ AC_ARG_WITH(4in6, | |||
1411 | ] | 1411 | ] |
1412 | ) | 1412 | ) |
1413 | 1413 | ||
1414 | # Whether to enable BSD auth support | ||
1415 | AC_ARG_WITH(bsd-auth, | ||
1416 | [ --with-bsd-auth Enable BSD auth support], | ||
1417 | [ | ||
1418 | if test "x$withval" != "xno" ; then | ||
1419 | AC_DEFINE(BSD_AUTH) | ||
1420 | bsd_auth=yes | ||
1421 | fi | ||
1422 | ] | ||
1423 | ) | ||
1424 | |||
1414 | AC_MSG_CHECKING(whether to install ssh as suid root) | 1425 | AC_MSG_CHECKING(whether to install ssh as suid root) |
1415 | AC_ARG_ENABLE(suid-ssh, | 1426 | AC_ARG_ENABLE(suid-ssh, |
1416 | [ --enable-suid-ssh Install ssh as suid root (default) | 1427 | [ --enable-suid-ssh Install ssh as suid root (default) |
@@ -1739,6 +1750,10 @@ echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" | |||
1739 | echo " Use IPv4 by default hack: $IPV4_HACK_MSG" | 1750 | echo " Use IPv4 by default hack: $IPV4_HACK_MSG" |
1740 | echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" | 1751 | echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" |
1741 | 1752 | ||
1753 | if test ! -z "$bsd_auth"; then | ||
1754 | echo " BSD Auth support: yes" | ||
1755 | fi | ||
1756 | |||
1742 | echo "" | 1757 | echo "" |
1743 | 1758 | ||
1744 | echo " Host: ${host}" | 1759 | echo " Host: ${host}" |
@@ -1769,3 +1784,4 @@ if test ! -z "$NO_SFTP"; then | |||
1769 | echo "64bit integers." | 1784 | echo "64bit integers." |
1770 | echo "" | 1785 | echo "" |
1771 | fi | 1786 | fi |
1787 | |||
@@ -89,10 +89,6 @@ RCSID("$OpenBSD: session.c,v 1.56 2001/02/16 14:03:43 markus Exp $"); | |||
89 | # define S_UNOFILE_HARD S_UNOFILE "_hard" | 89 | # define S_UNOFILE_HARD S_UNOFILE "_hard" |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | #ifdef HAVE_LOGIN_CAP | ||
93 | #include <login_cap.h> | ||
94 | #endif | ||
95 | |||
96 | /* types */ | 92 | /* types */ |
97 | 93 | ||
98 | #define TTYSZ 64 | 94 | #define TTYSZ 64 |
@@ -1071,6 +1067,13 @@ do_child(const char *command, struct passwd * pw, const char *term, | |||
1071 | perror("unable to set user context"); | 1067 | perror("unable to set user context"); |
1072 | exit(1); | 1068 | exit(1); |
1073 | } | 1069 | } |
1070 | #ifdef BSD_AUTH | ||
1071 | if (auth_approval(NULL, lc, pw->pw_name, "ssh") <= 0) { | ||
1072 | error("approval failure for %s", pw->pw_name); | ||
1073 | fprintf(stderr, "Approval failure"); | ||
1074 | exit(1); | ||
1075 | } | ||
1076 | #endif | ||
1074 | # else /* HAVE_LOGIN_CAP */ | 1077 | # else /* HAVE_LOGIN_CAP */ |
1075 | if (setlogin(pw->pw_name) < 0) | 1078 | if (setlogin(pw->pw_name) < 0) |
1076 | error("setlogin failed: %s", strerror(errno)); | 1079 | error("setlogin failed: %s", strerror(errno)); |