mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 20:30:38 +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 *pubkey_accepted_types;
|
||||
char *ProxyCommand;
|
||||
char *custombanner;
|
||||
char *moduli_file;
|
||||
char *agent_socket;
|
||||
unsigned long timeout; /* seconds */
|
||||
unsigned long timeout_usec;
|
||||
@@ -272,6 +270,13 @@ struct ssh_session_struct {
|
||||
int control_master;
|
||||
char *control_path;
|
||||
} opts;
|
||||
|
||||
/* server options */
|
||||
struct {
|
||||
char *custombanner;
|
||||
char *moduli_file;
|
||||
} server_opts;
|
||||
|
||||
/* counters */
|
||||
ssh_counter socket_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;
|
||||
|
||||
if (sshbind->banner != NULL) {
|
||||
session->opts.custombanner = strdup(sshbind->banner);
|
||||
if (session->opts.custombanner == NULL) {
|
||||
session->server_opts.custombanner = strdup(sshbind->banner);
|
||||
if (session->server_opts.custombanner == NULL) {
|
||||
ssh_set_error_oom(sshbind);
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (sshbind->moduli_file != NULL) {
|
||||
session->opts.moduli_file = strdup(sshbind->moduli_file);
|
||||
if (session->opts.moduli_file == NULL) {
|
||||
session->server_opts.moduli_file = strdup(sshbind->moduli_file);
|
||||
if (session->server_opts.moduli_file == NULL) {
|
||||
ssh_set_error_oom(sshbind);
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
@@ -185,13 +185,13 @@ int ssh_send_banner(ssh_session session, int server)
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
if (server == 1) {
|
||||
if (session->opts.custombanner == NULL){
|
||||
if (session->server_opts.custombanner == NULL) {
|
||||
session->serverbanner = strdup(banner);
|
||||
if (session->serverbanner == NULL) {
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
len = strlen(session->opts.custombanner);
|
||||
len = strlen(session->server_opts.custombanner);
|
||||
session->serverbanner = malloc(len + 8 + 1);
|
||||
if(session->serverbanner == NULL) {
|
||||
goto end;
|
||||
@@ -199,7 +199,7 @@ int ssh_send_banner(ssh_session session, int server)
|
||||
snprintf(session->serverbanner,
|
||||
len + 8 + 1,
|
||||
"SSH-2.0-%s",
|
||||
session->opts.custombanner);
|
||||
session->server_opts.custombanner);
|
||||
}
|
||||
|
||||
snprintf(buffer,
|
||||
|
||||
@@ -643,7 +643,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dhgex_request)
|
||||
pn = pmin;
|
||||
}
|
||||
}
|
||||
rc = ssh_retrieve_dhgroup(session->opts.moduli_file,
|
||||
rc = ssh_retrieve_dhgroup(session->server_opts.moduli_file,
|
||||
pmin,
|
||||
pn,
|
||||
pmax,
|
||||
|
||||
@@ -339,8 +339,6 @@ void ssh_free(ssh_session session)
|
||||
|
||||
SAFE_FREE(session->opts.agent_socket);
|
||||
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.host);
|
||||
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();
|
||||
|
||||
/* burn connection, it could contain sensitive data */
|
||||
|
||||
Reference in New Issue
Block a user