xref: /freebsd/crypto/openssh/servconf.h (revision e146993e33182e13df79b5a957f2734f663fd836)
1*e146993eSDag-Erling Smørgrav /* $OpenBSD: servconf.h,v 1.99 2011/06/22 21:57:01 djm Exp $ */
28eb43d35SBrooks Davis /* $FreeBSD$ */
3af12a3e7SDag-Erling Smørgrav 
4511b41d2SMark Murray /*
5511b41d2SMark Murray  * Author: Tatu Ylonen <ylo@cs.hut.fi>
6511b41d2SMark Murray  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
7511b41d2SMark Murray  *                    All rights reserved
8511b41d2SMark Murray  * Definitions for server configuration data and for the functions reading it.
9511b41d2SMark Murray  *
10c2d3a559SKris Kennaway  * As far as I am concerned, the code I have written for this software
11c2d3a559SKris Kennaway  * can be used freely for any purpose.  Any derived versions of this
12c2d3a559SKris Kennaway  * software must be clearly marked as such, and if the derived work is
13c2d3a559SKris Kennaway  * incompatible with the protocol description in the RFC file, it must be
14c2d3a559SKris Kennaway  * called by a name other than "ssh" or "Secure Shell".
15511b41d2SMark Murray  */
16511b41d2SMark Murray 
17511b41d2SMark Murray #ifndef SERVCONF_H
18511b41d2SMark Murray #define SERVCONF_H
19511b41d2SMark Murray 
20511b41d2SMark Murray #define MAX_PORTS		256	/* Max # ports. */
21511b41d2SMark Murray 
22511b41d2SMark Murray #define MAX_ALLOW_USERS		256	/* Max # users on allow list. */
23511b41d2SMark Murray #define MAX_DENY_USERS		256	/* Max # users on deny list. */
24511b41d2SMark Murray #define MAX_ALLOW_GROUPS	256	/* Max # groups on allow list. */
25511b41d2SMark Murray #define MAX_DENY_GROUPS		256	/* Max # groups on deny list. */
26c2d3a559SKris Kennaway #define MAX_SUBSYSTEMS		256	/* Max # subsystems. */
27ca3176e7SBrian Feldman #define MAX_HOSTKEYS		256	/* Max # hostkeys. */
28b15c8340SDag-Erling Smørgrav #define MAX_HOSTCERTS		256	/* Max # host certificates. */
2921e764dfSDag-Erling Smørgrav #define MAX_ACCEPT_ENV		256	/* Max # of env vars. */
30333ee039SDag-Erling Smørgrav #define MAX_MATCH_GROUPS	256	/* Max # of groups for Match. */
31*e146993eSDag-Erling Smørgrav #define MAX_AUTHKEYS_FILES	256	/* Max # of authorized_keys files. */
32ca3176e7SBrian Feldman 
33ca3176e7SBrian Feldman /* permit_root_login */
34ca3176e7SBrian Feldman #define	PERMIT_NOT_SET		-1
35ca3176e7SBrian Feldman #define	PERMIT_NO		0
36ca3176e7SBrian Feldman #define	PERMIT_FORCED_ONLY	1
37ca3176e7SBrian Feldman #define	PERMIT_NO_PASSWD	2
38ca3176e7SBrian Feldman #define	PERMIT_YES		3
39ca3176e7SBrian Feldman 
40*e146993eSDag-Erling Smørgrav /* use_privsep */
41*e146993eSDag-Erling Smørgrav #define PRIVSEP_OFF		0
42*e146993eSDag-Erling Smørgrav #define PRIVSEP_ON		1
43*e146993eSDag-Erling Smørgrav #define PRIVSEP_SANDBOX		2
44*e146993eSDag-Erling Smørgrav 
4521e764dfSDag-Erling Smørgrav #define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
46d4af9e69SDag-Erling Smørgrav #define DEFAULT_SESSIONS_MAX	10	/* Default for MaxSessions */
47d4af9e69SDag-Erling Smørgrav 
48d4af9e69SDag-Erling Smørgrav /* Magic name for internal sftp-server */
49d4af9e69SDag-Erling Smørgrav #define INTERNAL_SFTP_NAME	"internal-sftp"
50511b41d2SMark Murray 
51511b41d2SMark Murray typedef struct {
52ca3176e7SBrian Feldman 	u_int	num_ports;
53ca3176e7SBrian Feldman 	u_int	ports_from_cmdline;
54cce7d346SDag-Erling Smørgrav 	int	ports[MAX_PORTS];	/* Port number to listen on. */
55511b41d2SMark Murray 	char   *listen_addr;		/* Address on which the server listens. */
56511b41d2SMark Murray 	struct addrinfo *listen_addrs;	/* Addresses on which the server listens. */
57aa49c926SDag-Erling Smørgrav 	int     address_family;		/* Address family used by the server. */
58ca3176e7SBrian Feldman 	char   *host_key_files[MAX_HOSTKEYS];	/* Files containing host keys. */
59ca3176e7SBrian Feldman 	int     num_host_key_files;     /* Number of files for host keys. */
60b15c8340SDag-Erling Smørgrav 	char   *host_cert_files[MAX_HOSTCERTS];	/* Files containing host certs. */
61b15c8340SDag-Erling Smørgrav 	int     num_host_cert_files;     /* Number of files for host certs. */
62e8aafc91SKris Kennaway 	char   *pid_file;	/* Where to put our pid */
63511b41d2SMark Murray 	int     server_key_bits;/* Size of the server key. */
64511b41d2SMark Murray 	int     login_grace_time;	/* Disconnect if no auth in this time
65511b41d2SMark Murray 					 * (sec). */
66511b41d2SMark Murray 	int     key_regeneration_time;	/* Server key lifetime (seconds). */
67ca3176e7SBrian Feldman 	int     permit_root_login;	/* PERMIT_*, see above */
68511b41d2SMark Murray 	int     ignore_rhosts;	/* Ignore .rhosts and .shosts. */
69511b41d2SMark Murray 	int     ignore_user_known_hosts;	/* Ignore ~/.ssh/known_hosts
70511b41d2SMark Murray 						 * for RhostsRsaAuth */
71511b41d2SMark Murray 	int     print_motd;	/* If true, print /etc/motd. */
72ca3176e7SBrian Feldman 	int	print_lastlog;	/* If true, print lastlog */
73511b41d2SMark Murray 	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */
74511b41d2SMark Murray 	int     x11_display_offset;	/* What DISPLAY number to start
75511b41d2SMark Murray 					 * searching at */
76af12a3e7SDag-Erling Smørgrav 	int     x11_use_localhost;	/* If true, use localhost for fake X11 server. */
77c2d3a559SKris Kennaway 	char   *xauth_location;	/* Location of xauth program */
78511b41d2SMark Murray 	int     strict_modes;	/* If true, require string home dir modes. */
791ec0d754SDag-Erling Smørgrav 	int     tcp_keep_alive;	/* If true, set SO_KEEPALIVE. */
804a421b63SDag-Erling Smørgrav 	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
814a421b63SDag-Erling Smørgrav 	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
82ca3176e7SBrian Feldman 	char   *ciphers;	/* Supported SSH2 ciphers. */
83ca3176e7SBrian Feldman 	char   *macs;		/* Supported SSH2 macs. */
844a421b63SDag-Erling Smørgrav 	char   *kex_algorithms;	/* SSH2 kex methods in order of preference. */
85ca3176e7SBrian Feldman 	int	protocol;	/* Supported protocol versions. */
86e8aafc91SKris Kennaway 	int     gateway_ports;	/* If true, allow remote connects to forwarded ports. */
87511b41d2SMark Murray 	SyslogFacility log_facility;	/* Facility for system logging. */
88511b41d2SMark Murray 	LogLevel log_level;	/* Level for system logging. */
89511b41d2SMark Murray 	int     rhosts_rsa_authentication;	/* If true, permit rhosts RSA
90511b41d2SMark Murray 						 * authentication. */
91ca3176e7SBrian Feldman 	int     hostbased_authentication;	/* If true, permit ssh2 hostbased auth */
92ca3176e7SBrian Feldman 	int     hostbased_uses_name_from_packet_only; /* experimental */
93511b41d2SMark Murray 	int     rsa_authentication;	/* If true, permit RSA authentication. */
94ca3176e7SBrian Feldman 	int     pubkey_authentication;	/* If true, permit ssh2 pubkey authentication. */
95af12a3e7SDag-Erling Smørgrav 	int     kerberos_authentication;	/* If true, permit Kerberos
96af12a3e7SDag-Erling Smørgrav 						 * authentication. */
97af12a3e7SDag-Erling Smørgrav 	int     kerberos_or_local_passwd;	/* If true, permit kerberos
98511b41d2SMark Murray 						 * and any other password
99511b41d2SMark Murray 						 * authentication mechanism,
100511b41d2SMark Murray 						 * such as SecurID or
101511b41d2SMark Murray 						 * /etc/passwd */
102af12a3e7SDag-Erling Smørgrav 	int     kerberos_ticket_cleanup;	/* If true, destroy ticket
103511b41d2SMark Murray 						 * file on logout. */
1041ec0d754SDag-Erling Smørgrav 	int     kerberos_get_afs_token;		/* If true, try to get AFS token if
1051ec0d754SDag-Erling Smørgrav 						 * authenticated with Kerberos. */
106cf2b5f3bSDag-Erling Smørgrav 	int     gss_authentication;	/* If true, permit GSSAPI authentication */
107cf2b5f3bSDag-Erling Smørgrav 	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
108511b41d2SMark Murray 	int     password_authentication;	/* If true, permit password
109511b41d2SMark Murray 						 * authentication. */
11009958426SBrian Feldman 	int     kbd_interactive_authentication;	/* If true, permit */
111af12a3e7SDag-Erling Smørgrav 	int     challenge_response_authentication;
112cce7d346SDag-Erling Smørgrav 	int     zero_knowledge_password_authentication;
113cce7d346SDag-Erling Smørgrav 					/* If true, permit jpake auth */
114511b41d2SMark Murray 	int     permit_empty_passwd;	/* If false, do not permit empty
115511b41d2SMark Murray 					 * passwords. */
116f388f5efSDag-Erling Smørgrav 	int     permit_user_env;	/* If true, read ~/.ssh/environment */
117511b41d2SMark Murray 	int     use_login;	/* If true, login(1) is used */
11880628bacSDag-Erling Smørgrav 	int     compression;	/* If true, compression is allowed */
11909958426SBrian Feldman 	int	allow_tcp_forwarding;
120d4af9e69SDag-Erling Smørgrav 	int	allow_agent_forwarding;
121ca3176e7SBrian Feldman 	u_int num_allow_users;
122511b41d2SMark Murray 	char   *allow_users[MAX_ALLOW_USERS];
123ca3176e7SBrian Feldman 	u_int num_deny_users;
124511b41d2SMark Murray 	char   *deny_users[MAX_DENY_USERS];
125ca3176e7SBrian Feldman 	u_int num_allow_groups;
126511b41d2SMark Murray 	char   *allow_groups[MAX_ALLOW_GROUPS];
127ca3176e7SBrian Feldman 	u_int num_deny_groups;
128511b41d2SMark Murray 	char   *deny_groups[MAX_DENY_GROUPS];
129c2d3a559SKris Kennaway 
130ca3176e7SBrian Feldman 	u_int num_subsystems;
131c2d3a559SKris Kennaway 	char   *subsystem_name[MAX_SUBSYSTEMS];
132c2d3a559SKris Kennaway 	char   *subsystem_command[MAX_SUBSYSTEMS];
133333ee039SDag-Erling Smørgrav 	char   *subsystem_args[MAX_SUBSYSTEMS];
134c2d3a559SKris Kennaway 
13521e764dfSDag-Erling Smørgrav 	u_int num_accept_env;
13621e764dfSDag-Erling Smørgrav 	char   *accept_env[MAX_ACCEPT_ENV];
13721e764dfSDag-Erling Smørgrav 
138c2d3a559SKris Kennaway 	int	max_startups_begin;
139c2d3a559SKris Kennaway 	int	max_startups_rate;
140c2d3a559SKris Kennaway 	int	max_startups;
14121e764dfSDag-Erling Smørgrav 	int	max_authtries;
142d4af9e69SDag-Erling Smørgrav 	int	max_sessions;
143ca3176e7SBrian Feldman 	char   *banner;			/* SSH-2 banner message */
144cf2b5f3bSDag-Erling Smørgrav 	int	use_dns;
145ca3176e7SBrian Feldman 	int	client_alive_interval;	/*
146ca3176e7SBrian Feldman 					 * poke the client this often to
147ca3176e7SBrian Feldman 					 * see if it's still there
148ca3176e7SBrian Feldman 					 */
149ca3176e7SBrian Feldman 	int	client_alive_count_max;	/*
150ca3176e7SBrian Feldman 					 * If the client is unresponsive
151af12a3e7SDag-Erling Smørgrav 					 * for this many intervals above,
152af12a3e7SDag-Erling Smørgrav 					 * disconnect the session
153ca3176e7SBrian Feldman 					 */
154c2d3a559SKris Kennaway 
155*e146993eSDag-Erling Smørgrav 	u_int num_authkeys_files;	/* Files containing public keys */
156*e146993eSDag-Erling Smørgrav 	char   *authorized_keys_files[MAX_AUTHKEYS_FILES];
157b74df5b2SDag-Erling Smørgrav 
158333ee039SDag-Erling Smørgrav 	char   *adm_forced_command;
159333ee039SDag-Erling Smørgrav 
160cf2b5f3bSDag-Erling Smørgrav 	int	use_pam;		/* Enable auth via PAM */
161b74df5b2SDag-Erling Smørgrav 
162b74df5b2SDag-Erling Smørgrav 	int	permit_tun;
163333ee039SDag-Erling Smørgrav 
164333ee039SDag-Erling Smørgrav 	int	num_permitted_opens;
165d4af9e69SDag-Erling Smørgrav 
166d4af9e69SDag-Erling Smørgrav 	char   *chroot_directory;
167b15c8340SDag-Erling Smørgrav 	char   *revoked_keys_file;
168b15c8340SDag-Erling Smørgrav 	char   *trusted_user_ca_keys;
169e2f6069cSDag-Erling Smørgrav 	char   *authorized_principals_file;
17089986192SBrooks Davis 
17189986192SBrooks Davis 	int	hpn_disabled;		/* Disable HPN functionality. */
17289986192SBrooks Davis 	int	hpn_buffer_size;	/* Set HPN buffer size - default 2MB.*/
17389986192SBrooks Davis 	int	tcp_rcv_buf_poll;	/* Poll TCP rcv window in autotuning
17489986192SBrooks Davis 					 * kernels. */
17589986192SBrooks Davis 
17689986192SBrooks Davis #ifdef	NONE_CIPHER_ENABLED
17789986192SBrooks Davis 	int	none_enabled;		/* Enable NONE cipher switch. */
17889986192SBrooks Davis #endif
179511b41d2SMark Murray }       ServerOptions;
180511b41d2SMark Murray 
181*e146993eSDag-Erling Smørgrav /*
182*e146993eSDag-Erling Smørgrav  * These are string config options that must be copied between the
183*e146993eSDag-Erling Smørgrav  * Match sub-config and the main config, and must be sent from the
184*e146993eSDag-Erling Smørgrav  * privsep slave to the privsep master. We use a macro to ensure all
185*e146993eSDag-Erling Smørgrav  * the options are copied and the copies are done in the correct order.
186*e146993eSDag-Erling Smørgrav  */
187*e146993eSDag-Erling Smørgrav #define COPY_MATCH_STRING_OPTS() do { \
188*e146993eSDag-Erling Smørgrav 		M_CP_STROPT(banner); \
189*e146993eSDag-Erling Smørgrav 		M_CP_STROPT(trusted_user_ca_keys); \
190*e146993eSDag-Erling Smørgrav 		M_CP_STROPT(revoked_keys_file); \
191*e146993eSDag-Erling Smørgrav 		M_CP_STROPT(authorized_principals_file); \
192*e146993eSDag-Erling Smørgrav 		M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
193*e146993eSDag-Erling Smørgrav 	} while (0)
194*e146993eSDag-Erling Smørgrav 
195af12a3e7SDag-Erling Smørgrav void	 initialize_server_options(ServerOptions *);
196af12a3e7SDag-Erling Smørgrav void	 fill_default_server_options(ServerOptions *);
197333ee039SDag-Erling Smørgrav int	 process_server_config_line(ServerOptions *, char *, const char *, int,
198333ee039SDag-Erling Smørgrav 	     int *, const char *, const char *, const char *);
19921e764dfSDag-Erling Smørgrav void	 load_server_config(const char *, Buffer *);
200333ee039SDag-Erling Smørgrav void	 parse_server_config(ServerOptions *, const char *, Buffer *,
201333ee039SDag-Erling Smørgrav 	     const char *, const char *, const char *);
202333ee039SDag-Erling Smørgrav void	 parse_server_match_config(ServerOptions *, const char *, const char *,
203333ee039SDag-Erling Smørgrav 	     const char *);
204d4af9e69SDag-Erling Smørgrav void	 copy_set_server_options(ServerOptions *, ServerOptions *, int);
205d4af9e69SDag-Erling Smørgrav void	 dump_config(ServerOptions *);
206b15c8340SDag-Erling Smørgrav char	*derelativise_path(const char *);
207511b41d2SMark Murray 
208511b41d2SMark Murray #endif				/* SERVCONF_H */
209