mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 11:10:28 +09:00
Fix server kex again
This commit is contained in:
@@ -218,6 +218,7 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
|
|||||||
/* options.c */
|
/* options.c */
|
||||||
|
|
||||||
char *dir_expand_dup(ssh_session session, const char *value, int allowsshdir);
|
char *dir_expand_dup(ssh_session session, const char *value, int allowsshdir);
|
||||||
|
int ssh_options_set_algo(ssh_session session, int algo, const char *list);
|
||||||
|
|
||||||
/** Free memory space */
|
/** Free memory space */
|
||||||
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
|
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ static char *get_username_from_uid(ssh_session session, uid_t uid){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ssh_options_set_algo(ssh_session session, int algo,
|
int ssh_options_set_algo(ssh_session session, int algo,
|
||||||
const char *list) {
|
const char *list) {
|
||||||
if (!verify_existing_algo(algo, list)) {
|
if (!verify_existing_algo(algo, list)) {
|
||||||
ssh_set_error(session, SSH_REQUEST_DENIED,
|
ssh_set_error(session, SSH_REQUEST_DENIED,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) {
|
|||||||
ssh_set_error(sshbind, SSH_FATAL,"session is null");
|
ssh_set_error(sshbind, SSH_FATAL,"session is null");
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
if (sshbind->dsakey == NULL || sshbind->rsakey == NULL) {
|
if (sshbind->dsakey == NULL && sshbind->rsakey == NULL) {
|
||||||
ssh_set_error(sshbind, SSH_FATAL,
|
ssh_set_error(sshbind, SSH_FATAL,
|
||||||
"DSA or RSA host key file must be set before accept()");
|
"DSA or RSA host key file must be set before accept()");
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
@@ -315,16 +315,16 @@ static int server_set_kex(ssh_session session) {
|
|||||||
ZERO_STRUCTP(server);
|
ZERO_STRUCTP(server);
|
||||||
ssh_get_random(server->cookie, 16, 0);
|
ssh_get_random(server->cookie, 16, 0);
|
||||||
if (session->dsa_key != NULL && session->rsa_key != NULL) {
|
if (session->dsa_key != NULL && session->rsa_key != NULL) {
|
||||||
if (ssh_options_set(session, SSH_BIND_OPTIONS_HOSTKEY,
|
if (ssh_options_set_algo(session, SSH_HOSTKEYS,
|
||||||
"ssh-dss,ssh-rsa") < 0) {
|
"ssh-dss,ssh-rsa") < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (session->dsa_key != NULL) {
|
} else if (session->dsa_key != NULL) {
|
||||||
if (ssh_options_set(session, SSH_BIND_OPTIONS_HOSTKEY, "ssh-dss") < 0) {
|
if (ssh_options_set_algo(session, SSH_HOSTKEYS, "ssh-dss") < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ssh_options_set(session, SSH_BIND_OPTIONS_HOSTKEY, "ssh-rsa") < 0) {
|
if (ssh_options_set_algo(session, SSH_HOSTKEYS, "ssh-rsa") < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user