summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2012-11-04 23:21:40 +1100
committerDamien Miller <djm@mindrot.org>2012-11-04 23:21:40 +1100
commita6e3f01d1e230b8acfdd6b4cf3096459d2a325e0 (patch)
tree577022d2b31e9519d26bc614c3f5396e17d58ec6 /monitor.c
parentd0d1099b3b8a766480ce6df215631bf0af6e6bcd (diff)
- djm@cvs.openbsd.org 2012/11/04 11:09:15
[auth.h auth1.c auth2.c monitor.c servconf.c servconf.h sshd.c] [sshd_config.5] Support multiple required authentication via an AuthenticationMethods option. This option lists one or more comma-separated lists of authentication method names. Successful completion of all the methods in any list is required for authentication to complete; feedback and ok markus@
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/monitor.c b/monitor.c
index e9802a3fd..0adbf3a65 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.117 2012/06/22 12:30:26 dtucker Exp $ */ 1/* $OpenBSD: monitor.c,v 1.118 2012/11/04 11:09:15 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -381,6 +381,21 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
381 while (!authenticated) { 381 while (!authenticated) {
382 auth_method = "unknown"; 382 auth_method = "unknown";
383 authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); 383 authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1);
384
385 /* Special handling for multiple required authentications */
386 if (options.num_auth_methods != 0) {
387 if (!compat20)
388 fatal("AuthenticationMethods is not supported"
389 "with SSH protocol 1");
390 if (authenticated &&
391 !auth2_update_methods_lists(authctxt,
392 auth_method)) {
393 debug3("%s: method %s: partial", __func__,
394 auth_method);
395 authenticated = 0;
396 }
397 }
398
384 if (authenticated) { 399 if (authenticated) {
385 if (!(ent->flags & MON_AUTHDECIDE)) 400 if (!(ent->flags & MON_AUTHDECIDE))
386 fatal("%s: unexpected authentication from %d", 401 fatal("%s: unexpected authentication from %d",
@@ -401,7 +416,6 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
401 } 416 }
402#endif 417#endif
403 } 418 }
404
405 if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) { 419 if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) {
406 auth_log(authctxt, authenticated, auth_method, 420 auth_log(authctxt, authenticated, auth_method,
407 compat20 ? " ssh2" : ""); 421 compat20 ? " ssh2" : "");
@@ -781,7 +795,17 @@ mm_answer_pwnamallow(int sock, Buffer *m)
781 COPY_MATCH_STRING_OPTS(); 795 COPY_MATCH_STRING_OPTS();
782#undef M_CP_STROPT 796#undef M_CP_STROPT
783#undef M_CP_STRARRAYOPT 797#undef M_CP_STRARRAYOPT
784 798
799 /* Create valid auth method lists */
800 if (compat20 && auth2_setup_methods_lists(authctxt) != 0) {
801 /*
802 * The monitor will continue long enough to let the child
803 * run to it's packet_disconnect(), but it must not allow any
804 * authentication to succeed.
805 */
806 debug("%s: no valid authentication method lists", __func__);
807 }
808
785 debug3("%s: sending MONITOR_ANS_PWNAM: %d", __func__, allowed); 809 debug3("%s: sending MONITOR_ANS_PWNAM: %d", __func__, allowed);
786 mm_request_send(sock, MONITOR_ANS_PWNAM, m); 810 mm_request_send(sock, MONITOR_ANS_PWNAM, m);
787 811
@@ -918,7 +942,10 @@ mm_answer_bsdauthrespond(int sock, Buffer *m)
918 debug3("%s: sending authenticated: %d", __func__, authok); 942 debug3("%s: sending authenticated: %d", __func__, authok);
919 mm_request_send(sock, MONITOR_ANS_BSDAUTHRESPOND, m); 943 mm_request_send(sock, MONITOR_ANS_BSDAUTHRESPOND, m);
920 944
921 auth_method = "bsdauth"; 945 if (compat20)
946 auth_method = "keyboard-interactive";
947 else
948 auth_method = "bsdauth";
922 949
923 return (authok != 0); 950 return (authok != 0);
924} 951}