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 challenge_response_authentication;
162 int permit_empty_passwd;
165 char *permit_user_env_allowlist;
167 int allow_tcp_forwarding;
168 int allow_streamlocal_forwarding;
169 int allow_agent_forwarding;
170 int disable_forwarding;
171 u_int num_allow_users;
173 u_int num_deny_users;
175 u_int num_allow_groups;
177 u_int num_deny_groups;
180 u_int num_subsystems;
181 char *subsystem_name[MAX_SUBSYSTEMS];
182 char *subsystem_command[MAX_SUBSYSTEMS];
183 char *subsystem_args[MAX_SUBSYSTEMS];
185 u_int num_accept_env;
190 int max_startups_begin;
191 int max_startups_rate;
193 int per_source_max_startups;
194 int per_source_masklen_ipv4;
195 int per_source_masklen_ipv6;
200 int client_alive_interval;
204 int client_alive_count_max;
210 u_int num_authkeys_files;
211 char **authorized_keys_files;
213 char *adm_forced_command;
216 int permit_pam_user_change;
218 int tcp_rcv_buf_poll;
222 int disable_multithreaded;
227 char **permitted_opens;
228 u_int num_permitted_opens;
229 char **permitted_listens;
230 u_int num_permitted_listens;
232 char *chroot_directory;
233 char *revoked_keys_file;
234 char *trusted_user_ca_keys;
235 char *authorized_keys_command;
236 char *authorized_keys_command_user;
237 char *authorized_principals_file;
238 char *authorized_principals_command;
239 char *authorized_principals_command_user;
244 char *version_addendum;
246 u_int num_auth_methods;
249 int fingerprint_hash;
250 int expose_userauth_info;
251 u_int64_t timing_secret;
256 struct connection_info {
260 const char *laddress;
268 struct include_item {
271 struct sshbuf *contents;
272 TAILQ_ENTRY(include_item) entry;
274 TAILQ_HEAD(include_list, include_item);
286 #define COPY_MATCH_STRING_OPTS() do { \
287 M_CP_STROPT(banner); \
288 M_CP_STROPT(trusted_user_ca_keys); \
289 M_CP_STROPT(revoked_keys_file); \
290 M_CP_STROPT(authorized_keys_command); \
291 M_CP_STROPT(authorized_keys_command_user); \
292 M_CP_STROPT(authorized_principals_file); \
293 M_CP_STROPT(authorized_principals_command); \
294 M_CP_STROPT(authorized_principals_command_user); \
295 M_CP_STROPT(hostbased_accepted_algos); \
296 M_CP_STROPT(pubkey_accepted_algos); \
297 M_CP_STROPT(ca_sign_algorithms); \
298 M_CP_STROPT(routing_domain); \
299 M_CP_STROPT(permit_user_env_allowlist); \
300 M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
301 M_CP_STRARRAYOPT(allow_users, num_allow_users); \
302 M_CP_STRARRAYOPT(deny_users, num_deny_users); \
303 M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
304 M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
305 M_CP_STRARRAYOPT(accept_env, num_accept_env); \
306 M_CP_STRARRAYOPT(setenv, num_setenv); \
307 M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
308 M_CP_STRARRAYOPT(permitted_opens, num_permitted_opens); \
309 M_CP_STRARRAYOPT(permitted_listens, num_permitted_listens); \
310 M_CP_STRARRAYOPT(log_verbose, num_log_verbose); \
313 struct connection_info *get_connection_info(
struct ssh *,
int,
int);
314 void initialize_server_options(ServerOptions *);
315 void fill_default_server_options(ServerOptions *);
316 int process_server_config_line(ServerOptions *,
char *,
const char *,
int,
317 int *,
struct connection_info *,
struct include_list *includes);
318 void process_permitopen(
struct ssh *ssh, ServerOptions *options);
319 void load_server_config(
const char *,
struct sshbuf *);
320 void parse_server_config(ServerOptions *,
const char *,
struct sshbuf *,
321 struct include_list *includes,
struct connection_info *);
322 void parse_server_match_config(ServerOptions *,
323 struct include_list *includes,
struct connection_info *);
324 int parse_server_match_testspec(
struct connection_info *,
char *);
325 int server_match_spec_complete(
struct connection_info *);
326 void copy_set_server_options(ServerOptions *, ServerOptions *,
int);
327 void dump_config(ServerOptions *);
328 char *derelativise_path(
const char *);
329 void servconf_add_hostkey(
const char *,
const int,
330 ServerOptions *,
const char *path,
int);
331 void servconf_add_hostcert(
const char *,
const int,
332 ServerOptions *,
const char *path);