aboutsummaryrefslogtreecommitdiff
path: root/src/server_ssh.c
blob: 92d9454fb6ee9d41333b509a0483e5da96bfb70f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdlib.h>
#include <libssh/callbacks.h>
#include <libssh/server.h>

#include "server_ssh.h"
#include "server.h"

static void set_default_keys(ssh_bind sshbind, int rsa_already_set,
                      int dsa_already_set, int ecdsa_already_set);


int ssh_on_connect(struct server_data *data, struct server_session *ses)
{
    return 0;
}

int ssh_on_disconnect(struct server_data *data, struct server_session *ses)
{
    return 0;
}

int ssh_mainloop_cb(struct server_data *data, struct server_session *ses)
{
    return 0;
}

int ssh_init_cb(struct server_ctx *ctx)
{
    ctx->server_cbs.on_connect = ssh_on_connect;
    ctx->server_cbs.on_disconnect = ssh_on_disconnect;
    ctx->server_cbs.mainloop = ssh_mainloop_cb;
    ctx->server_cbs.on_free = ssh_free_cb;
    ctx->server_cbs.on_listen = ssh_listen_cb;
    ctx->server_cbs.on_shutdown = ssh_shutdown_cb;

    ssh_init();
    ssh_data *d = (ssh_data *) calloc(1, sizeof(*d));
    d->sshbind = ssh_bind_new();
    ctx->server_dat.data = d;
    if (!d->sshbind)
        return 1;

    set_default_keys(d->sshbind, 0, 0, 0);
    return 0;
}

int ssh_free_cb(struct server_data *data)
{
    return 0;
}

int ssh_listen_cb(struct server_data *data)
{
    return 0;
}

int ssh_shutdown_cb(struct server_data *data)
{
    return 0;
}

static void set_default_keys(ssh_bind sshbind, int rsa_already_set,
                             int dsa_already_set, int ecdsa_already_set)
{
    if (!rsa_already_set) {
        ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY,
                             "./ssh_host_rsa_key");
    }
    if (!dsa_already_set) {
        ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY,
                             "./ssh_host_dsa_key");
    }
    if (!ecdsa_already_set) {
        ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY,
                             "./ssh_host_ecdsa_key");
    }
}