version 1.104, 2001/03/08 21:42:32 |
version 1.105, 2001/03/26 08:07:09 |
|
|
*/ |
*/ |
volatile int received_window_change_signal = 0; |
volatile int received_window_change_signal = 0; |
|
|
/* Flag indicating whether we have a valid host private key loaded. */ |
|
int host_private_key_loaded = 0; |
|
|
|
/* Host private key. */ |
/* Host private key. */ |
RSA *host_private_key = NULL; |
Key *host_private_key = NULL; |
|
|
/* Original real UID. */ |
/* Original real UID. */ |
uid_t original_real_uid; |
uid_t original_real_uid; |
|
|
* privileges, because the file is only readable by root. |
* privileges, because the file is only readable by root. |
*/ |
*/ |
if (ok && (options.protocol & SSH_PROTO_1)) { |
if (ok && (options.protocol & SSH_PROTO_1)) { |
Key k; |
host_private_key = key_load_private_type(KEY_RSA1, |
host_private_key = RSA_new(); |
_PATH_HOST_KEY_FILE, "", NULL); |
k.type = KEY_RSA1; |
|
k.rsa = host_private_key; |
|
if (load_private_key(_PATH_HOST_KEY_FILE, "", &k, NULL)) |
|
host_private_key_loaded = 1; |
|
} |
} |
/* |
/* |
* Get rid of any extra privileges that we may have. We will no |
* Get rid of any extra privileges that we may have. We will no |
|
|
tilde_expand_filename(options.user_hostfile2, original_real_uid); |
tilde_expand_filename(options.user_hostfile2, original_real_uid); |
|
|
/* Log into the remote system. This never returns if the login fails. */ |
/* Log into the remote system. This never returns if the login fails. */ |
ssh_login(host_private_key_loaded, host_private_key, |
ssh_login(host_private_key, host, (struct sockaddr *)&hostaddr, |
host, (struct sockaddr *)&hostaddr, original_real_uid); |
original_real_uid); |
|
|
/* We no longer need the host private key. Clear it now. */ |
/* We no longer need the host private key. Clear it now. */ |
if (host_private_key_loaded) |
if (host_private_key != NULL) |
RSA_free(host_private_key); /* Destroys contents safely */ |
key_free(host_private_key); /* Destroys contents safely */ |
|
|
exit_status = compat20 ? ssh_session2() : ssh_session(); |
exit_status = compat20 ? ssh_session2() : ssh_session(); |
packet_close(); |
packet_close(); |
|
|
return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id); |
return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id); |
} |
} |
|
|
int |
|
guess_identity_file_type(const char *filename) |
|
{ |
|
struct stat st; |
|
Key *public; |
|
int type = KEY_RSA1; /* default */ |
|
|
|
if (stat(filename, &st) < 0) { |
|
/* ignore this key */ |
|
return KEY_UNSPEC; |
|
} |
|
public = key_new(type); |
|
if (!load_public_key(filename, public, NULL)) { |
|
/* ok, so we will assume this is 'some' key */ |
|
type = KEY_UNSPEC; |
|
} |
|
key_free(public); |
|
return type; |
|
} |
|
|
|
void |
void |
load_public_identity_files(void) |
load_public_identity_files(void) |
{ |
{ |
|
|
for (i = 0; i < options.num_identity_files; i++) { |
for (i = 0; i < options.num_identity_files; i++) { |
filename = tilde_expand_filename(options.identity_files[i], |
filename = tilde_expand_filename(options.identity_files[i], |
original_real_uid); |
original_real_uid); |
public = key_new(KEY_RSA1); |
public = key_load_public(filename, NULL); |
if (!load_public_key(filename, public, NULL)) { |
|
key_free(public); |
|
public = key_new(KEY_UNSPEC); |
|
if (!try_load_public_key(filename, public, NULL)) { |
|
debug("unknown identity file %s", filename); |
|
key_free(public); |
|
public = NULL; |
|
} |
|
} |
|
debug("identity file %s type %d", filename, |
debug("identity file %s type %d", filename, |
public ? public->type : -1); |
public ? public->type : -1); |
xfree(options.identity_files[i]); |
xfree(options.identity_files[i]); |