1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

options: Allow avoiding system-wide configuration

The added option SSH_BIND_OPTIONS_PROCESS_CONFIG allows to skip
processing the system-wide configuration file.  The global configuration
file is processed automatically if this option is not set as false.

This option will only be effective if set before any call to
ssh_bind_options_parse_config().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Anderson Toshiyuki Sasaki
2019-05-16 13:20:27 +02:00
committed by Andreas Schneider
parent 07faf95a10
commit 79f0c38fbd
3 changed files with 29 additions and 9 deletions

View File

@@ -132,7 +132,6 @@ static socket_t bind_socket(ssh_bind sshbind, const char *hostname,
ssh_bind ssh_bind_new(void) {
ssh_bind ptr;
int rc;
ptr = calloc(1, sizeof(struct ssh_bind_struct));
if (ptr == NULL) {
@@ -142,13 +141,6 @@ ssh_bind ssh_bind_new(void) {
ptr->bindport = 22;
ptr->common.log_verbosity = 0;
/* Apply global bind configurations */
rc = ssh_bind_options_parse_config(ptr, NULL);
if (rc != 0) {
ssh_bind_free(ptr);
ptr = NULL;
}
return ptr;
}
@@ -431,14 +423,25 @@ void ssh_bind_free(ssh_bind sshbind){
int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd){
int i, rc;
if (sshbind == NULL) {
return SSH_ERROR;
}
if (session == NULL){
ssh_set_error(sshbind, SSH_FATAL,"session is null");
return SSH_ERROR;
}
/* Apply global bind configurations, if it hasn't been applied before */
rc = ssh_bind_options_parse_config(sshbind, NULL);
if (rc != 0) {
ssh_set_error(sshbind, SSH_FATAL,"Could not parse global config");
return SSH_ERROR;
}
session->server = 1;
/* copy options */
/* Copy options from bind to session */
for (i = 0; i < 10; i++) {
if (sshbind->wanted_methods[i]) {
session->opts.wanted_methods[i] = strdup(sshbind->wanted_methods[i]);