|
Lines 254-260
Buffer loginmsg;
Link Here
|
| 254 |
struct passwd *privsep_pw = NULL; |
254 |
struct passwd *privsep_pw = NULL; |
| 255 |
|
255 |
|
| 256 |
/* Prototypes for various functions defined later in this file. */ |
256 |
/* Prototypes for various functions defined later in this file. */ |
| 257 |
void destroy_sensitive_data(void); |
257 |
void destroy_sensitive_data(int); |
| 258 |
void demote_sensitive_data(void); |
258 |
void demote_sensitive_data(void); |
| 259 |
|
259 |
|
| 260 |
static void do_ssh1_kex(void); |
260 |
static void do_ssh1_kex(void); |
|
Lines 273-278
close_listen_socks(void)
Link Here
|
| 273 |
num_listen_socks = -1; |
273 |
num_listen_socks = -1; |
| 274 |
} |
274 |
} |
| 275 |
|
275 |
|
|
|
276 |
/* |
| 277 |
* Is this process listening for clients (i.e. not specific to any specific |
| 278 |
* client connection?) |
| 279 |
*/ |
| 280 |
int listening_for_clients(void) |
| 281 |
{ |
| 282 |
return num_listen_socks > 0; |
| 283 |
} |
| 284 |
|
| 276 |
static void |
285 |
static void |
| 277 |
close_startup_pipes(void) |
286 |
close_startup_pipes(void) |
| 278 |
{ |
287 |
{ |
|
Lines 533-554
sshd_exchange_identification(int sock_in
Link Here
|
| 533 |
} |
542 |
} |
| 534 |
} |
543 |
} |
| 535 |
|
544 |
|
| 536 |
/* Destroy the host and server keys. They will no longer be needed. */ |
545 |
/* |
|
|
546 |
* Destroy the host and server keys. They will no longer be needed. Careful, |
| 547 |
* this can be called from cleanup_exit() - i.e. from just about anywhere. |
| 548 |
*/ |
| 537 |
void |
549 |
void |
| 538 |
destroy_sensitive_data(void) |
550 |
destroy_sensitive_data(int privsep) |
| 539 |
{ |
551 |
{ |
| 540 |
int i; |
552 |
int i; |
|
|
553 |
pid_t pid; |
| 554 |
uid_t uid; |
| 541 |
|
555 |
|
| 542 |
if (sensitive_data.server_key) { |
556 |
if (sensitive_data.server_key) { |
| 543 |
key_free(sensitive_data.server_key); |
557 |
key_free(sensitive_data.server_key); |
| 544 |
sensitive_data.server_key = NULL; |
558 |
sensitive_data.server_key = NULL; |
| 545 |
} |
559 |
} |
|
|
560 |
pid = getpid(); |
| 561 |
uid = getuid(); |
| 546 |
for (i = 0; i < options.num_host_key_files; i++) { |
562 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 547 |
if (sensitive_data.host_keys[i]) { |
563 |
if (sensitive_data.host_keys[i]) { |
|
|
564 |
char *fp; |
| 565 |
|
| 566 |
if (key_is_private(sensitive_data.host_keys[i])) |
| 567 |
fp = key_fingerprint(sensitive_data.host_keys[i], |
| 568 |
FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, |
| 569 |
SSH_FP_HEX); |
| 570 |
else |
| 571 |
fp = NULL; |
| 548 |
key_free(sensitive_data.host_keys[i]); |
572 |
key_free(sensitive_data.host_keys[i]); |
| 549 |
sensitive_data.host_keys[i] = NULL; |
573 |
sensitive_data.host_keys[i] = NULL; |
|
|
574 |
if (fp != NULL) { |
| 575 |
if (privsep) |
| 576 |
PRIVSEP(audit_destroy_sensitive_data(fp, |
| 577 |
pid, uid)); |
| 578 |
else |
| 579 |
audit_destroy_sensitive_data(fp, |
| 580 |
pid, uid); |
| 581 |
xfree(fp); |
| 582 |
} |
| 550 |
} |
583 |
} |
| 551 |
if (sensitive_data.host_certificates[i]) { |
584 |
if (sensitive_data.host_certificates |
|
|
585 |
&& sensitive_data.host_certificates[i]) { |
| 552 |
key_free(sensitive_data.host_certificates[i]); |
586 |
key_free(sensitive_data.host_certificates[i]); |
| 553 |
sensitive_data.host_certificates[i] = NULL; |
587 |
sensitive_data.host_certificates[i] = NULL; |
| 554 |
} |
588 |
} |
|
Lines 562-567
void
Link Here
|
| 562 |
demote_sensitive_data(void) |
596 |
demote_sensitive_data(void) |
| 563 |
{ |
597 |
{ |
| 564 |
Key *tmp; |
598 |
Key *tmp; |
|
|
599 |
pid_t pid; |
| 600 |
uid_t uid; |
| 565 |
int i; |
601 |
int i; |
| 566 |
|
602 |
|
| 567 |
if (sensitive_data.server_key) { |
603 |
if (sensitive_data.server_key) { |
|
Lines 570-582
demote_sensitive_data(void)
Link Here
|
| 570 |
sensitive_data.server_key = tmp; |
606 |
sensitive_data.server_key = tmp; |
| 571 |
} |
607 |
} |
| 572 |
|
608 |
|
|
|
609 |
pid = getpid(); |
| 610 |
uid = getuid(); |
| 573 |
for (i = 0; i < options.num_host_key_files; i++) { |
611 |
for (i = 0; i < options.num_host_key_files; i++) { |
| 574 |
if (sensitive_data.host_keys[i]) { |
612 |
if (sensitive_data.host_keys[i]) { |
|
|
613 |
char *fp; |
| 614 |
|
| 615 |
if (key_is_private(sensitive_data.host_keys[i])) |
| 616 |
fp = key_fingerprint(sensitive_data.host_keys[i], |
| 617 |
FIPS_mode() ? SSH_FP_SHA1 : SSH_FP_MD5, |
| 618 |
SSH_FP_HEX); |
| 619 |
else |
| 620 |
fp = NULL; |
| 575 |
tmp = key_demote(sensitive_data.host_keys[i]); |
621 |
tmp = key_demote(sensitive_data.host_keys[i]); |
| 576 |
key_free(sensitive_data.host_keys[i]); |
622 |
key_free(sensitive_data.host_keys[i]); |
| 577 |
sensitive_data.host_keys[i] = tmp; |
623 |
sensitive_data.host_keys[i] = tmp; |
| 578 |
if (tmp->type == KEY_RSA1) |
624 |
if (tmp->type == KEY_RSA1) |
| 579 |
sensitive_data.ssh1_host_key = tmp; |
625 |
sensitive_data.ssh1_host_key = tmp; |
|
|
626 |
if (fp != NULL) { |
| 627 |
audit_destroy_sensitive_data(fp, pid, uid); |
| 628 |
xfree(fp); |
| 629 |
} |
| 580 |
} |
630 |
} |
| 581 |
/* Certs do not need demotion */ |
631 |
/* Certs do not need demotion */ |
| 582 |
} |
632 |
} |
|
Lines 1145-1150
server_accept_loop(int *sock_in, int *so
Link Here
|
| 1145 |
if (received_sigterm) { |
1195 |
if (received_sigterm) { |
| 1146 |
logit("Received signal %d; terminating.", |
1196 |
logit("Received signal %d; terminating.", |
| 1147 |
(int) received_sigterm); |
1197 |
(int) received_sigterm); |
|
|
1198 |
destroy_sensitive_data(0); |
| 1148 |
close_listen_socks(); |
1199 |
close_listen_socks(); |
| 1149 |
unlink(options.pid_file); |
1200 |
unlink(options.pid_file); |
| 1150 |
exit(received_sigterm == SIGTERM ? 0 : 255); |
1201 |
exit(received_sigterm == SIGTERM ? 0 : 255); |
|
Lines 2050-2056
main(int ac, char **av)
Link Here
|
| 2050 |
privsep_postauth(authctxt); |
2101 |
privsep_postauth(authctxt); |
| 2051 |
/* the monitor process [priv] will not return */ |
2102 |
/* the monitor process [priv] will not return */ |
| 2052 |
if (!compat20) |
2103 |
if (!compat20) |
| 2053 |
destroy_sensitive_data(); |
2104 |
destroy_sensitive_data(0); |
| 2054 |
} |
2105 |
} |
| 2055 |
|
2106 |
|
| 2056 |
packet_set_timeout(options.client_alive_interval, |
2107 |
packet_set_timeout(options.client_alive_interval, |
|
Lines 2061-2066
main(int ac, char **av)
Link Here
|
| 2061 |
|
2112 |
|
| 2062 |
/* The connection has been terminated. */ |
2113 |
/* The connection has been terminated. */ |
| 2063 |
packet_destroy_all(1, 1); |
2114 |
packet_destroy_all(1, 1); |
|
|
2115 |
destroy_sensitive_data(1); |
| 2064 |
|
2116 |
|
| 2065 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
2117 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes); |
| 2066 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
2118 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes); |
|
Lines 2289-2295
do_ssh1_kex(void)
Link Here
|
| 2289 |
session_id[i] = session_key[i] ^ session_key[i + 16]; |
2341 |
session_id[i] = session_key[i] ^ session_key[i + 16]; |
| 2290 |
} |
2342 |
} |
| 2291 |
/* Destroy the private and public keys. No longer. */ |
2343 |
/* Destroy the private and public keys. No longer. */ |
| 2292 |
destroy_sensitive_data(); |
2344 |
destroy_sensitive_data(0); |
| 2293 |
|
2345 |
|
| 2294 |
if (use_privsep) |
2346 |
if (use_privsep) |
| 2295 |
mm_ssh1_session_id(session_id); |
2347 |
mm_ssh1_session_id(session_id); |
|
Lines 2392-2397
cleanup_exit(int i)
Link Here
|
| 2392 |
if (the_authctxt) |
2444 |
if (the_authctxt) |
| 2393 |
do_cleanup(the_authctxt); |
2445 |
do_cleanup(the_authctxt); |
| 2394 |
is_privsep_child = use_privsep && pmonitor != NULL && !mm_is_monitor(); |
2446 |
is_privsep_child = use_privsep && pmonitor != NULL && !mm_is_monitor(); |
|
|
2447 |
if (sensitive_data.host_keys != NULL) |
| 2448 |
destroy_sensitive_data(is_privsep_child); |
| 2395 |
packet_destroy_all(1, is_privsep_child); |
2449 |
packet_destroy_all(1, is_privsep_child); |
| 2396 |
#ifdef SSH_AUDIT_EVENTS |
2450 |
#ifdef SSH_AUDIT_EVENTS |
| 2397 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */ |
2451 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */ |