Temporary server fixup for options structure delet

server_set_kex needs to be rewritten
This commit is contained in:
Aris Adamantiadis
2009-10-03 23:06:26 +02:00
parent ab5b4c7cfe
commit 149a2b4a18
2 changed files with 23 additions and 15 deletions

View File

@@ -45,7 +45,6 @@
#include "libssh/socket.h" #include "libssh/socket.h"
#include "libssh/channels.h" #include "libssh/channels.h"
#include "libssh/session.h" #include "libssh/session.h"
#include "libssh/options.h"
#include "libssh/misc.h" #include "libssh/misc.h"
#include "libssh/keys.h" #include "libssh/keys.h"
#include "libssh/dh.h" #include "libssh/dh.h"
@@ -303,6 +302,15 @@ void ssh_bind_free(SSH_BIND *sshbind){
} }
extern char *supported_methods[]; 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) { static int server_set_kex(ssh_session session) {
KEX *server = &session->server_kex; KEX *server = &session->server_kex;
@@ -311,7 +319,7 @@ static int server_set_kex(ssh_session session) {
ZERO_STRUCTP(server); ZERO_STRUCTP(server);
ssh_get_random(server->cookie, 16, 0); ssh_get_random(server->cookie, 16, 0);
#if 0
if (session->dsa_key != NULL && session->rsa_key != NULL) { if (session->dsa_key != NULL && session->rsa_key != NULL) {
if (ssh_bind_options_set(options, SSH_BIND_OPTIONS_HOSTKEY, if (ssh_bind_options_set(options, SSH_BIND_OPTIONS_HOSTKEY,
"ssh-dss,ssh-rsa") < 0) { "ssh-dss,ssh-rsa") < 0) {
@@ -326,6 +334,7 @@ static int server_set_kex(ssh_session session) {
return -1; return -1;
} }
} }
#endif
server->methods = malloc(10 * sizeof(char **)); server->methods = malloc(10 * sizeof(char **));
if (server->methods == NULL) { if (server->methods == NULL) {
@@ -333,7 +342,7 @@ static int server_set_kex(ssh_session session) {
} }
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if ((wanted = options->wanted_methods[i]) == NULL) { if ((wanted = session->wanted_methods[i]) == NULL) {
wanted = supported_methods[i]; wanted = supported_methods[i];
} }
server->methods[i] = strdup(wanted); server->methods[i] = strdup(wanted);

View File

@@ -40,29 +40,28 @@ static int auth_password(char *user, char *password){
} }
int main(int argc, char **argv){ int main(int argc, char **argv){
ssh_options options=ssh_options_new();
ssh_session session; ssh_session session;
SSH_BIND *ssh_bind; ssh_bind ssh_bind_o;
ssh_message message; ssh_message message;
ssh_channel chan=0; ssh_channel chan=0;
ssh_buffer buf; ssh_buffer buf;
int auth=0; int auth=0;
int sftp=0; int sftp=0;
int i; int i;
ssh_options_getopt(options, &argc, argv);
ssh_options_set(options, SSH_OPTIONS_SERVER_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key"); ssh_bind_o=ssh_bind_new();
ssh_options_set(options, SSH_OPTIONS_SERVER_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key"); // 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_o,options);
ssh_bind_set_options(ssh_bind,options); if(ssh_bind_listen(ssh_bind_o)<0){
if(ssh_bind_listen(ssh_bind)<0){ printf("Error listening to socket: %s\n",ssh_get_error(ssh_bind_o));
printf("Error listening to socket: %s\n",ssh_get_error(ssh_bind));
return 1; return 1;
} }
session=ssh_bind_accept(ssh_bind); session=ssh_bind_accept(ssh_bind_o);
if(!session){ 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; return 1;
} }
printf("Socket connected: fd = %d\n", ssh_get_fd(session)); printf("Socket connected: fd = %d\n", ssh_get_fd(session));
@@ -153,7 +152,7 @@ int main(int argc, char **argv){
} while (i>0); } while (i>0);
buffer_free(buf); buffer_free(buf);
ssh_disconnect(session); ssh_disconnect(session);
ssh_bind_free(ssh_bind); ssh_bind_free(ssh_bind_o);
ssh_finalize(); ssh_finalize();
return 0; return 0;
} }