diff options
-rw-r--r-- | libssh/server.c | 15 | ||||
-rw-r--r-- | samplesshd.c | 23 |
2 files changed, 23 insertions, 15 deletions
diff --git a/libssh/server.c b/libssh/server.c index 7821faac..2a8ba334 100644 --- a/libssh/server.c +++ b/libssh/server.c @@ -45,7 +45,6 @@ #include "libssh/socket.h" #include "libssh/channels.h" #include "libssh/session.h" -#include "libssh/options.h" #include "libssh/misc.h" #include "libssh/keys.h" #include "libssh/dh.h" @@ -303,6 +302,15 @@ void ssh_bind_free(SSH_BIND *sshbind){ } extern char *supported_methods[]; +/** @internal + * This functions sets the Key Exchange protocols to be accepted + * by the server. They depend on + * -What the user asked (via options) + * -What is available (keys) + * It should then accept the intersection of what the user asked + * and what is available, and return an error if nothing matches + * @bug To rewrite, it's broken !! + */ static int server_set_kex(ssh_session session) { KEX *server = &session->server_kex; @@ -311,7 +319,7 @@ static int server_set_kex(ssh_session session) { ZERO_STRUCTP(server); ssh_get_random(server->cookie, 16, 0); - +#if 0 if (session->dsa_key != NULL && session->rsa_key != NULL) { if (ssh_bind_options_set(options, SSH_BIND_OPTIONS_HOSTKEY, "ssh-dss,ssh-rsa") < 0) { @@ -326,6 +334,7 @@ static int server_set_kex(ssh_session session) { return -1; } } +#endif server->methods = malloc(10 * sizeof(char **)); if (server->methods == NULL) { @@ -333,7 +342,7 @@ static int server_set_kex(ssh_session session) { } for (i = 0; i < 10; i++) { - if ((wanted = options->wanted_methods[i]) == NULL) { + if ((wanted = session->wanted_methods[i]) == NULL) { wanted = supported_methods[i]; } server->methods[i] = strdup(wanted); diff --git a/samplesshd.c b/samplesshd.c index 9d6e3bb0..fa97fabf 100644 --- a/samplesshd.c +++ b/samplesshd.c @@ -40,29 +40,28 @@ static int auth_password(char *user, char *password){ } int main(int argc, char **argv){ - ssh_options options=ssh_options_new(); ssh_session session; - SSH_BIND *ssh_bind; + ssh_bind ssh_bind_o; ssh_message message; ssh_channel chan=0; ssh_buffer buf; int auth=0; int sftp=0; int i; - ssh_options_getopt(options, &argc, argv); - ssh_options_set(options, SSH_OPTIONS_SERVER_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key"); - ssh_options_set(options, SSH_OPTIONS_SERVER_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key"); + ssh_bind_o=ssh_bind_new(); +// ssh_options_getopt(options, &argc, argv); + ssh_bind_options_set(ssh_bind_o, SSH_BIND_OPTIONS_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key"); + ssh_bind_options_set(ssh_bind_o, SSH_BIND_OPTIONS_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key"); - ssh_bind=ssh_bind_new(); - ssh_bind_set_options(ssh_bind,options); - if(ssh_bind_listen(ssh_bind)<0){ - printf("Error listening to socket: %s\n",ssh_get_error(ssh_bind)); +// ssh_bind_set_options(ssh_bind_o,options); + if(ssh_bind_listen(ssh_bind_o)<0){ + printf("Error listening to socket: %s\n",ssh_get_error(ssh_bind_o)); return 1; } - session=ssh_bind_accept(ssh_bind); + session=ssh_bind_accept(ssh_bind_o); if(!session){ - printf("error accepting a connection : %s\n",ssh_get_error(ssh_bind)); + printf("error accepting a connection : %s\n",ssh_get_error(ssh_bind_o)); return 1; } printf("Socket connected: fd = %d\n", ssh_get_fd(session)); @@ -153,7 +152,7 @@ int main(int argc, char **argv){ } while (i>0); buffer_free(buf); ssh_disconnect(session); - ssh_bind_free(ssh_bind); + ssh_bind_free(ssh_bind_o); ssh_finalize(); return 0; } |