runopts.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Dropbear - a SSH2 server
  3. *
  4. * Copyright (c) 2002,2003 Matt Johnston
  5. * All rights reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE. */
  24. #ifndef DROPBEAR_RUNOPTS_H_
  25. #define DROPBEAR_RUNOPTS_H_
  26. #include "includes.h"
  27. #include "signkey.h"
  28. #include "buffer.h"
  29. #include "auth.h"
  30. #include "tcpfwd.h"
  31. typedef struct runopts {
  32. #if DROPBEAR_SVR_REMOTETCPFWD || DROPBEAR_CLI_LOCALTCPFWD \
  33. || DROPBEAR_CLI_REMOTETCPFWD
  34. int listen_fwd_all;
  35. #endif
  36. unsigned int recv_window;
  37. time_t keepalive_secs; /* Time between sending keepalives. 0 is off */
  38. time_t idle_timeout_secs; /* Exit if no traffic is sent/received in this time */
  39. int usingsyslog;
  40. #ifndef DISABLE_ZLIB
  41. /* TODO: add a commandline flag. Currently this is on by default if compression
  42. * is compiled in, but disabled for a client's non-final multihop stages. (The
  43. * intermediate stages are compressed streams, so are uncompressible. */
  44. enum {
  45. DROPBEAR_COMPRESS_DELAYED, /* Server only */
  46. DROPBEAR_COMPRESS_ON,
  47. DROPBEAR_COMPRESS_OFF,
  48. } compress_mode;
  49. #endif
  50. #if DROPBEAR_USER_ALGO_LIST
  51. char *cipher_list;
  52. char *mac_list;
  53. #endif
  54. } runopts;
  55. extern runopts opts;
  56. int readhostkey(const char * filename, sign_key * hostkey,
  57. enum signkey_type *type);
  58. void load_all_hostkeys(void);
  59. typedef struct svr_runopts {
  60. char * bannerfile;
  61. int forkbg;
  62. /* ports and addresses are arrays of the portcount
  63. listening ports. strings are malloced. */
  64. char *ports[DROPBEAR_MAX_PORTS];
  65. unsigned int portcount;
  66. char *addresses[DROPBEAR_MAX_PORTS];
  67. int inetdmode;
  68. /* Hidden "-2" flag indicates it's re-executing itself */
  69. int reexec_child;
  70. /* Flags indicating whether to use ipv4 and ipv6 */
  71. /* not used yet
  72. int ipv4;
  73. int ipv6;
  74. */
  75. #if DO_MOTD
  76. /* whether to print the MOTD */
  77. int domotd;
  78. #endif
  79. int norootlogin;
  80. #ifdef HAVE_GETGROUPLIST
  81. /* restrict_group is the group name if group restriction was enabled,
  82. NULL otherwise */
  83. char *restrict_group;
  84. /* restrict_group_gid is only valid if restrict_group is set */
  85. gid_t restrict_group_gid;
  86. #endif
  87. int noauthpass;
  88. int norootpass;
  89. int allowblankpass;
  90. unsigned int maxauthtries;
  91. #if DROPBEAR_SVR_REMOTETCPFWD
  92. int noremotetcp;
  93. #endif
  94. #if DROPBEAR_SVR_LOCALTCPFWD
  95. int nolocaltcp;
  96. #endif
  97. sign_key *hostkey;
  98. int delay_hostkey;
  99. char *hostkey_files[MAX_HOSTKEYS];
  100. int num_hostkey_files;
  101. buffer * banner;
  102. char * pidfile;
  103. char * forced_command;
  104. #if DROPBEAR_PLUGIN
  105. char *pubkey_plugin;
  106. char *pubkey_plugin_options;
  107. #endif
  108. int pass_on_env;
  109. } svr_runopts;
  110. extern svr_runopts svr_opts;
  111. void svr_getopts(int argc, char ** argv);
  112. void loadhostkeys(void);
  113. typedef struct cli_runopts {
  114. char *progname;
  115. char *remotehost;
  116. const char *remoteport;
  117. char *own_user;
  118. char *username;
  119. char *cmd;
  120. int wantpty;
  121. int always_accept_key;
  122. int no_hostkey_check;
  123. int no_cmd;
  124. int quiet;
  125. int backgrounded;
  126. int is_subsystem;
  127. #if DROPBEAR_CLI_PUBKEY_AUTH
  128. m_list *privkeys; /* Keys to use for public-key auth */
  129. #endif
  130. #if DROPBEAR_CLI_ANYTCPFWD
  131. int exit_on_fwd_failure;
  132. #endif
  133. int disable_trivial_auth;
  134. #if DROPBEAR_CLI_REMOTETCPFWD
  135. m_list * remotefwds;
  136. #endif
  137. #if DROPBEAR_CLI_LOCALTCPFWD
  138. m_list * localfwds;
  139. #endif
  140. #if DROPBEAR_CLI_AGENTFWD
  141. int agent_fwd;
  142. int agent_keys_loaded; /* whether pubkeys has been populated with a
  143. list of keys held by the agent */
  144. int agent_fd; /* The agent fd is only set during authentication. Forwarded
  145. agent sessions have their own file descriptors */
  146. #endif
  147. #if DROPBEAR_CLI_NETCAT
  148. char *netcat_host;
  149. unsigned int netcat_port;
  150. #endif
  151. #if DROPBEAR_CLI_PROXYCMD
  152. char *proxycmd;
  153. #endif
  154. char *bind_address;
  155. char *bind_port;
  156. } cli_runopts;
  157. extern cli_runopts cli_opts;
  158. void cli_getopts(int argc, char ** argv);
  159. #if DROPBEAR_USER_ALGO_LIST
  160. void parse_ciphers_macs(void);
  161. #endif
  162. void print_version(void);
  163. void parse_recv_window(const char* recv_window_arg);
  164. int split_address_port(const char* spec, char **first, char ** second);
  165. #endif /* DROPBEAR_RUNOPTS_H_ */