|
Lines 253-259
Buffer loginmsg;
Link Here
|
| 253 |
struct passwd *privsep_pw = NULL; |
253 |
struct passwd *privsep_pw = NULL; |
| 254 |
|
254 |
|
| 255 |
/* Prototypes for various functions defined later in this file. */ |
255 |
/* Prototypes for various functions defined later in this file. */ |
| 256 |
void destroy_sensitive_data(void); |
256 |
void destroy_sensitive_data(int); |
| 257 |
void demote_sensitive_data(void); |
257 |
void demote_sensitive_data(void); |
| 258 |
|
258 |
|
| 259 |
static void do_ssh1_kex(void); |
259 |
static void do_ssh1_kex(void); |
|
Lines 272-277
close_listen_socks(void)
Link Here
|
| 272 |
num_listen_socks = -1; |
272 |
num_listen_socks = -1; |
| 273 |
} |
273 |
} |
| 274 |
|
274 |
|
|
|
275 |
/* |
| 276 |
* Is this process listening for clients (i.e. not specific to any specific |
| 277 |
* client connection?) |
| 278 |
*/ |
| 279 |
int listening_for_clients(void) |
| 280 |
{ |
| 281 |
return num_listen_socks > 0; |
| 282 |
} |
| 283 |
|
| 275 |
static void |
284 |
static void |
| 276 |
close_startup_pipes(void) |
285 |
close_startup_pipes(void) |
| 277 |
{ |
286 |
{ |
|
Lines 532-553
sshd_exchange_identification(int sock_in
Link Here
|
| 532 |
} |
541 |
} |
| 533 |
} |
542 |
} |
| 534 |
|
543 |
|
| 535 |
/* Destroy the host and server keys. They will no longer be needed. */ |
544 |
/* |
|
|
545 |
* Destroy the host and server keys. They will no longer be needed. Careful, |
| 546 |
* this can be called from cleanup_exit() - i.e. from just about anywhere. |
| 547 |
*/ |
| 536 |
void |
548 |
void |
| 537 |
destroy_sensitive_data(void) |
549 |
destroy_sensitive_data(int privsep) |
| 538 |
{ |
550 |
{ |
| 539 |
int i; |
551 |
int i; |
|
|
552 |
pid_t pid; |
| 553 |
uid_t uid; |
| 540 |
|
554 |
|
| 541 |
if (sensitive_data.server_key) { |
555 |
if (sensitive_data.server_key) { |
| 542 |
key_free(sensitive_data.server_key); |
556 |
key_free(sensitive_data.server_key); |
| 543 |
sensitive_data.server_key = NULL; |
557 |
sensitive_data.server_key = NULL; |
| 544 |
} |
558 |
} |
|
|
559 |
pid = getpid(); |
| 560 |
uid = getuid(); |
| 545 |
for (i = 0; i < options.num_host_key_files; i++) { |
561 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 546 |
if (sensitive_data.host_keys[i]) { |
562 |
if (sensitive_data.host_keys[i]) { |
|
|
563 |
char *fp; |
| 564 |
|
| 565 |
if (key_is_private(sensitive_data.host_keys[i])) |
| 566 |
fp = key_fingerprint(sensitive_data.host_keys[i], |
| 567 |
FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, |
| 568 |
SSH_FP_HEX); |
| 569 |
else |
| 570 |
fp = NULL; |
| 547 |
key_free(sensitive_data.host_keys[i]); |
571 |
key_free(sensitive_data.host_keys[i]); |
| 548 |
sensitive_data.host_keys[i] = NULL; |
572 |
sensitive_data.host_keys[i] = NULL; |
|
|
573 |
if (fp != NULL) { |
| 574 |
if (privsep) |
| 575 |
PRIVSEP(audit_destroy_sensitive_data(fp, |
| 576 |
pid, uid)); |
| 577 |
else |
| 578 |
audit_destroy_sensitive_data(fp, |
| 579 |
pid, uid); |
| 580 |
xfree(fp); |
| 581 |
} |
| 549 |
} |
582 |
} |
| 550 |
if (sensitive_data.host_certificates[i]) { |
583 |
if (sensitive_data.host_certificates |
|
|
584 |
&& sensitive_data.host_certificates[i]) { |
| 551 |
key_free(sensitive_data.host_certificates[i]); |
585 |
key_free(sensitive_data.host_certificates[i]); |
| 552 |
sensitive_data.host_certificates[i] = NULL; |
586 |
sensitive_data.host_certificates[i] = NULL; |
| 553 |
} |
587 |
} |
|
Lines 561-566
void
Link Here
|
| 561 |
demote_sensitive_data(void) |
595 |
demote_sensitive_data(void) |
| 562 |
{ |
596 |
{ |
| 563 |
Key *tmp; |
597 |
Key *tmp; |
|
|
598 |
pid_t pid; |
| 599 |
uid_t uid; |
| 564 |
int i; |
600 |
int i; |
| 565 |
|
601 |
|
| 566 |
if (sensitive_data.server_key) { |
602 |
if (sensitive_data.server_key) { |
|
Lines 569-581
demote_sensitive_data(void)
Link Here
|
| 569 |
sensitive_data.server_key = tmp; |
605 |
sensitive_data.server_key = tmp; |
| 570 |
} |
606 |
} |
| 571 |
|
607 |
|
|
|
608 |
pid = getpid(); |
| 609 |
uid = getuid(); |
| 572 |
for (i = 0; i < options.num_host_key_files; i++) { |
610 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 573 |
if (sensitive_data.host_keys[i]) { |
611 |
if (sensitive_data.host_keys[i]) { |
|
|
612 |
char *fp; |
| 613 |
|
| 614 |
if (key_is_private(sensitive_data.host_keys[i])) |
| 615 |
fp = key_fingerprint(sensitive_data.host_keys[i], |
| 616 |
FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, |
| 617 |
SSH_FP_HEX); |
| 618 |
else |
| 619 |
fp = NULL; |
| 574 |
tmp = key_demote(sensitive_data.host_keys[i]); |
620 |
tmp = key_demote(sensitive_data.host_keys[i]); |
| 575 |
key_free(sensitive_data.host_keys[i]); |
621 |
key_free(sensitive_data.host_keys[i]); |
| 576 |
sensitive_data.host_keys[i] = tmp; |
622 |
sensitive_data.host_keys[i] = tmp; |
| 577 |
if (tmp->type == KEY_RSA1) |
623 |
if (tmp->type == KEY_RSA1) |
| 578 |
sensitive_data.ssh1_host_key = tmp; |
624 |
sensitive_data.ssh1_host_key = tmp; |
|
|
625 |
if (fp != NULL) { |
| 626 |
audit_destroy_sensitive_data(fp, pid, uid); |
| 627 |
xfree(fp); |
| 628 |
} |
| 579 |
} |
629 |
} |
| 580 |
/* Certs do not need demotion */ |
630 |
/* Certs do not need demotion */ |
| 581 |
} |
631 |
} |
|
Lines 1120-1125
server_accept_loop(int *sock_in, int *so
Link Here
|
| 1120 |
if (received_sigterm) { |
1170 |
if (received_sigterm) { |
| 1121 |
logit("Received signal %d; terminating.", |
1171 |
logit("Received signal %d; terminating.", |
| 1122 |
(int) received_sigterm); |
1172 |
(int) received_sigterm); |
|
|
1173 |
destroy_sensitive_data(0); |
| 1123 |
close_listen_socks(); |
1174 |
close_listen_socks(); |
| 1124 |
unlink(options.pid_file); |
1175 |
unlink(options.pid_file); |
| 1125 |
exit(0); |
1176 |
exit(0); |
|
Lines 2023-2029
main(int ac, char **av)
Link Here
|
| 2023 |
privsep_postauth(authctxt); |
2074 |
privsep_postauth(authctxt); |
| 2024 |
/* the monitor process [priv] will not return */ |
2075 |
/* the monitor process [priv] will not return */ |
| 2025 |
if (!compat20) |
2076 |
if (!compat20) |
| 2026 |
destroy_sensitive_data(); |
2077 |
destroy_sensitive_data(0); |
| 2027 |
} |
2078 |
} |
| 2028 |
|
2079 |
|
| 2029 |
packet_set_timeout(options.client_alive_interval, |
2080 |
packet_set_timeout(options.client_alive_interval, |
|
Lines 2034-2039
main(int ac, char **av)
Link Here
|
| 2034 |
|
2085 |
|
| 2035 |
/* The connection has been terminated. */ |
2086 |
/* The connection has been terminated. */ |
| 2036 |
packet_destroy_all(1, 1); |
2087 |
packet_destroy_all(1, 1); |
|
|
2088 |
destroy_sensitive_data(1); |
| 2037 |
|
2089 |
|
| 2038 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
2090 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
| 2039 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
2091 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
|
Lines 2262-2268
do_ssh1_kex(void)
Link Here
|
| 2262 |
session_id[i] = session_key[i] ^ session_key[i + 16]; |
2314 |
session_id[i] = session_key[i] ^ session_key[i + 16]; |
| 2263 |
} |
2315 |
} |
| 2264 |
/* Destroy the private and public keys. No longer. */ |
2316 |
/* Destroy the private and public keys. No longer. */ |
| 2265 |
destroy_sensitive_data(); |
2317 |
destroy_sensitive_data(0); |
| 2266 |
|
2318 |
|
| 2267 |
if (use_privsep) |
2319 |
if (use_privsep) |
| 2268 |
mm_ssh1_session_id(session_id); |
2320 |
mm_ssh1_session_id(session_id); |
|
Lines 2352-2359
do_ssh2_kex(void)
Link Here
|
| 2352 |
void |
2404 |
void |
| 2353 |
cleanup_exit(int i) |
2405 |
cleanup_exit(int i) |
| 2354 |
{ |
2406 |
{ |
|
|
2407 |
static int in_cleanup; |
| 2408 |
|
| 2409 |
int is_privsep_child; |
| 2410 |
|
| 2411 |
/* cleanup_exit can be called at the very least from the privsep |
| 2412 |
wrappers used for auditing. Make sure we don't recurse |
| 2413 |
indefinitely. */ |
| 2414 |
if (in_cleanup) |
| 2415 |
_exit(i); |
| 2416 |
in_cleanup = 1; |
| 2417 |
|
| 2355 |
if (the_authctxt) |
2418 |
if (the_authctxt) |
| 2356 |
do_cleanup(the_authctxt); |
2419 |
do_cleanup(the_authctxt); |
|
|
2420 |
is_privsep_child = use_privsep && pmonitor != NULL && !mm_is_monitor(); |
| 2421 |
if (sensitive_data.host_keys != NULL) |
| 2422 |
destroy_sensitive_data(is_privsep_child); |
| 2357 |
packet_destroy_all(1, is_privsep_child); |
2423 |
packet_destroy_all(1, is_privsep_child); |
| 2358 |
#ifdef SSH_AUDIT_EVENTS |
2424 |
#ifdef SSH_AUDIT_EVENTS |
| 2359 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */ |
2425 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */ |