|
Lines 146-151
Link Here
|
| 146 |
int mm_answer_pwnamallow(int, Buffer *); |
146 |
int mm_answer_pwnamallow(int, Buffer *); |
| 147 |
int mm_answer_auth2_read_banner(int, Buffer *); |
147 |
int mm_answer_auth2_read_banner(int, Buffer *); |
| 148 |
int mm_answer_authserv(int, Buffer *); |
148 |
int mm_answer_authserv(int, Buffer *); |
|
|
149 |
#ifdef PAM_ENHANCEMENT |
| 150 |
int mm_answer_authmethod(int, Buffer *); |
| 151 |
#endif |
| 149 |
int mm_answer_authpassword(int, Buffer *); |
152 |
int mm_answer_authpassword(int, Buffer *); |
| 150 |
int mm_answer_bsdauthquery(int, Buffer *); |
153 |
int mm_answer_bsdauthquery(int, Buffer *); |
| 151 |
int mm_answer_bsdauthrespond(int, Buffer *); |
154 |
int mm_answer_bsdauthrespond(int, Buffer *); |
|
Lines 225-234
Link Here
|
| 225 |
{MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, |
228 |
{MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign}, |
| 226 |
{MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, |
229 |
{MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow}, |
| 227 |
{MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, |
230 |
{MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv}, |
|
|
231 |
#ifdef PAM_ENHANCEMENT |
| 232 |
{MONITOR_REQ_AUTHMETHOD, MON_ISAUTH, mm_answer_authmethod}, |
| 233 |
#endif |
| 228 |
{MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, |
234 |
{MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner}, |
| 229 |
{MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, |
235 |
{MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword}, |
| 230 |
#ifdef USE_PAM |
236 |
#ifdef USE_PAM |
|
|
237 |
#ifdef PAM_ENHANCEMENT |
| 238 |
{MONITOR_REQ_PAM_START, MON_ISAUTH, mm_answer_pam_start}, |
| 239 |
#else |
| 231 |
{MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start}, |
240 |
{MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start}, |
|
|
241 |
#endif |
| 232 |
{MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account}, |
242 |
{MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account}, |
| 233 |
{MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx}, |
243 |
{MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx}, |
| 234 |
{MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query}, |
244 |
{MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query}, |
|
Lines 385-396
Link Here
|
| 385 |
auth_method = "unknown"; |
395 |
auth_method = "unknown"; |
| 386 |
auth_submethod = NULL; |
396 |
auth_submethod = NULL; |
| 387 |
authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); |
397 |
authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); |
| 388 |
|
|
|
| 389 |
/* Special handling for multiple required authentications */ |
398 |
/* Special handling for multiple required authentications */ |
| 390 |
if (options.num_auth_methods != 0) { |
399 |
if (options.num_auth_methods != 0) { |
| 391 |
if (!compat20) |
400 |
if (!compat20) |
| 392 |
fatal("AuthenticationMethods is not supported" |
401 |
fatal("AuthenticationMethods is not supported" |
| 393 |
"with SSH protocol 1"); |
402 |
"with SSH protocol 1"); |
|
|
403 |
|
| 404 |
#if defined(USE_PAM) && defined(PAM_ENHANCEMENT) |
| 405 |
/* |
| 406 |
* If each userauth has its own PAM service, then PAM |
| 407 |
* need to perform account check for this service. |
| 408 |
*/ |
| 409 |
if (options.use_pam && authenticated && |
| 410 |
options.pam_service_per_authmethod) { |
| 411 |
Buffer m; |
| 412 |
|
| 413 |
buffer_init(&m); |
| 414 |
mm_request_receive_expect(pmonitor->m_sendfd, |
| 415 |
MONITOR_REQ_PAM_ACCOUNT, &m); |
| 416 |
authenticated = |
| 417 |
mm_answer_pam_account(pmonitor->m_sendfd, &m); |
| 418 |
buffer_free(&m); |
| 419 |
} |
| 420 |
#endif |
| 394 |
if (authenticated && |
421 |
if (authenticated && |
| 395 |
!auth2_update_methods_lists(authctxt, |
422 |
!auth2_update_methods_lists(authctxt, |
| 396 |
auth_method, auth_submethod)) { |
423 |
auth_method, auth_submethod)) { |
|
Lines 399-404
Link Here
|
| 399 |
authenticated = 0; |
426 |
authenticated = 0; |
| 400 |
partial = 1; |
427 |
partial = 1; |
| 401 |
} |
428 |
} |
|
|
429 |
|
| 402 |
} |
430 |
} |
| 403 |
|
431 |
|
| 404 |
if (authenticated) { |
432 |
if (authenticated) { |
|
Lines 409-416
Link Here
|
| 409 |
!auth_root_allowed(auth_method)) |
437 |
!auth_root_allowed(auth_method)) |
| 410 |
authenticated = 0; |
438 |
authenticated = 0; |
| 411 |
#ifdef USE_PAM |
439 |
#ifdef USE_PAM |
|
|
440 |
#ifdef PAM_ENHANCEMENT |
| 441 |
/* |
| 442 |
* PAM needs to perform account checks after auth. |
| 443 |
* However, if each userauth has its own PAM service |
| 444 |
* and options.num_auth_methods != 0, then no need to |
| 445 |
* perform account checking, because it was done |
| 446 |
* already. |
| 447 |
*/ |
| 448 |
if (options.use_pam && authenticated && |
| 449 |
!(options.num_auth_methods != 0 && |
| 450 |
options.pam_service_per_authmethod)) { |
| 451 |
#else |
| 412 |
/* PAM needs to perform account checks after auth */ |
452 |
/* PAM needs to perform account checks after auth */ |
| 413 |
if (options.use_pam && authenticated) { |
453 |
if (options.use_pam && authenticated) { |
|
|
454 |
#endif |
| 414 |
Buffer m; |
455 |
Buffer m; |
| 415 |
|
456 |
|
| 416 |
buffer_init(&m); |
457 |
buffer_init(&m); |
|
Lines 828-833
Link Here
|
| 828 |
/* Allow service/style information on the auth context */ |
869 |
/* Allow service/style information on the auth context */ |
| 829 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); |
870 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1); |
| 830 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); |
871 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1); |
|
|
872 |
#ifdef PAM_ENHANCEMENT |
| 873 |
/* Allow authmethod information on the auth context */ |
| 874 |
monitor_permit(mon_dispatch, MONITOR_REQ_AUTHMETHOD, 1); |
| 875 |
#endif |
| 831 |
} |
876 |
} |
| 832 |
#ifdef USE_PAM |
877 |
#ifdef USE_PAM |
| 833 |
if (options.use_pam) |
878 |
if (options.use_pam) |
|
Lines 868-874
Link Here
|
| 868 |
return (0); |
913 |
return (0); |
| 869 |
} |
914 |
} |
| 870 |
|
915 |
|
|
|
916 |
#ifdef PAM_ENHANCEMENT |
| 871 |
int |
917 |
int |
|
|
918 |
mm_answer_authmethod(int sock, Buffer *m) |
| 919 |
{ |
| 920 |
monitor_permit_authentications(1); |
| 921 |
|
| 922 |
if (authctxt->authmethod_name != NULL) |
| 923 |
free(authctxt->authmethod_name); |
| 924 |
|
| 925 |
authctxt->authmethod_name = buffer_get_string(m, NULL); |
| 926 |
debug3("%s: authmethod_name=%s", __func__, authctxt->authmethod_name); |
| 927 |
|
| 928 |
if (strlen(authctxt->authmethod_name) == 0) { |
| 929 |
free(authctxt->authmethod_name); |
| 930 |
authctxt->authmethod_name = NULL; |
| 931 |
} |
| 932 |
|
| 933 |
return (0); |
| 934 |
} |
| 935 |
#endif |
| 936 |
|
| 937 |
int |
| 872 |
mm_answer_authpassword(int sock, Buffer *m) |
938 |
mm_answer_authpassword(int sock, Buffer *m) |
| 873 |
{ |
939 |
{ |
| 874 |
static int call_count; |
940 |
static int call_count; |