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;
255 struct connection_info {
259 const char *laddress;
267 struct include_item {
270 struct sshbuf *contents;
271 TAILQ_ENTRY(include_item) entry;
273 TAILQ_HEAD(include_list, include_item);
285 #define COPY_MATCH_STRING_OPTS() do { \
286 M_CP_STROPT(banner); \
287 M_CP_STROPT(trusted_user_ca_keys); \
288 M_CP_STROPT(revoked_keys_file); \
289 M_CP_STROPT(authorized_keys_command); \
290 M_CP_STROPT(authorized_keys_command_user); \
291 M_CP_STROPT(authorized_principals_file); \
292 M_CP_STROPT(authorized_principals_command); \
293 M_CP_STROPT(authorized_principals_command_user); \
294 M_CP_STROPT(hostbased_accepted_algos); \
295 M_CP_STROPT(pubkey_accepted_algos); \
296 M_CP_STROPT(ca_sign_algorithms); \
297 M_CP_STROPT(routing_domain); \
298 M_CP_STROPT(permit_user_env_allowlist); \
299 M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
300 M_CP_STRARRAYOPT(allow_users, num_allow_users); \
301 M_CP_STRARRAYOPT(deny_users, num_deny_users); \
302 M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
303 M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
304 M_CP_STRARRAYOPT(accept_env, num_accept_env); \
305 M_CP_STRARRAYOPT(setenv, num_setenv); \
306 M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
307 M_CP_STRARRAYOPT(permitted_opens, num_permitted_opens); \
308 M_CP_STRARRAYOPT(permitted_listens, num_permitted_listens); \
309 M_CP_STRARRAYOPT(log_verbose, num_log_verbose); \
312 struct connection_info *get_connection_info(
struct ssh *,
int,
int);
313 void initialize_server_options(ServerOptions *);
314 void fill_default_server_options(ServerOptions *);
315 int process_server_config_line(ServerOptions *,
char *,
const char *,
int,
316 int *,
struct connection_info *,
struct include_list *includes);
317 void process_permitopen(
struct ssh *ssh, ServerOptions *options);
318 void load_server_config(
const char *,
struct sshbuf *);
319 void parse_server_config(ServerOptions *,
const char *,
struct sshbuf *,
320 struct include_list *includes,
struct connection_info *);
321 void parse_server_match_config(ServerOptions *,
322 struct include_list *includes,
struct connection_info *);
323 int parse_server_match_testspec(
struct connection_info *,
char *);
324 int server_match_spec_complete(
struct connection_info *);
325 void copy_set_server_options(ServerOptions *, ServerOptions *,
int);
326 void dump_config(ServerOptions *);
327 char *derelativise_path(
const char *);
328 void servconf_add_hostkey(
const char *,
const int,
329 ServerOptions *,
const char *path,
int);
330 void servconf_add_hostcert(
const char *,
const int,
331 ServerOptions *,
const char *path);