mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
Fixed ssh_options_copy().
This commit is contained in:
@@ -383,7 +383,7 @@ LIBSSH_API int ssh_message_type(ssh_message msg);
|
|||||||
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
|
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
|
||||||
LIBSSH_API ssh_session ssh_new(void);
|
LIBSSH_API ssh_session ssh_new(void);
|
||||||
|
|
||||||
LIBSSH_API ssh_options ssh_options_copy(ssh_options opt);
|
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
|
||||||
LIBSSH_API int ssh_options_getopt(ssh_options options, int *argcptr, char **argv);
|
LIBSSH_API int ssh_options_getopt(ssh_options options, int *argcptr, char **argv);
|
||||||
LIBSSH_API int ssh_options_parse_config(ssh_options opt, const char *filename);
|
LIBSSH_API int ssh_options_parse_config(ssh_options opt, const char *filename);
|
||||||
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
|
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Duplicate an option structure.
|
* @brief Duplicate the options of a session structure.
|
||||||
*
|
*
|
||||||
* If you make several sessions with the same options this is useful. You
|
* If you make several sessions with the same options this is useful. You
|
||||||
* cannot use twice the same option structure in ssh_session_connect.
|
* cannot use twice the same option structure in ssh_session_connect.
|
||||||
@@ -51,92 +51,71 @@
|
|||||||
*
|
*
|
||||||
* @see ssh_session_connect()
|
* @see ssh_session_connect()
|
||||||
*/
|
*/
|
||||||
#if 0
|
int ssh_options_copy(ssh_session src, ssh_session *dest) {
|
||||||
ssh_session ssh_session_copy(ssh_options opt) {
|
ssh_session new;
|
||||||
ssh_session new = NULL;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (session == NULL) {
|
if (src == NULL || dest == NULL || *dest == NULL) {
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = ssh_session_new();
|
new = *dest;
|
||||||
if (new == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session->username) {
|
if (src->username) {
|
||||||
new->username = strdup(session->username);
|
new->username = strdup(src->username);
|
||||||
if (new->username == NULL) {
|
if (new->username == NULL) {
|
||||||
goto err;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session->host) {
|
|
||||||
new->host = strdup(session->host);
|
if (src->host) {
|
||||||
|
new->host = strdup(src->host);
|
||||||
if (new->host == NULL) {
|
if (new->host == NULL) {
|
||||||
goto err;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session->bindaddr) {
|
|
||||||
new->bindaddr = strdup(session->bindaddr);
|
if (src->identity) {
|
||||||
if (new->bindaddr == NULL) {
|
new->identity = strdup(src->identity);
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (session->identity) {
|
|
||||||
new->identity=strdup(session->identity);
|
|
||||||
if (new->identity == NULL) {
|
if (new->identity == NULL) {
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session->sshdir) {
|
|
||||||
new->ssh_dir = strdup(session->sshdir);
|
if (src->sshdir) {
|
||||||
|
new->sshdir = strdup(src->sshdir);
|
||||||
if (new->sshdir == NULL) {
|
if (new->sshdir == NULL) {
|
||||||
goto err;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (session->knownhosts) {
|
|
||||||
new->knownhosts = strdup(session->knownhosts);
|
if (src->knownhosts) {
|
||||||
|
new->knownhosts = strdup(src->knownhosts);
|
||||||
if (new->knownhosts == NULL) {
|
if (new->knownhosts == NULL) {
|
||||||
goto err;
|
return -1;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (session->dsakey) {
|
|
||||||
new->dsakey = strdup(session->dsakey);
|
|
||||||
if (new->dsakey == NULL) {
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (session->rsakey) {
|
|
||||||
new->rsakey = strdup(session->rsakey);
|
|
||||||
if (new->rsakey == NULL) {
|
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 10; ++i) {
|
for (i = 0; i < 10; ++i) {
|
||||||
if (session->wanted_methods[i]) {
|
if (src->wanted_methods[i]) {
|
||||||
new->wanted_methods[i] = strdup(session->wanted_methods[i]);
|
new->wanted_methods[i] = strdup(src->wanted_methods[i]);
|
||||||
if (new->wanted_methods[i] == NULL) {
|
if (new->wanted_methods[i] == NULL) {
|
||||||
goto err;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new->fd = session->fd;
|
new->fd = src->fd;
|
||||||
new->port = session->port;
|
new->port = src->port;
|
||||||
new->callbacks = session->callbacks;
|
new->callbacks = src->callbacks;
|
||||||
new->timeout = session->timeout;
|
new->timeout = src->timeout;
|
||||||
new->timeout_usec = session->timeout_usec;
|
new->timeout_usec = src->timeout_usec;
|
||||||
new->ssh2 = session->ssh2;
|
new->ssh2 = src->ssh2;
|
||||||
new->ssh1 = session->ssh1;
|
new->ssh1 = src->ssh1;
|
||||||
new->log_verbosity = session->log_verbosity;
|
new->log_verbosity = src->log_verbosity;
|
||||||
|
|
||||||
return new;
|
return 0;
|
||||||
err:
|
|
||||||
ssh_session_free(new);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static char *get_username_from_uid(ssh_session session, uid_t uid){
|
static char *get_username_from_uid(ssh_session session, uid_t uid){
|
||||||
|
|||||||
Reference in New Issue
Block a user