Skip to content

Commit

Permalink
session BUGFIX missing ssh_init()
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed May 3, 2024
1 parent 581fe3b commit 5788c80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/session_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include <sys/un.h>
#include <unistd.h>

#ifdef NC_ENABLED_SSH_TLS
#include <libssh/libssh.h>
#endif
#include <libyang/libyang.h>

#include "compat.h"
Expand Down Expand Up @@ -1917,6 +1920,13 @@ nc_client_init(void)
return -1;
}

#ifdef NC_ENABLED_SSH_TLS
if (ssh_init()) {
ERR(NULL, "%s: failed to init libssh.", __func__);
return -1;
}
#endif

return 0;
}

Expand All @@ -1929,6 +1939,7 @@ nc_client_destroy(void)
nc_client_ch_del_bind(NULL, 0, 0);
nc_client_ssh_destroy_opts();
nc_client_tls_destroy_opts();
ssh_finalize();
#endif /* NC_ENABLED_SSH_TLS */
}

Expand Down
8 changes: 8 additions & 0 deletions src/session_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#ifdef NC_ENABLED_SSH_TLS
#include <curl/curl.h>
#include <libssh/libssh.h>
#endif

#include "compat.h"
Expand Down Expand Up @@ -809,6 +810,12 @@ nc_server_init(void)
ERR(NULL, "%s: failed to init CURL.", __func__);
goto error;
}

/* optional for dynamic library, mandatory for static */
if (ssh_init()) {
ERR(NULL, "%s: failed to init libssh.", __func__);
goto error;
}
#endif

if ((r = pthread_mutex_init(&server_opts.bind_lock, NULL))) {
Expand Down Expand Up @@ -866,6 +873,7 @@ nc_server_destroy(void)
nc_server_config_ks_keystore(NULL, NC_OP_DELETE);
nc_server_config_ts_truststore(NULL, NC_OP_DELETE);
curl_global_cleanup();
ssh_finalize();
#endif /* NC_ENABLED_SSH_TLS */
}

Expand Down

0 comments on commit 5788c80

Please sign in to comment.