mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
refactor: wrap and move server session options in a new struct
Signed-off-by: Francesco Rollo <eferollo@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
committed by
Sahana Prasad
parent
6c59d975ba
commit
b4ed60024b
@@ -248,8 +248,6 @@ struct ssh_session_struct {
|
|||||||
char *wanted_methods[SSH_KEX_METHODS];
|
char *wanted_methods[SSH_KEX_METHODS];
|
||||||
char *pubkey_accepted_types;
|
char *pubkey_accepted_types;
|
||||||
char *ProxyCommand;
|
char *ProxyCommand;
|
||||||
char *custombanner;
|
|
||||||
char *moduli_file;
|
|
||||||
char *agent_socket;
|
char *agent_socket;
|
||||||
unsigned long timeout; /* seconds */
|
unsigned long timeout; /* seconds */
|
||||||
unsigned long timeout_usec;
|
unsigned long timeout_usec;
|
||||||
@@ -272,6 +270,13 @@ struct ssh_session_struct {
|
|||||||
int control_master;
|
int control_master;
|
||||||
char *control_path;
|
char *control_path;
|
||||||
} opts;
|
} opts;
|
||||||
|
|
||||||
|
/* server options */
|
||||||
|
struct {
|
||||||
|
char *custombanner;
|
||||||
|
char *moduli_file;
|
||||||
|
} server_opts;
|
||||||
|
|
||||||
/* counters */
|
/* counters */
|
||||||
ssh_counter socket_counter;
|
ssh_counter socket_counter;
|
||||||
ssh_counter raw_counter;
|
ssh_counter raw_counter;
|
||||||
|
|||||||
@@ -480,16 +480,16 @@ int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd)
|
|||||||
session->common.log_verbosity = sshbind->common.log_verbosity;
|
session->common.log_verbosity = sshbind->common.log_verbosity;
|
||||||
|
|
||||||
if (sshbind->banner != NULL) {
|
if (sshbind->banner != NULL) {
|
||||||
session->opts.custombanner = strdup(sshbind->banner);
|
session->server_opts.custombanner = strdup(sshbind->banner);
|
||||||
if (session->opts.custombanner == NULL) {
|
if (session->server_opts.custombanner == NULL) {
|
||||||
ssh_set_error_oom(sshbind);
|
ssh_set_error_oom(sshbind);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sshbind->moduli_file != NULL) {
|
if (sshbind->moduli_file != NULL) {
|
||||||
session->opts.moduli_file = strdup(sshbind->moduli_file);
|
session->server_opts.moduli_file = strdup(sshbind->moduli_file);
|
||||||
if (session->opts.moduli_file == NULL) {
|
if (session->server_opts.moduli_file == NULL) {
|
||||||
ssh_set_error_oom(sshbind);
|
ssh_set_error_oom(sshbind);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,13 +185,13 @@ int ssh_send_banner(ssh_session session, int server)
|
|||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
if (server == 1) {
|
if (server == 1) {
|
||||||
if (session->opts.custombanner == NULL){
|
if (session->server_opts.custombanner == NULL) {
|
||||||
session->serverbanner = strdup(banner);
|
session->serverbanner = strdup(banner);
|
||||||
if (session->serverbanner == NULL) {
|
if (session->serverbanner == NULL) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
len = strlen(session->opts.custombanner);
|
len = strlen(session->server_opts.custombanner);
|
||||||
session->serverbanner = malloc(len + 8 + 1);
|
session->serverbanner = malloc(len + 8 + 1);
|
||||||
if(session->serverbanner == NULL) {
|
if(session->serverbanner == NULL) {
|
||||||
goto end;
|
goto end;
|
||||||
@@ -199,7 +199,7 @@ int ssh_send_banner(ssh_session session, int server)
|
|||||||
snprintf(session->serverbanner,
|
snprintf(session->serverbanner,
|
||||||
len + 8 + 1,
|
len + 8 + 1,
|
||||||
"SSH-2.0-%s",
|
"SSH-2.0-%s",
|
||||||
session->opts.custombanner);
|
session->server_opts.custombanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buffer,
|
snprintf(buffer,
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dhgex_request)
|
|||||||
pn = pmin;
|
pn = pmin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = ssh_retrieve_dhgroup(session->opts.moduli_file,
|
rc = ssh_retrieve_dhgroup(session->server_opts.moduli_file,
|
||||||
pmin,
|
pmin,
|
||||||
pn,
|
pn,
|
||||||
pmax,
|
pmax,
|
||||||
|
|||||||
@@ -339,8 +339,6 @@ void ssh_free(ssh_session session)
|
|||||||
|
|
||||||
SAFE_FREE(session->opts.agent_socket);
|
SAFE_FREE(session->opts.agent_socket);
|
||||||
SAFE_FREE(session->opts.bindaddr);
|
SAFE_FREE(session->opts.bindaddr);
|
||||||
SAFE_FREE(session->opts.custombanner);
|
|
||||||
SAFE_FREE(session->opts.moduli_file);
|
|
||||||
SAFE_FREE(session->opts.username);
|
SAFE_FREE(session->opts.username);
|
||||||
SAFE_FREE(session->opts.host);
|
SAFE_FREE(session->opts.host);
|
||||||
SAFE_FREE(session->opts.sshdir);
|
SAFE_FREE(session->opts.sshdir);
|
||||||
@@ -358,6 +356,9 @@ void ssh_free(ssh_session session)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SAFE_FREE(session->server_opts.custombanner);
|
||||||
|
SAFE_FREE(session->server_opts.moduli_file);
|
||||||
|
|
||||||
_ssh_remove_legacy_log_cb();
|
_ssh_remove_legacy_log_cb();
|
||||||
|
|
||||||
/* burn connection, it could contain sensitive data */
|
/* burn connection, it could contain sensitive data */
|
||||||
|
|||||||
Reference in New Issue
Block a user