19 #include <openbsd-compat/sys-queue.h>
23 #define MAX_SUBSYSTEMS 256
26 #define PERMIT_NOT_SET -1
28 #define PERMIT_FORCED_ONLY 1
29 #define PERMIT_NO_PASSWD 2
35 #define PRIVSEP_NOSANDBOX 2
38 #define PERMITOPEN_ANY 0
39 #define PERMITOPEN_NONE -2
42 #define IGNORE_RHOSTS_NO 0
43 #define IGNORE_RHOSTS_YES 1
44 #define IGNORE_RHOSTS_SHOSTS 2
46 #define DEFAULT_AUTH_FAIL_MAX 6
47 #define DEFAULT_SESSIONS_MAX 10
48 #define DEFAULT_MAX_DISPLAYS 1000
51 #define INTERNAL_SFTP_NAME "internal-sftp"
54 #define PUBKEYAUTH_TOUCH_REQUIRED (1)
55 #define PUBKEYAUTH_VERIFY_REQUIRED (1<<1)
65 struct queued_listenaddr {
74 struct addrinfo *addrs;
79 u_int ports_from_cmdline;
81 struct queued_listenaddr *queued_listen_addrs;
82 u_int num_queued_listens;
83 struct listenaddr *listen_addrs;
84 u_int num_listen_addrs;
89 char **host_key_files;
90 int *host_key_file_userprovided;
91 u_int num_host_key_files;
92 char **host_cert_files;
93 u_int num_host_cert_files;
100 int permit_root_login;
102 int ignore_user_known_hosts;
107 int x11_display_offset;
109 int x11_max_displays;
110 int x11_use_localhost;
111 char *xauth_location;
116 int ip_qos_interactive;
120 char *kex_algorithms;
121 struct ForwardOptions fwd_opts;
122 SyslogFacility log_facility;
124 u_int num_log_verbose;
126 int hostbased_authentication;
127 int hostbased_uses_name_from_packet_only;
128 char *hostbased_accepted_algos;
129 char *hostkeyalgorithms;
130 char *ca_sign_algorithms;
131 int pubkey_authentication;
132 char *pubkey_accepted_algos;
133 int pubkey_auth_options;
134 int kerberos_authentication;
136 int kerberos_or_local_passwd;
141 int kerberos_ticket_cleanup;
143 int kerberos_get_afs_token;
145 int kerberos_unique_ccache;
149 int gsi_allow_limited_proxy;
150 int gss_authentication;
153 int gss_cleanup_creds;
154 char *gss_creds_path;
155 int gss_strict_acceptor;
157 char *gss_kex_algorithms;
158 int password_authentication;
160 int kbd_interactive_authentication;
161 int permit_empty_passwd;
164 char *permit_user_env_allowlist;
166 int allow_tcp_forwarding;
167 int allow_streamlocal_forwarding;
168 int allow_agent_forwarding;
169 int disable_forwarding;
170 u_int num_allow_users;
172 u_int num_deny_users;
174 u_int num_allow_groups;
176 u_int num_deny_groups;
179 u_int num_subsystems;
180 char *subsystem_name[MAX_SUBSYSTEMS];
181 char *subsystem_command[MAX_SUBSYSTEMS];
182 char *subsystem_args[MAX_SUBSYSTEMS];
184 u_int num_accept_env;
189 int max_startups_begin;
190 int max_startups_rate;
192 int per_source_max_startups;
193 int per_source_masklen_ipv4;
194 int per_source_masklen_ipv6;
199 int client_alive_interval;
203 int client_alive_count_max;
209 u_int num_authkeys_files;
210 char **authorized_keys_files;
212 char *adm_forced_command;
215 int permit_pam_user_change;
217 int tcp_rcv_buf_poll;
221 int disable_multithreaded;
226 char **permitted_opens;
227 u_int num_permitted_opens;
228 char **permitted_listens;
229 u_int num_permitted_listens;
231 char *chroot_directory;
232 char *revoked_keys_file;
233 char *trusted_user_ca_keys;
234 char *authorized_keys_command;
235 char *authorized_keys_command_user;
236 char *authorized_principals_file;
237 char *authorized_principals_command;
238 char *authorized_principals_command_user;
243 char *version_addendum;
245 u_int num_auth_methods;
248 int fingerprint_hash;
249 int expose_userauth_info;
250 u_int64_t timing_secret;
252 int required_rsa_size;
254 char **channel_timeouts;
255 u_int num_channel_timeouts;
257 int unused_connection_timeout;
261 struct connection_info {
265 const char *laddress;
273 struct include_item {
276 struct sshbuf *contents;
277 TAILQ_ENTRY(include_item) entry;
279 TAILQ_HEAD(include_list, include_item);
291 #define COPY_MATCH_STRING_OPTS() do { \
292 M_CP_STROPT(banner); \
293 M_CP_STROPT(trusted_user_ca_keys); \
294 M_CP_STROPT(revoked_keys_file); \
295 M_CP_STROPT(authorized_keys_command); \
296 M_CP_STROPT(authorized_keys_command_user); \
297 M_CP_STROPT(authorized_principals_file); \
298 M_CP_STROPT(authorized_principals_command); \
299 M_CP_STROPT(authorized_principals_command_user); \
300 M_CP_STROPT(hostbased_accepted_algos); \
301 M_CP_STROPT(pubkey_accepted_algos); \
302 M_CP_STROPT(ca_sign_algorithms); \
303 M_CP_STROPT(routing_domain); \
304 M_CP_STROPT(permit_user_env_allowlist); \
305 M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
306 M_CP_STRARRAYOPT(allow_users, num_allow_users); \
307 M_CP_STRARRAYOPT(deny_users, num_deny_users); \
308 M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
309 M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
310 M_CP_STRARRAYOPT(accept_env, num_accept_env); \
311 M_CP_STRARRAYOPT(setenv, num_setenv); \
312 M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
313 M_CP_STRARRAYOPT(permitted_opens, num_permitted_opens); \
314 M_CP_STRARRAYOPT(permitted_listens, num_permitted_listens); \
315 M_CP_STRARRAYOPT(channel_timeouts, num_channel_timeouts); \
316 M_CP_STRARRAYOPT(log_verbose, num_log_verbose); \
319 struct connection_info *get_connection_info(
struct ssh *,
int,
int);
320 void initialize_server_options(ServerOptions *);
321 void fill_default_server_options(ServerOptions *);
322 int process_server_config_line(ServerOptions *,
char *,
const char *,
int,
323 int *,
struct connection_info *,
struct include_list *includes);
324 void process_permitopen(
struct ssh *ssh, ServerOptions *options);
325 void process_channel_timeouts(
struct ssh *ssh, ServerOptions *);
326 void load_server_config(
const char *,
struct sshbuf *);
327 void parse_server_config(ServerOptions *,
const char *,
struct sshbuf *,
328 struct include_list *includes,
struct connection_info *,
int);
329 void parse_server_match_config(ServerOptions *,
330 struct include_list *includes,
struct connection_info *);
331 int parse_server_match_testspec(
struct connection_info *,
char *);
332 int server_match_spec_complete(
struct connection_info *);
333 void copy_set_server_options(ServerOptions *, ServerOptions *,
int);
334 void dump_config(ServerOptions *);
335 char *derelativise_path(
const char *);
336 void servconf_add_hostkey(
const char *,
const int,
337 ServerOptions *,
const char *path,
int);
338 void servconf_add_hostcert(
const char *,
const int,
339 ServerOptions *,
const char *path);