diff options
-rw-r--r-- | include/libssh/callback.h | 6 | ||||
-rw-r--r-- | include/libssh/libssh.h | 46 | ||||
-rw-r--r-- | include/libssh/priv.h | 10 | ||||
-rw-r--r-- | include/libssh/server.h | 2 | ||||
-rw-r--r-- | libssh/client.c | 2 | ||||
-rw-r--r-- | libssh/kex.c | 2 | ||||
-rw-r--r-- | libssh/options.c | 63 | ||||
-rw-r--r-- | libssh/server.c | 4 | ||||
-rw-r--r-- | libssh/session.c | 2 | ||||
-rw-r--r-- | sample.c | 2 | ||||
-rw-r--r-- | samplesshd.c | 2 |
11 files changed, 70 insertions, 71 deletions
diff --git a/include/libssh/callback.h b/include/libssh/callback.h index fd60bc10..00a41d38 100644 --- a/include/libssh/callback.h +++ b/include/libssh/callback.h @@ -60,10 +60,10 @@ typedef struct ssh_callbacks_struct * ssh_callbacks; p->size=sizeof(*p); \ } while(0); -LIBSSH_API int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb, +LIBSSH_API int ssh_options_set_auth_callback(ssh_options opt, ssh_auth_callback cb, void *userdata); -LIBSSH_API int ssh_options_set_log_function(SSH_OPTIONS *opt, +LIBSSH_API int ssh_options_set_log_function(ssh_options opt, ssh_log_callback cb, void *userdata); -LIBSSH_API int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback) +LIBSSH_API int ssh_options_set_status_callback(ssh_options opt, void (*callback) (void *arg, float status), void *arg); #endif /*_SSH_CALLBACK_H */ diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 21dfb268..d87f70c8 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -370,30 +370,30 @@ LIBSSH_API int ssh_message_subtype(SSH_MESSAGE *msg); LIBSSH_API int ssh_message_type(SSH_MESSAGE *msg); LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode); LIBSSH_API ssh_session ssh_new(void); -LIBSSH_API SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt); -LIBSSH_API void ssh_options_free(SSH_OPTIONS *opt); -LIBSSH_API SSH_OPTIONS *ssh_options_new(void); - -LIBSSH_API int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow); -LIBSSH_API int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow); -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 ssh_options ssh_options_copy(ssh_options opt); +LIBSSH_API void ssh_options_free(ssh_options opt); +LIBSSH_API ssh_options ssh_options_new(void); + +LIBSSH_API int ssh_options_allow_ssh1(ssh_options opt, int allow); +LIBSSH_API int ssh_options_allow_ssh2(ssh_options opt, int allow); +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_set(ssh_options opt, enum ssh_options_e type, const void *value); -LIBSSH_API int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner); -LIBSSH_API int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port); -LIBSSH_API int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey); -LIBSSH_API int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd); -LIBSSH_API int ssh_options_set_host(SSH_OPTIONS *opt, const char *host); -LIBSSH_API int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity); -LIBSSH_API int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity); -LIBSSH_API int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir); -LIBSSH_API int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port); -LIBSSH_API int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey); -LIBSSH_API int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir); -LIBSSH_API int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec); -LIBSSH_API int ssh_options_set_username(SSH_OPTIONS *opt, const char *username); -LIBSSH_API int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list); +LIBSSH_API int ssh_options_set_banner(ssh_options opt, const char *banner); +LIBSSH_API int ssh_options_set_bind(ssh_options opt, const char *bindaddr, int port); +LIBSSH_API int ssh_options_set_dsa_server_key(ssh_options opt, const char *dsakey); +LIBSSH_API int ssh_options_set_fd(ssh_options opt, socket_t fd); +LIBSSH_API int ssh_options_set_host(ssh_options opt, const char *host); +LIBSSH_API int ssh_options_set_identity(ssh_options opt, const char *identity); +LIBSSH_API int ssh_options_set_log_verbosity(ssh_options opt, int verbosity); +LIBSSH_API int ssh_options_set_known_hosts_file(ssh_options opt, const char *dir); +LIBSSH_API int ssh_options_set_port(ssh_options opt, unsigned int port); +LIBSSH_API int ssh_options_set_rsa_server_key(ssh_options opt, const char *rsakey); +LIBSSH_API int ssh_options_set_ssh_dir(ssh_options opt, const char *dir); +LIBSSH_API int ssh_options_set_timeout(ssh_options opt, long seconds, long usec); +LIBSSH_API int ssh_options_set_username(ssh_options opt, const char *username); +LIBSSH_API int ssh_options_set_wanted_algos(ssh_options opt, int algo, const char *list); LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len); LIBSSH_API int ssh_scp_accept_request(ssh_scp scp); LIBSSH_API int ssh_scp_close(ssh_scp scp); @@ -418,7 +418,7 @@ LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking); LIBSSH_API void ssh_set_fd_except(ssh_session session); LIBSSH_API void ssh_set_fd_toread(ssh_session session); LIBSSH_API void ssh_set_fd_towrite(ssh_session session); -LIBSSH_API void ssh_set_options(ssh_session session, SSH_OPTIONS *options); +LIBSSH_API void ssh_set_options(ssh_session session, ssh_options options); LIBSSH_API void ssh_silent_disconnect(ssh_session session); #ifndef _WIN32 LIBSSH_API int ssh_userauth_agent_pubkey(ssh_session session, const char *username, diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 83e44735..3fe5fa39 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -383,7 +383,7 @@ struct ssh_message_struct; struct ssh_session_struct { struct error_struct error; struct socket *socket; - SSH_OPTIONS *options; + ssh_options options; char *serverbanner; char *clientbanner; int protoversion; @@ -463,7 +463,7 @@ struct ssh_kbdint_struct { struct ssh_bind_struct { struct error_struct error; socket_t bindfd; - SSH_OPTIONS *options; + ssh_options options; int blocking; int toaccept; }; @@ -747,9 +747,9 @@ int channel_write_common(ssh_channel channel, const void *data, /* options.c */ /* this function must be called when no specific username has been asked. it has to guess it */ -int ssh_options_default_username(SSH_OPTIONS *opt); -int ssh_options_default_ssh_dir(SSH_OPTIONS *opt); -int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt); +int ssh_options_default_username(ssh_options opt); +int ssh_options_default_ssh_dir(ssh_options opt); +int ssh_options_default_known_hosts_file(ssh_options opt); /* buffer.c */ int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); diff --git a/include/libssh/server.h b/include/libssh/server.h index fefee1b0..afe3f49c 100644 --- a/include/libssh/server.h +++ b/include/libssh/server.h @@ -51,7 +51,7 @@ LIBSSH_API SSH_BIND *ssh_bind_new(void); * * @param options The option structure to set. */ -LIBSSH_API void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options); +LIBSSH_API void ssh_bind_set_options(SSH_BIND *ssh_bind, ssh_options options); /** * @brief Start listening to the socket. diff --git a/libssh/client.c b/libssh/client.c index b29f8329..5844095a 100644 --- a/libssh/client.c +++ b/libssh/client.c @@ -470,7 +470,7 @@ int ssh_service_request(ssh_session session, const char *service) { * \see ssh_disconnect() */ int ssh_connect(ssh_session session) { - SSH_OPTIONS *options = session->options; + ssh_options options = session->options; int ssh1 = 0; int ssh2 = 0; int fd = -1; diff --git a/libssh/kex.c b/libssh/kex.c index 52376668..95468c4a 100644 --- a/libssh/kex.c +++ b/libssh/kex.c @@ -331,7 +331,7 @@ void ssh_list_kex(ssh_session session, KEX *kex) { int set_kex(ssh_session session){ KEX *server = &session->server_kex; KEX *client=&session->client_kex; - SSH_OPTIONS *options=session->options; + ssh_options options=session->options; int i; const char *wanted; enter_function(); diff --git a/libssh/options.c b/libssh/options.c index 56f18400..63156c5d 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -49,15 +49,14 @@ * \see ssh_options_getopt() */ -SSH_OPTIONS *ssh_options_new(void) { - SSH_OPTIONS *option; +ssh_options ssh_options_new(void) { + ssh_options option; - option = malloc(sizeof(SSH_OPTIONS)); + option = malloc(sizeof(struct ssh_options_struct)); if (option == NULL) { return NULL; } - - memset(option,0,sizeof(SSH_OPTIONS)); + ZERO_STRUCTP(option); option->port=22; /* set the default port */ option->fd=-1; option->ssh2allowed=1; @@ -82,8 +81,8 @@ SSH_OPTIONS *ssh_options_new(void) { * * @see ssh_session_connect() */ -SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt) { - SSH_OPTIONS *new = NULL; +ssh_options ssh_options_copy(ssh_options opt) { + ssh_options new = NULL; int i; if (opt == NULL) { @@ -172,7 +171,7 @@ err: * * @param opt Option structure to free. */ -void ssh_options_free(SSH_OPTIONS *opt) { +void ssh_options_free(ssh_options opt) { int i; if (opt == NULL) { @@ -203,7 +202,7 @@ void ssh_options_free(SSH_OPTIONS *opt) { } #ifndef _WIN32 -static char *get_username_from_uid(SSH_OPTIONS *opt, uid_t uid){ +static char *get_username_from_uid(ssh_options opt, uid_t uid){ struct passwd *pwd = NULL; pwd = getpwuid(uid); @@ -672,7 +671,7 @@ int ssh_options_set(ssh_options opt, enum ssh_options_e type, * * @return 0 on succes, < 0 on error. */ -int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){ +int ssh_options_set_host(ssh_options opt, const char *hostname){ return ssh_options_set(opt, SSH_OPTIONS_HOST, hostname); } @@ -685,7 +684,7 @@ int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){ * * @return 0 on success, < 0 on error. */ -int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port) { +int ssh_options_set_port(ssh_options opt, unsigned int port) { return ssh_options_set(opt, SSH_OPTIONS_PORT, &port); } @@ -700,7 +699,7 @@ int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port) { * * @bug this should not be set at options time */ -int ssh_options_set_username(SSH_OPTIONS *opt, const char *username) { +int ssh_options_set_username(ssh_options opt, const char *username) { return ssh_options_set(opt, SSH_OPTIONS_USER, username); } @@ -717,7 +716,7 @@ int ssh_options_set_username(SSH_OPTIONS *opt, const char *username) { * * @return 0 on success, < 0 on error. */ -int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd) { +int ssh_options_set_fd(ssh_options opt, socket_t fd) { return ssh_options_set(opt, SSH_OPTIONS_FD, &fd); } @@ -736,7 +735,7 @@ int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd) { * * @return 0 on success, < 0 on error. */ -int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) { +int ssh_options_set_bind(ssh_options opt, const char *bindaddr, int port) { int rc; rc = ssh_options_set(opt, SSH_OPTIONS_SERVER_BINDADDR, bindaddr); @@ -763,7 +762,7 @@ int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) { * * @see ssh_options_set_user_home_dir() */ -int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir) { +int ssh_options_set_ssh_dir(ssh_options opt, const char *dir) { return ssh_options_set(opt, SSH_OPTIONS_SSH_DIR, dir); } @@ -781,7 +780,7 @@ int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir) { * * @see ssh_options_set_user_home_dir() */ -int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir){ +int ssh_options_set_known_hosts_file(ssh_options opt, const char *dir){ return ssh_options_set(opt, SSH_OPTIONS_KNOWNHOSTS, dir); } @@ -799,7 +798,7 @@ int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir){ * * @see ssh_options_set_user_home_dir() */ -int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity){ +int ssh_options_set_identity(ssh_options opt, const char *identity){ return ssh_options_set(opt, SSH_OPTIONS_IDENTITY, identity); } @@ -812,7 +811,7 @@ int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity){ * * @return 0 on success, < 0 on error. */ -int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey) { +int ssh_options_set_dsa_server_key(ssh_options opt, const char *dsakey) { return ssh_options_set(opt, SSH_OPTIONS_SERVER_DSAKEY, dsakey); } @@ -825,7 +824,7 @@ int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey) { * * @return 0 on success, < 0 on error. */ -int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey) { +int ssh_options_set_rsa_server_key(ssh_options opt, const char *rsakey) { return ssh_options_set(opt, SSH_OPTIONS_SERVER_RSAKEY, rsakey); } @@ -838,7 +837,7 @@ int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey) { * * @return 0 on success, < 0 on error. */ -int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner) { +int ssh_options_set_banner(ssh_options opt, const char *banner) { return ssh_options_set(opt, SSH_OPTIONS_SERVER_BANNER, banner); } @@ -867,7 +866,7 @@ int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner) { * * @return 0 on success, < 0 on error */ -int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list) { +int ssh_options_set_wanted_algos(ssh_options opt, int algo, const char *list) { if (opt == NULL || list == NULL) { return -1; } @@ -893,15 +892,15 @@ int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list) { } /* this function must be called when no specific username has been asked. it has to guess it */ -int ssh_options_default_username(SSH_OPTIONS *opt) { +int ssh_options_default_username(ssh_options opt) { return ssh_options_set(opt, SSH_OPTIONS_USER, NULL); } -int ssh_options_default_ssh_dir(SSH_OPTIONS *opt) { +int ssh_options_default_ssh_dir(ssh_options opt) { return ssh_options_set(opt, SSH_OPTIONS_SSH_DIR, NULL); } -int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt) { +int ssh_options_default_known_hosts_file(ssh_options opt) { return ssh_options_set(opt, SSH_OPTIONS_KNOWNHOSTS, NULL); } @@ -923,7 +922,7 @@ int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt) { * * @see ssh_connect() */ -int ssh_options_set_status_callback(SSH_OPTIONS *opt, +int ssh_options_set_status_callback(ssh_options opt, void (*callback)(void *arg, float status), void *arg) { if (opt == NULL || callback == NULL || opt->callbacks==NULL) { return -1; @@ -950,7 +949,7 @@ int ssh_options_set_status_callback(SSH_OPTIONS *opt, * @bug Currently it only timeouts the socket connection, not the * complete exchange. */ -int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec) { +int ssh_options_set_timeout(ssh_options opt, long seconds, long usec) { if (ssh_options_set(opt, SSH_OPTIONS_TIMEOUT, &seconds) < 0) { return -1; } @@ -969,7 +968,7 @@ int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec) { * * @return 0 on success, < 0 on error. */ -int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow) { +int ssh_options_allow_ssh1(ssh_options opt, int allow) { return ssh_options_set(opt, SSH_OPTIONS_SSH1, &allow); } @@ -984,7 +983,7 @@ int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow) { * * @return 0 on success, < 0 on error. */ -int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow) { +int ssh_options_allow_ssh2(ssh_options opt, int allow) { return ssh_options_set(opt, SSH_OPTIONS_SSH2, &allow); } @@ -1001,7 +1000,7 @@ int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow) { * * @warning The message string may contain format string characters. */ -int ssh_options_set_log_function(SSH_OPTIONS *opt, ssh_log_callback cb, +int ssh_options_set_log_function(ssh_options opt, ssh_log_callback cb, void *userdata) { if (opt == NULL || cb == NULL || opt->callbacks==NULL) { return -1; @@ -1029,7 +1028,7 @@ int ssh_options_set_log_function(SSH_OPTIONS *opt, ssh_log_callback cb, * * @return 0 on success, < 0 on error. */ -int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity) { +int ssh_options_set_log_verbosity(ssh_options opt, int verbosity) { return ssh_options_set(opt, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); } /** @@ -1053,7 +1052,7 @@ int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity) { * * @see ssh_options_new() */ -int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) { +int ssh_options_getopt(ssh_options options, int *argcptr, char **argv) { char *user = NULL; char *cipher = NULL; char *localaddr = NULL; @@ -1253,7 +1252,7 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv) { * * @return 0 on success, < 0 on error. */ -int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb, +int ssh_options_set_auth_callback(ssh_options opt, ssh_auth_callback cb, void *userdata) { if (opt == NULL || cb == NULL || opt->callbacks==NULL) { return -1; diff --git a/libssh/server.c b/libssh/server.c index a116836c..b58316d4 100644 --- a/libssh/server.c +++ b/libssh/server.c @@ -122,7 +122,7 @@ SSH_BIND *ssh_bind_new(void) { return ptr; } -void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options) { +void ssh_bind_set_options(SSH_BIND *ssh_bind, ssh_options options) { ssh_bind->options = options; } @@ -271,7 +271,7 @@ extern char *supported_methods[]; static int server_set_kex(ssh_session session) { KEX *server = &session->server_kex; - SSH_OPTIONS *options = session->options; + ssh_options options = session->options; int i, j; char *wanted; diff --git a/libssh/session.c b/libssh/session.c index c412038b..c676cc80 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -164,7 +164,7 @@ void ssh_silent_disconnect(ssh_session session) { * \see ssh_new() * \see ssh_options_new() */ -void ssh_set_options(ssh_session session, SSH_OPTIONS *options) { +void ssh_set_options(ssh_session session, ssh_options options) { if (session == NULL || options == NULL) { return; } @@ -502,7 +502,7 @@ static int auth_kbdint(ssh_session session){ int main(int argc, char **argv){ ssh_session session; - SSH_OPTIONS *options; + ssh_options options; int auth=0; char *password; char *banner; diff --git a/samplesshd.c b/samplesshd.c index 6fd97a83..dcd85dc6 100644 --- a/samplesshd.c +++ b/samplesshd.c @@ -40,7 +40,7 @@ static int auth_password(char *user, char *password){ } int main(int argc, char **argv){ - SSH_OPTIONS *options=ssh_options_new(); + ssh_options options=ssh_options_new(); ssh_session session; SSH_BIND *ssh_bind; SSH_MESSAGE *message; |