2
* options.c - handle pre-connection options
4
* This file is part of the SSH Library
6
* Copyright (c) 2003-2008 by Aris Adamantiadis
7
* Copyright (c) 2009 by Andreas Schneider <mail@cynapses.org>
9
* The SSH Library is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2.1 of the License, or (at your
12
* option) any later version.
14
* The SSH Library is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
* License for more details.
19
* You should have received a copy of the GNU Lesser General Public License
20
* along with the SSH Library; see the file COPYING. If not, write to
21
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34
#include <sys/types.h>
35
#include "libssh/priv.h"
36
#include "libssh/session.h"
37
#include "libssh/misc.h"
39
#include "libssh/server.h"
40
#include "libssh/bind.h"
44
* @addtogroup libssh_session
49
* @brief Duplicate the options of a session structure.
51
* If you make several sessions with the same options this is useful. You
52
* cannot use twice the same option structure in ssh_session_connect.
54
* @param src The session to use to copy the options.
56
* @param dest The session to copy the options to.
58
* @returns 0 on sucess, -1 on error with errno set.
60
* @see ssh_session_connect()
62
int ssh_options_copy(ssh_session src, ssh_session *dest) {
66
if (src == NULL || dest == NULL || *dest == NULL) {
73
new->username = strdup(src->username);
74
if (new->username == NULL) {
80
new->host = strdup(src->host);
81
if (new->host == NULL) {
87
struct ssh_iterator *it;
89
new->identity = ssh_list_new();
90
if (new->identity == NULL) {
94
it = ssh_list_get_iterator(src->identity);
99
id = strdup((char *) it->data);
104
rc = ssh_list_append(new->identity, id);
113
new->sshdir = strdup(src->sshdir);
114
if (new->sshdir == NULL) {
119
if (src->knownhosts) {
120
new->knownhosts = strdup(src->knownhosts);
121
if (new->knownhosts == NULL) {
126
for (i = 0; i < 10; ++i) {
127
if (src->wanted_methods[i]) {
128
new->wanted_methods[i] = strdup(src->wanted_methods[i]);
129
if (new->wanted_methods[i] == NULL) {
135
if(src->ProxyCommand) {
136
new->ProxyCommand = strdup(src->ProxyCommand);
137
if(new->ProxyCommand == NULL)
141
new->port = src->port;
142
new->callbacks = src->callbacks;
143
new->timeout = src->timeout;
144
new->timeout_usec = src->timeout_usec;
145
new->ssh2 = src->ssh2;
146
new->ssh1 = src->ssh1;
147
new->log_verbosity = src->log_verbosity;
148
new->compressionlevel = src->compressionlevel;
153
int ssh_options_set_algo(ssh_session session, int algo,
155
if (!verify_existing_algo(algo, list)) {
156
ssh_set_error(session, SSH_REQUEST_DENIED,
157
"Setting method: no algorithm for method \"%s\" (%s)\n",
158
ssh_kex_nums[algo], list);
162
SAFE_FREE(session->wanted_methods[algo]);
163
session->wanted_methods[algo] = strdup(list);
164
if (session->wanted_methods[algo] == NULL) {
165
ssh_set_error_oom(session);
173
* @brief This function can set all possible ssh options.
175
* @param session An allocated SSH session structure.
177
* @param type The option type to set. This could be one of the
180
* - SSH_OPTIONS_HOST:
181
* The hostname or ip address to connect to (const char *).
183
* - SSH_OPTIONS_PORT:
184
* The port to connect to (unsigned int).
186
* - SSH_OPTIONS_PORT_STR:
187
* The port to connect to (const char *).
190
* The file descriptor to use (socket_t).\n
192
* If you wish to open the socket yourself for a reason
193
* or another, set the file descriptor. Don't forget to
194
* set the hostname as the hostname is used as a key in
195
* the known_host mechanism.
197
* - SSH_OPTIONS_BINDADDR:
198
* The address to bind the client to (const char *).
200
* - SSH_OPTIONS_USER:
201
* The username for authentication (const char *).\n
203
* If the value is NULL, the username is set to the
206
* - SSH_OPTIONS_SSH_DIR:
207
* Set the ssh directory (const char *,format string).\n
209
* If the value is NULL, the directory is set to the
210
* default ssh directory.\n
212
* The ssh directory is used for files like known_hosts
213
* and identity (private and public key). It may include
214
* "%s" which will be replaced by the user home
217
* - SSH_OPTIONS_KNOWNHOSTS:
218
* Set the known hosts file name (const char *,format string).\n
220
* If the value is NULL, the directory is set to the
221
* default known hosts file, normally
222
* ~/.ssh/known_hosts.\n
224
* The known hosts file is used to certify remote hosts
225
* are genuine. It may include "%s" which will be
226
* replaced by the user home directory.
228
* - SSH_OPTIONS_IDENTITY:
229
* Set the identity file name (const char *,format string).\n
231
* By default identity, id_dsa and id_rsa are checked.\n
233
* The identity file used authenticate with public key.
234
* It may include "%s" which will be replaced by the
235
* user home directory.
237
* - SSH_OPTIONS_TIMEOUT:
238
* Set a timeout for the connection in seconds (long).
240
* - SSH_OPTIONS_TIMEOUT_USEC:
241
* Set a timeout for the connection in micro seconds
244
* - SSH_OPTIONS_SSH1:
245
* Allow or deny the connection to SSH1 servers
248
* - SSH_OPTIONS_SSH2:
249
* Allow or deny the connection to SSH2 servers
252
* - SSH_OPTIONS_LOG_VERBOSITY:
253
* Set the session logging verbosity (int).\n
255
* The verbosity of the messages. Every log smaller or
256
* equal to verbosity will be shown.
257
* - SSH_LOG_NOLOG: No logging
258
* - SSH_LOG_RARE: Rare conditions or warnings
259
* - SSH_LOG_ENTRY: API-accessible entrypoints
260
* - SSH_LOG_PACKET: Packet id and size
261
* - SSH_LOG_FUNCTIONS: Function entering and leaving
263
* - SSH_OPTIONS_LOG_VERBOSITY_STR:
264
* Set the session logging verbosity (const char *).\n
266
* The verbosity of the messages. Every log smaller or
267
* equal to verbosity will be shown.
268
* - SSH_LOG_NOLOG: No logging
269
* - SSH_LOG_RARE: Rare conditions or warnings
270
* - SSH_LOG_ENTRY: API-accessible entrypoints
271
* - SSH_LOG_PACKET: Packet id and size
272
* - SSH_LOG_FUNCTIONS: Function entering and leaving
274
* See the corresponding numbers in libssh.h.
276
* - SSH_OPTIONS_AUTH_CALLBACK:
277
* Set a callback to use your own authentication function
278
* (function pointer).
280
* - SSH_OPTIONS_AUTH_USERDATA:
281
* Set the user data passed to the authentication
282
* function (generic pointer).
284
* - SSH_OPTIONS_LOG_CALLBACK:
285
* Set a callback to use your own logging function
286
* (function pointer).
288
* - SSH_OPTIONS_LOG_USERDATA:
289
* Set the user data passed to the logging function
292
* - SSH_OPTIONS_STATUS_CALLBACK:
293
* Set a callback to show connection status in realtime
294
* (function pointer).\n
297
* fn(void *arg, float status)
300
* During ssh_connect(), libssh will call the callback
301
* with status from 0.0 to 1.0.
303
* - SSH_OPTIONS_STATUS_ARG:
304
* Set the status argument which should be passed to the
305
* status callback (generic pointer).
307
* - SSH_OPTIONS_CIPHERS_C_S:
308
* Set the symmetric cipher client to server (const char *,
309
* comma-separated list).
311
* - SSH_OPTIONS_CIPHERS_S_C:
312
* Set the symmetric cipher server to client (const char *,
313
* comma-separated list).
315
* - SSH_OPTIONS_COMPRESSION_C_S:
316
* Set the compression to use for client to server
317
* communication (const char *, "yes", "no" or a specific
318
* algorithm name if needed ("zlib","zlib@openssh.com","none").
320
* - SSH_OPTIONS_COMPRESSION_S_C:
321
* Set the compression to use for server to client
322
* communication (const char *, "yes", "no" or a specific
323
* algorithm name if needed ("zlib","zlib@openssh.com","none").
325
* - SSH_OPTIONS_COMPRESSION:
326
* Set the compression to use for both directions
327
* communication (const char *, "yes", "no" or a specific
328
* algorithm name if needed ("zlib","zlib@openssh.com","none").
330
* - SSH_OPTIONS_COMPRESSION_LEVEL:
331
* Set the compression level to use for zlib functions. (int,
332
* value from 1 to 9, 9 being the most efficient but slower).
334
* - SSH_OPTIONS_STRICTHOSTKEYCHECK:
335
* Set the parameter StrictHostKeyChecking to avoid
336
* asking about a fingerprint (int, 0 = false).
338
* - SSH_OPTIONS_PROXYCOMMAND:
339
* Set the command to be executed in order to connect to
340
* server (const char *).
342
* @param value The value to set. This is a generic pointer and the
343
* datatype which is used should be set according to the
346
* @return 0 on success, < 0 on error.
348
int ssh_options_set(ssh_session session, enum ssh_options_e type,
354
if (session == NULL) {
359
case SSH_OPTIONS_HOST:
362
ssh_set_error_oom(session);
367
SAFE_FREE(session->host);
371
session->host = strdup(p + 1);
372
if (session->host == NULL) {
374
ssh_set_error_oom(session);
378
SAFE_FREE(session->username);
379
session->username = strdup(q);
381
if (session->username == NULL) {
382
ssh_set_error_oom(session);
389
case SSH_OPTIONS_PORT:
391
session->port = 22 & 0xffff;
393
int *x = (int *) value;
395
session->port = *x & 0xffff;
398
case SSH_OPTIONS_PORT_STR:
400
session->port = 22 & 0xffff;
404
ssh_set_error_oom(session);
407
i = strtol(q, &p, 10);
413
session->port = i & 0xffff;
418
session->fd = SSH_INVALID_SOCKET;
420
socket_t *x = (socket_t *) value;
422
session->fd = *x & 0xffff;
425
case SSH_OPTIONS_BINDADDR:
427
ssh_set_error_invalid(session, __FUNCTION__);
434
SAFE_FREE(session->bindaddr);
435
session->bindaddr = q;
437
case SSH_OPTIONS_USER:
438
SAFE_FREE(session->username);
439
if (value == NULL) { /* set default username */
440
q = ssh_get_local_username(session);
444
session->username = q;
445
} else { /* username provided */
446
session->username = strdup(value);
447
if (session->username == NULL) {
448
ssh_set_error_oom(session);
453
case SSH_OPTIONS_SSH_DIR:
455
SAFE_FREE(session->sshdir);
457
session->sshdir = ssh_path_expand_tilde("~/.ssh");
458
if (session->sshdir == NULL) {
462
SAFE_FREE(session->sshdir);
463
session->sshdir = ssh_path_expand_tilde(value);
464
if (session->sshdir == NULL) {
469
case SSH_OPTIONS_IDENTITY:
470
case SSH_OPTIONS_ADD_IDENTITY:
472
ssh_set_error_invalid(session, __FUNCTION__);
479
rc = ssh_list_prepend(session->identity, q);
484
case SSH_OPTIONS_KNOWNHOSTS:
486
SAFE_FREE(session->knownhosts);
487
if (session->sshdir == NULL) {
490
session->knownhosts = ssh_path_expand_escape(session, "%d/known_hosts");
491
if (session->knownhosts == NULL) {
495
SAFE_FREE(session->knownhosts);
496
session->knownhosts = strdup(value);
497
if (session->knownhosts == NULL) {
502
case SSH_OPTIONS_TIMEOUT:
504
ssh_set_error_invalid(session, __FUNCTION__);
507
long *x = (long *) value;
509
session->timeout = *x & 0xffffffff;
512
case SSH_OPTIONS_TIMEOUT_USEC:
514
ssh_set_error_invalid(session, __FUNCTION__);
517
long *x = (long *) value;
519
session->timeout_usec = *x & 0xffffffff;
522
case SSH_OPTIONS_SSH1:
524
ssh_set_error_invalid(session, __FUNCTION__);
527
int *x = (int *) value;
531
case SSH_OPTIONS_SSH2:
533
ssh_set_error_invalid(session, __FUNCTION__);
536
int *x = (int *) value;
537
session->ssh2 = *x & 0xffff;
540
case SSH_OPTIONS_LOG_VERBOSITY:
542
ssh_set_error_invalid(session, __FUNCTION__);
545
int *x = (int *) value;
547
session->log_verbosity = *x & 0xffff;
550
case SSH_OPTIONS_LOG_VERBOSITY_STR:
552
session->log_verbosity = 0 & 0xffff;
556
ssh_set_error_oom(session);
559
i = strtol(q, &p, 10);
565
session->log_verbosity = i & 0xffff;
568
case SSH_OPTIONS_CIPHERS_C_S:
570
ssh_set_error_invalid(session, __FUNCTION__);
573
if (ssh_options_set_algo(session, SSH_CRYPT_C_S, value) < 0)
577
case SSH_OPTIONS_CIPHERS_S_C:
579
ssh_set_error_invalid(session, __FUNCTION__);
582
if (ssh_options_set_algo(session, SSH_CRYPT_S_C, value) < 0)
586
case SSH_OPTIONS_COMPRESSION_C_S:
588
ssh_set_error_invalid(session, __FUNCTION__);
591
if (strcasecmp(value,"yes")==0){
592
if(ssh_options_set_algo(session,SSH_COMP_C_S,"zlib@openssh.com,zlib") < 0)
594
} else if (strcasecmp(value,"no")==0){
595
if(ssh_options_set_algo(session,SSH_COMP_C_S,"none") < 0)
598
if (ssh_options_set_algo(session, SSH_COMP_C_S, value) < 0)
603
case SSH_OPTIONS_COMPRESSION_S_C:
605
ssh_set_error_invalid(session, __FUNCTION__);
608
if (strcasecmp(value,"yes")==0){
609
if(ssh_options_set_algo(session,SSH_COMP_S_C,"zlib@openssh.com,zlib") < 0)
611
} else if (strcasecmp(value,"no")==0){
612
if(ssh_options_set_algo(session,SSH_COMP_S_C,"none") < 0)
615
if (ssh_options_set_algo(session, SSH_COMP_S_C, value) < 0)
620
case SSH_OPTIONS_COMPRESSION:
622
ssh_set_error_invalid(session, __FUNCTION__);
625
if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_C_S,value) < 0)
627
if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_S_C,value) < 0)
630
case SSH_OPTIONS_COMPRESSION_LEVEL:
632
ssh_set_error_invalid(session, __FUNCTION__);
637
if(*x < 1 || *x > 9){
638
ssh_set_error_invalid(session, __FUNCTION__);
641
session->compressionlevel=*x & 0xff;
644
case SSH_OPTIONS_STRICTHOSTKEYCHECK:
646
ssh_set_error_invalid(session, __FUNCTION__);
649
session->StrictHostKeyChecking = *(int*)value;
652
case SSH_OPTIONS_PROXYCOMMAND:
654
ssh_set_error_invalid(session, __FUNCTION__);
657
SAFE_FREE(session->ProxyCommand);
662
session->ProxyCommand = q;
666
ssh_set_error(session, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
676
* @brief Parse command line arguments.
678
* This is a helper for your application to generate the appropriate
679
* options from the command line arguments.\n
680
* The argv array and argc value are changed so that the parsed
681
* arguments wont appear anymore in them.\n
682
* The single arguments (without switches) are not parsed. thus,
683
* myssh -l user localhost\n
684
* The command wont set the hostname value of options to localhost.
686
* @param session The session to configure.
688
* @param argcptr The pointer to the argument count.
690
* @param argv The arguments list pointer.
692
* @returns 0 on success, < 0 on error.
694
* @see ssh_session_new()
696
int ssh_options_getopt(ssh_session session, int *argcptr, char **argv) {
699
char *identity = NULL;
717
/* Not supported with a Microsoft compiler */
720
int saveoptind = optind; /* need to save 'em */
721
int saveopterr = opterr;
723
save = malloc(argc * sizeof(char *));
725
ssh_set_error_oom(session);
729
opterr = 0; /* shut up getopt */
730
while(cont && ((i = getopt(argc, argv, "c:i:Cl:p:vb:rd12")) != -1)) {
768
save[current] = strdup(opt);
769
if (save[current] == NULL) {
771
ssh_set_error_oom(session);
776
save[current++] = argv[optind + 1];
782
while (optind < argc) {
783
save[current++] = argv[optind++];
786
if (usersa && usedss) {
787
ssh_set_error(session, SSH_FATAL, "Either RSA or DSS must be chosen");
791
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &debuglevel);
800
/* first recopy the save vector into the original's */
801
for (i = 0; i < current; i++) {
802
/* don't erase argv[0] */
803
argv[ i + 1] = save[i];
805
argv[current + 1] = NULL;
806
*argcptr = current + 1;
809
/* set a new option struct */
811
if (ssh_options_set(session, SSH_OPTIONS_COMPRESSION, "yes") < 0) {
816
if (cont && cipher) {
817
if (ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, cipher) < 0) {
820
if (cont && ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, cipher) < 0) {
826
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
831
if (cont && identity) {
832
if (ssh_options_set(session, SSH_OPTIONS_IDENTITY, identity) < 0) {
837
ssh_options_set(session, SSH_OPTIONS_PORT_STR, port);
839
ssh_options_set(session, SSH_OPTIONS_SSH1, &ssh1);
840
ssh_options_set(session, SSH_OPTIONS_SSH2, &ssh2);
851
* @brief Parse the ssh config file.
853
* This should be the last call of all options, it may overwrite options which
854
* are already set. It requires that the host name is already set with
855
* ssh_options_set_host().
857
* @param session SSH session handle
859
* @param filename The options file to use, if NULL the default
860
* ~/.ssh/config will be used.
862
* @return 0 on success, < 0 on error.
864
* @see ssh_options_set_host()
866
int ssh_options_parse_config(ssh_session session, const char *filename) {
867
char *expanded_filename;
870
if (session == NULL) {
873
if (session->host == NULL) {
874
ssh_set_error_invalid(session, __FUNCTION__);
878
if (session->sshdir == NULL) {
879
r = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
881
ssh_set_error_oom(session);
886
/* set default filename */
887
if (filename == NULL) {
888
expanded_filename = ssh_path_expand_escape(session, "%d/config");
890
expanded_filename = ssh_path_expand_escape(session, filename);
892
if (expanded_filename == NULL) {
896
r = ssh_config_parse_file(session, expanded_filename);
900
if (filename == NULL) {
901
r = ssh_config_parse_file(session, "/etc/ssh/ssh_config");
905
free(expanded_filename);
909
int ssh_options_apply(ssh_session session) {
910
struct ssh_iterator *it;
914
if (session->sshdir == NULL) {
915
rc = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
921
if (session->username == NULL) {
922
rc = ssh_options_set(session, SSH_OPTIONS_USER, NULL);
928
if (session->knownhosts == NULL) {
929
tmp = ssh_path_expand_escape(session, "%d/known_hosts");
931
tmp = ssh_path_expand_escape(session, session->knownhosts);
936
free(session->knownhosts);
937
session->knownhosts = tmp;
939
if (session->ProxyCommand != NULL) {
940
tmp = ssh_path_expand_escape(session, session->ProxyCommand);
944
free(session->ProxyCommand);
945
session->ProxyCommand = tmp;
948
for (it = ssh_list_get_iterator(session->identity);
951
char *id = (char *) it->data;
952
tmp = ssh_path_expand_escape(session, id);
967
* @addtogroup libssh_server
970
static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo,
972
if (!verify_existing_algo(algo, list)) {
973
ssh_set_error(sshbind, SSH_REQUEST_DENIED,
974
"Setting method: no algorithm for method \"%s\" (%s)\n",
975
ssh_kex_nums[algo], list);
979
SAFE_FREE(sshbind->wanted_methods[algo]);
980
sshbind->wanted_methods[algo] = strdup(list);
981
if (sshbind->wanted_methods[algo] == NULL) {
982
ssh_set_error_oom(sshbind);
990
* @brief This function can set all possible ssh bind options.
992
* @param session An allocated ssh option structure.
994
* @param type The option type to set. This could be one of the
997
* SSH_BIND_OPTIONS_LOG_VERBOSITY:
998
* Set the session logging verbosity (integer).
1000
* The verbosity of the messages. Every log smaller or
1001
* equal to verbosity will be shown.
1002
* SSH_LOG_NOLOG: No logging
1003
* SSH_LOG_RARE: Rare conditions or warnings
1004
* SSH_LOG_ENTRY: API-accessible entrypoints
1005
* SSH_LOG_PACKET: Packet id and size
1006
* SSH_LOG_FUNCTIONS: Function entering and leaving
1008
* SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
1009
* Set the session logging verbosity (integer).
1011
* The verbosity of the messages. Every log smaller or
1012
* equal to verbosity will be shown.
1013
* SSH_LOG_NOLOG: No logging
1014
* SSH_LOG_RARE: Rare conditions or warnings
1015
* SSH_LOG_ENTRY: API-accessible entrypoints
1016
* SSH_LOG_PACKET: Packet id and size
1017
* SSH_LOG_FUNCTIONS: Function entering and leaving
1019
* SSH_BIND_OPTIONS_BINDADDR:
1020
* Set the bind address.
1022
* SSH_BIND_OPTIONS_BINDPORT:
1023
* Set the bind port, default is 22.
1025
* SSH_BIND_OPTIONS_HOSTKEY:
1026
* Set the server public key type: ssh-rsa or ssh-dss
1029
* SSH_BIND_OPTIONS_DSAKEY:
1030
* Set the path to the dsa ssh host key (string).
1032
* SSH_BIND_OPTIONS_RSAKEY:
1033
* Set the path to the ssh host rsa key (string).
1035
* SSH_BIND_OPTIONS_BANNER:
1036
* Set the server banner sent to clients (string).
1038
* @param value The value to set. This is a generic pointer and the
1039
* datatype which is used should be set according to the
1042
* @return 0 on success, < 0 on error.
1044
int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
1045
const void *value) {
1049
if (sshbind == NULL) {
1054
case SSH_BIND_OPTIONS_HOSTKEY:
1055
if (value == NULL) {
1056
ssh_set_error_invalid(sshbind, __FUNCTION__);
1059
if (ssh_bind_options_set_algo(sshbind, SSH_HOSTKEYS, value) < 0)
1063
case SSH_BIND_OPTIONS_BINDADDR:
1064
if (value == NULL) {
1065
ssh_set_error_invalid(sshbind, __FUNCTION__);
1068
SAFE_FREE(sshbind->bindaddr);
1069
sshbind->bindaddr = strdup(value);
1070
if (sshbind->bindaddr == NULL) {
1071
ssh_set_error_oom(sshbind);
1076
case SSH_BIND_OPTIONS_BINDPORT:
1077
if (value == NULL) {
1078
ssh_set_error_invalid(sshbind, __FUNCTION__);
1081
int *x = (int *) value;
1082
sshbind->bindport = *x & 0xffff;
1085
case SSH_BIND_OPTIONS_BINDPORT_STR:
1086
if (value == NULL) {
1087
sshbind->bindport = 22 & 0xffff;
1091
ssh_set_error_oom(sshbind);
1094
i = strtol(q, &p, 10);
1100
sshbind->bindport = i & 0xffff;
1103
case SSH_BIND_OPTIONS_LOG_VERBOSITY:
1104
if (value == NULL) {
1105
ssh_set_error_invalid(sshbind, __FUNCTION__);
1108
int *x = (int *) value;
1109
sshbind->log_verbosity = *x & 0xffff;
1112
case SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
1113
if (value == NULL) {
1114
sshbind->log_verbosity = 0;
1118
ssh_set_error_oom(sshbind);
1121
i = strtol(q, &p, 10);
1127
sshbind->log_verbosity = i & 0xffff;
1130
case SSH_BIND_OPTIONS_DSAKEY:
1131
if (value == NULL) {
1132
ssh_set_error_invalid(sshbind, __FUNCTION__);
1135
SAFE_FREE(sshbind->dsakey);
1136
sshbind->dsakey = strdup(value);
1137
if (sshbind->dsakey == NULL) {
1138
ssh_set_error_oom(sshbind);
1143
case SSH_BIND_OPTIONS_RSAKEY:
1144
if (value == NULL) {
1145
ssh_set_error_invalid(sshbind, __FUNCTION__);
1148
SAFE_FREE(sshbind->rsakey);
1149
sshbind->rsakey = strdup(value);
1150
if (sshbind->rsakey == NULL) {
1151
ssh_set_error_oom(sshbind);
1156
case SSH_BIND_OPTIONS_BANNER:
1157
if (value == NULL) {
1158
ssh_set_error_invalid(sshbind, __FUNCTION__);
1161
SAFE_FREE(sshbind->banner);
1162
sshbind->banner = strdup(value);
1163
if (sshbind->banner == NULL) {
1164
ssh_set_error_oom(sshbind);
1170
ssh_set_error(sshbind, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
1181
/* vim: set ts=4 sw=4 et cindent: */