|
Lines 308-313
monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
Link Here
|
| 308 |
partial = 0; |
308 |
partial = 0; |
| 309 |
auth_method = "unknown"; |
309 |
auth_method = "unknown"; |
| 310 |
auth_submethod = NULL; |
310 |
auth_submethod = NULL; |
|
|
311 |
auth2_authctxt_reset_info(authctxt); |
| 312 |
|
| 311 |
authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); |
313 |
authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1); |
| 312 |
|
314 |
|
| 313 |
/* Special handling for multiple required authentications */ |
315 |
/* Special handling for multiple required authentications */ |
|
Lines 343-348
monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
Link Here
|
| 343 |
#endif |
345 |
#endif |
| 344 |
} |
346 |
} |
| 345 |
if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) { |
347 |
if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) { |
|
|
348 |
if (authenticated || partial) { |
| 349 |
auth2_update_session_info(authctxt, |
| 350 |
auth_method, auth_submethod); |
| 351 |
} |
| 346 |
auth_log(authctxt, authenticated, partial, |
352 |
auth_log(authctxt, authenticated, partial, |
| 347 |
auth_method, auth_submethod); |
353 |
auth_method, auth_submethod); |
| 348 |
if (!partial && !authenticated) |
354 |
if (!partial && !authenticated) |
|
Lines 1147-1170
mm_answer_keyallowed(int sock, Buffer *m)
Link Here
|
| 1147 |
switch (type) { |
1153 |
switch (type) { |
| 1148 |
case MM_USERKEY: |
1154 |
case MM_USERKEY: |
| 1149 |
allowed = options.pubkey_authentication && |
1155 |
allowed = options.pubkey_authentication && |
| 1150 |
!auth2_userkey_already_used(authctxt, key) && |
1156 |
!auth2_key_already_used(authctxt, key) && |
| 1151 |
match_pattern_list(sshkey_ssh_name(key), |
1157 |
match_pattern_list(sshkey_ssh_name(key), |
| 1152 |
options.pubkey_key_types, 0) == 1 && |
1158 |
options.pubkey_key_types, 0) == 1 && |
| 1153 |
user_key_allowed(authctxt->pw, key, |
1159 |
user_key_allowed(authctxt->pw, key, |
| 1154 |
pubkey_auth_attempt); |
1160 |
pubkey_auth_attempt); |
| 1155 |
pubkey_auth_info(authctxt, key, NULL); |
|
|
| 1156 |
auth_method = "publickey"; |
1161 |
auth_method = "publickey"; |
|
|
1162 |
auth2_record_key(authctxt, 0, key); |
| 1157 |
if (options.pubkey_authentication && |
1163 |
if (options.pubkey_authentication && |
| 1158 |
(!pubkey_auth_attempt || allowed != 1)) |
1164 |
(!pubkey_auth_attempt || allowed != 1)) |
| 1159 |
auth_clear_options(); |
1165 |
auth_clear_options(); |
| 1160 |
break; |
1166 |
break; |
| 1161 |
case MM_HOSTKEY: |
1167 |
case MM_HOSTKEY: |
| 1162 |
allowed = options.hostbased_authentication && |
1168 |
allowed = options.hostbased_authentication && |
|
|
1169 |
!auth2_key_already_used(authctxt, key) && |
| 1163 |
match_pattern_list(sshkey_ssh_name(key), |
1170 |
match_pattern_list(sshkey_ssh_name(key), |
| 1164 |
options.hostbased_key_types, 0) == 1 && |
1171 |
options.hostbased_key_types, 0) == 1 && |
| 1165 |
hostbased_key_allowed(authctxt->pw, |
1172 |
hostbased_key_allowed(authctxt->pw, |
| 1166 |
cuser, chost, key); |
1173 |
cuser, chost, key); |
| 1167 |
pubkey_auth_info(authctxt, key, |
1174 |
auth2_record_key(authctxt, 0, key); |
|
|
1175 |
auth2_record_info(authctxt, |
| 1168 |
"client user \"%.100s\", client host \"%.100s\"", |
1176 |
"client user \"%.100s\", client host \"%.100s\"", |
| 1169 |
cuser, chost); |
1177 |
cuser, chost); |
| 1170 |
auth_method = "hostbased"; |
1178 |
auth_method = "hostbased"; |
|
Lines 1175-1185
mm_answer_keyallowed(int sock, Buffer *m)
Link Here
|
| 1175 |
} |
1183 |
} |
| 1176 |
} |
1184 |
} |
| 1177 |
|
1185 |
|
| 1178 |
debug3("%s: key %p is %s", |
1186 |
debug3("%s: key is %s", __func__, allowed ? "allowed" : "not allowed"); |
| 1179 |
__func__, key, allowed ? "allowed" : "not allowed"); |
|
|
| 1180 |
|
1187 |
|
| 1181 |
if (key != NULL) |
1188 |
sshkey_free(key); |
| 1182 |
key_free(key); |
|
|
| 1183 |
|
1189 |
|
| 1184 |
/* clear temporarily storage (used by verify) */ |
1190 |
/* clear temporarily storage (used by verify) */ |
| 1185 |
monitor_reset_key_state(); |
1191 |
monitor_reset_key_state(); |
|
Lines 1353-1362
mm_answer_keyverify(int sock, Buffer *m)
Link Here
|
| 1353 |
switch (key_blobtype) { |
1359 |
switch (key_blobtype) { |
| 1354 |
case MM_USERKEY: |
1360 |
case MM_USERKEY: |
| 1355 |
valid_data = monitor_valid_userblob(data, datalen); |
1361 |
valid_data = monitor_valid_userblob(data, datalen); |
|
|
1362 |
auth_method = "publickey"; |
| 1356 |
break; |
1363 |
break; |
| 1357 |
case MM_HOSTKEY: |
1364 |
case MM_HOSTKEY: |
| 1358 |
valid_data = monitor_valid_hostbasedblob(data, datalen, |
1365 |
valid_data = monitor_valid_hostbasedblob(data, datalen, |
| 1359 |
hostbased_cuser, hostbased_chost); |
1366 |
hostbased_cuser, hostbased_chost); |
|
|
1367 |
auth_method = "hostbased"; |
| 1360 |
break; |
1368 |
break; |
| 1361 |
default: |
1369 |
default: |
| 1362 |
valid_data = 0; |
1370 |
valid_data = 0; |
|
Lines 1366-1388
mm_answer_keyverify(int sock, Buffer *m)
Link Here
|
| 1366 |
fatal("%s: bad signature data blob", __func__); |
1374 |
fatal("%s: bad signature data blob", __func__); |
| 1367 |
|
1375 |
|
| 1368 |
verified = key_verify(key, signature, signaturelen, data, datalen); |
1376 |
verified = key_verify(key, signature, signaturelen, data, datalen); |
| 1369 |
debug3("%s: key %p signature %s", |
1377 |
debug3("%s: %s %p signature %s", __func__, auth_method, key, |
| 1370 |
__func__, key, (verified == 1) ? "verified" : "unverified"); |
1378 |
(verified == 1) ? "verified" : "unverified"); |
| 1371 |
|
1379 |
auth2_record_key(authctxt, verified == 1, key); |
| 1372 |
/* If auth was successful then record key to ensure it isn't reused */ |
|
|
| 1373 |
if (verified == 1 && key_blobtype == MM_USERKEY) |
| 1374 |
auth2_record_userkey(authctxt, key); |
| 1375 |
else |
| 1376 |
key_free(key); |
| 1377 |
|
1380 |
|
| 1378 |
free(blob); |
1381 |
free(blob); |
| 1379 |
free(signature); |
1382 |
free(signature); |
| 1380 |
free(data); |
1383 |
free(data); |
| 1381 |
|
1384 |
|
| 1382 |
auth_method = key_blobtype == MM_USERKEY ? "publickey" : "hostbased"; |
|
|
| 1383 |
|
| 1384 |
monitor_reset_key_state(); |
1385 |
monitor_reset_key_state(); |
| 1385 |
|
1386 |
|
|
|
1387 |
sshkey_free(key); |
| 1386 |
buffer_clear(m); |
1388 |
buffer_clear(m); |
| 1387 |
buffer_put_int(m, verified); |
1389 |
buffer_put_int(m, verified); |
| 1388 |
mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m); |
1390 |
mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m); |
|
Lines 1774-1779
int
Link Here
|
| 1774 |
mm_answer_gss_userok(int sock, Buffer *m) |
1776 |
mm_answer_gss_userok(int sock, Buffer *m) |
| 1775 |
{ |
1777 |
{ |
| 1776 |
int authenticated; |
1778 |
int authenticated; |
|
|
1779 |
const char *displayname; |
| 1777 |
|
1780 |
|
| 1778 |
if (!options.gss_authentication) |
1781 |
if (!options.gss_authentication) |
| 1779 |
fatal("%s: GSSAPI authentication not enabled", __func__); |
1782 |
fatal("%s: GSSAPI authentication not enabled", __func__); |
|
Lines 1788-1793
mm_answer_gss_userok(int sock, Buffer *m)
Link Here
|
| 1788 |
|
1791 |
|
| 1789 |
auth_method = "gssapi-with-mic"; |
1792 |
auth_method = "gssapi-with-mic"; |
| 1790 |
|
1793 |
|
|
|
1794 |
if ((displayname = ssh_gssapi_displayname()) != NULL) |
| 1795 |
auth2_record_info(authctxt, "%s", displayname); |
| 1796 |
|
| 1791 |
/* Monitor loop will terminate if authenticated */ |
1797 |
/* Monitor loop will terminate if authenticated */ |
| 1792 |
return (authenticated); |
1798 |
return (authenticated); |
| 1793 |
} |
1799 |
} |