servconf.h revision 248619
1248619Sdes/* $OpenBSD: servconf.h,v 1.107 2013/01/03 05:49:36 djm Exp $ */
2224642Sbrooks/* $FreeBSD: head/crypto/openssh/servconf.h 248619 2013-03-22 17:55:38Z des $ */
392559Sdes
457429Smarkm/*
557429Smarkm * Author: Tatu Ylonen <ylo@cs.hut.fi>
657429Smarkm * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
757429Smarkm *                    All rights reserved
857429Smarkm * Definitions for server configuration data and for the functions reading it.
960576Skris *
1065674Skris * As far as I am concerned, the code I have written for this software
1165674Skris * can be used freely for any purpose.  Any derived versions of this
1265674Skris * software must be clearly marked as such, and if the derived work is
1365674Skris * incompatible with the protocol description in the RFC file, it must be
1465674Skris * called by a name other than "ssh" or "Secure Shell".
1557429Smarkm */
1657429Smarkm
1757429Smarkm#ifndef SERVCONF_H
1857429Smarkm#define SERVCONF_H
1957429Smarkm
2057429Smarkm#define MAX_PORTS		256	/* Max # ports. */
2157429Smarkm
2257429Smarkm#define MAX_ALLOW_USERS		256	/* Max # users on allow list. */
2357429Smarkm#define MAX_DENY_USERS		256	/* Max # users on deny list. */
2457429Smarkm#define MAX_ALLOW_GROUPS	256	/* Max # groups on allow list. */
2557429Smarkm#define MAX_DENY_GROUPS		256	/* Max # groups on deny list. */
2665674Skris#define MAX_SUBSYSTEMS		256	/* Max # subsystems. */
2776262Sgreen#define MAX_HOSTKEYS		256	/* Max # hostkeys. */
28204917Sdes#define MAX_HOSTCERTS		256	/* Max # host certificates. */
29137019Sdes#define MAX_ACCEPT_ENV		256	/* Max # of env vars. */
30162856Sdes#define MAX_MATCH_GROUPS	256	/* Max # of groups for Match. */
31226046Sdes#define MAX_AUTHKEYS_FILES	256	/* Max # of authorized_keys files. */
32248619Sdes#define MAX_AUTH_METHODS	256	/* Max # of AuthenticationMethods. */
3357429Smarkm
3476262Sgreen/* permit_root_login */
3576262Sgreen#define	PERMIT_NOT_SET		-1
3676262Sgreen#define	PERMIT_NO		0
3776262Sgreen#define	PERMIT_FORCED_ONLY	1
3876262Sgreen#define	PERMIT_NO_PASSWD	2
3976262Sgreen#define	PERMIT_YES		3
4076262Sgreen
41226046Sdes/* use_privsep */
42226046Sdes#define PRIVSEP_OFF		0
43226046Sdes#define PRIVSEP_ON		1
44240075Sdes#define PRIVSEP_NOSANDBOX	2
45226046Sdes
46248619Sdes/* AllowTCPForwarding */
47248619Sdes#define FORWARD_DENY		0
48248619Sdes#define FORWARD_REMOTE		(1)
49248619Sdes#define FORWARD_LOCAL		(1<<1)
50248619Sdes#define FORWARD_ALLOW		(FORWARD_REMOTE|FORWARD_LOCAL)
51248619Sdes
52137019Sdes#define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
53181111Sdes#define DEFAULT_SESSIONS_MAX	10	/* Default for MaxSessions */
5476262Sgreen
55181111Sdes/* Magic name for internal sftp-server */
56181111Sdes#define INTERNAL_SFTP_NAME	"internal-sftp"
57181111Sdes
5857429Smarkmtypedef struct {
59192595Sdes	u_int	num_ports;
60192595Sdes	u_int	ports_from_cmdline;
61192595Sdes	int	ports[MAX_PORTS];	/* Port number to listen on. */
6257429Smarkm	char   *listen_addr;		/* Address on which the server listens. */
6357429Smarkm	struct addrinfo *listen_addrs;	/* Addresses on which the server listens. */
64147005Sdes	int     address_family;		/* Address family used by the server. */
6576262Sgreen	char   *host_key_files[MAX_HOSTKEYS];	/* Files containing host keys. */
6676262Sgreen	int     num_host_key_files;     /* Number of files for host keys. */
67204917Sdes	char   *host_cert_files[MAX_HOSTCERTS];	/* Files containing host certs. */
68204917Sdes	int     num_host_cert_files;     /* Number of files for host certs. */
6960576Skris	char   *pid_file;	/* Where to put our pid */
7057429Smarkm	int     server_key_bits;/* Size of the server key. */
7157429Smarkm	int     login_grace_time;	/* Disconnect if no auth in this time
7257429Smarkm					 * (sec). */
7357429Smarkm	int     key_regeneration_time;	/* Server key lifetime (seconds). */
7476262Sgreen	int     permit_root_login;	/* PERMIT_*, see above */
7557429Smarkm	int     ignore_rhosts;	/* Ignore .rhosts and .shosts. */
7657429Smarkm	int     ignore_user_known_hosts;	/* Ignore ~/.ssh/known_hosts
7757429Smarkm						 * for RhostsRsaAuth */
7857429Smarkm	int     print_motd;	/* If true, print /etc/motd. */
7976262Sgreen	int	print_lastlog;	/* If true, print lastlog */
8057429Smarkm	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */
8157429Smarkm	int     x11_display_offset;	/* What DISPLAY number to start
8257429Smarkm					 * searching at */
8392559Sdes	int     x11_use_localhost;	/* If true, use localhost for fake X11 server. */
8465674Skris	char   *xauth_location;	/* Location of xauth program */
8557429Smarkm	int     strict_modes;	/* If true, require string home dir modes. */
86126277Sdes	int     tcp_keep_alive;	/* If true, set SO_KEEPALIVE. */
87221420Sdes	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
88221420Sdes	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
8976262Sgreen	char   *ciphers;	/* Supported SSH2 ciphers. */
9076262Sgreen	char   *macs;		/* Supported SSH2 macs. */
91221420Sdes	char   *kex_algorithms;	/* SSH2 kex methods in order of preference. */
9276262Sgreen	int	protocol;	/* Supported protocol versions. */
9360576Skris	int     gateway_ports;	/* If true, allow remote connects to forwarded ports. */
9457429Smarkm	SyslogFacility log_facility;	/* Facility for system logging. */
9557429Smarkm	LogLevel log_level;	/* Level for system logging. */
9657429Smarkm	int     rhosts_rsa_authentication;	/* If true, permit rhosts RSA
9757429Smarkm						 * authentication. */
9876262Sgreen	int     hostbased_authentication;	/* If true, permit ssh2 hostbased auth */
9976262Sgreen	int     hostbased_uses_name_from_packet_only; /* experimental */
10057429Smarkm	int     rsa_authentication;	/* If true, permit RSA authentication. */
10192559Sdes	int     pubkey_authentication;	/* If true, permit ssh2 pubkey authentication. */
10292559Sdes	int     kerberos_authentication;	/* If true, permit Kerberos
10392559Sdes						 * authentication. */
10492559Sdes	int     kerberos_or_local_passwd;	/* If true, permit kerberos
10557429Smarkm						 * and any other password
10657429Smarkm						 * authentication mechanism,
10757429Smarkm						 * such as SecurID or
10857429Smarkm						 * /etc/passwd */
10992559Sdes	int     kerberos_ticket_cleanup;	/* If true, destroy ticket
11057429Smarkm						 * file on logout. */
111126277Sdes	int     kerberos_get_afs_token;		/* If true, try to get AFS token if
112126277Sdes						 * authenticated with Kerberos. */
113124211Sdes	int     gss_authentication;	/* If true, permit GSSAPI authentication */
114124211Sdes	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
11557429Smarkm	int     password_authentication;	/* If true, permit password
11657429Smarkm						 * authentication. */
11769591Sgreen	int     kbd_interactive_authentication;	/* If true, permit */
11892559Sdes	int     challenge_response_authentication;
119192595Sdes	int     zero_knowledge_password_authentication;
120192595Sdes					/* If true, permit jpake auth */
12157429Smarkm	int     permit_empty_passwd;	/* If false, do not permit empty
12257429Smarkm					 * passwords. */
123106130Sdes	int     permit_user_env;	/* If true, read ~/.ssh/environment */
12457429Smarkm	int     use_login;	/* If true, login(1) is used */
12598684Sdes	int     compression;	/* If true, compression is allowed */
126248619Sdes	int	allow_tcp_forwarding; /* One of FORWARD_* */
127181111Sdes	int	allow_agent_forwarding;
12876262Sgreen	u_int num_allow_users;
12957429Smarkm	char   *allow_users[MAX_ALLOW_USERS];
13076262Sgreen	u_int num_deny_users;
13157429Smarkm	char   *deny_users[MAX_DENY_USERS];
13276262Sgreen	u_int num_allow_groups;
13357429Smarkm	char   *allow_groups[MAX_ALLOW_GROUPS];
13476262Sgreen	u_int num_deny_groups;
13557429Smarkm	char   *deny_groups[MAX_DENY_GROUPS];
13665674Skris
13776262Sgreen	u_int num_subsystems;
13865674Skris	char   *subsystem_name[MAX_SUBSYSTEMS];
13965674Skris	char   *subsystem_command[MAX_SUBSYSTEMS];
140162856Sdes	char   *subsystem_args[MAX_SUBSYSTEMS];
14165674Skris
142137019Sdes	u_int num_accept_env;
143137019Sdes	char   *accept_env[MAX_ACCEPT_ENV];
144137019Sdes
14565674Skris	int	max_startups_begin;
14665674Skris	int	max_startups_rate;
14765674Skris	int	max_startups;
148137019Sdes	int	max_authtries;
149181111Sdes	int	max_sessions;
15076262Sgreen	char   *banner;			/* SSH-2 banner message */
151124211Sdes	int	use_dns;
15276262Sgreen	int	client_alive_interval;	/*
15392559Sdes					 * poke the client this often to
15492559Sdes					 * see if it's still there
15576262Sgreen					 */
15676262Sgreen	int	client_alive_count_max;	/*
15792559Sdes					 * If the client is unresponsive
15892559Sdes					 * for this many intervals above,
15992559Sdes					 * disconnect the session
16076262Sgreen					 */
16165674Skris
162226046Sdes	u_int num_authkeys_files;	/* Files containing public keys */
163226046Sdes	char   *authorized_keys_files[MAX_AUTHKEYS_FILES];
164157019Sdes
165162856Sdes	char   *adm_forced_command;
166162856Sdes
167124211Sdes	int	use_pam;		/* Enable auth via PAM */
168157019Sdes
169157019Sdes	int	permit_tun;
170162856Sdes
171162856Sdes	int	num_permitted_opens;
172181111Sdes
173181111Sdes	char   *chroot_directory;
174204917Sdes	char   *revoked_keys_file;
175204917Sdes	char   *trusted_user_ca_keys;
176215116Sdes	char   *authorized_principals_file;
177248619Sdes	char   *authorized_keys_command;
178248619Sdes	char   *authorized_keys_command_user;
179224638Sbrooks
180240075Sdes	char   *version_addendum;	/* Appended to SSH banner */
181240075Sdes
182224638Sbrooks	int	hpn_disabled;		/* Disable HPN functionality. */
183224638Sbrooks	int	hpn_buffer_size;	/* Set HPN buffer size - default 2MB.*/
184224638Sbrooks	int	tcp_rcv_buf_poll;	/* Poll TCP rcv window in autotuning
185224638Sbrooks					 * kernels. */
186248619Sdes	u_int	num_auth_methods;
187248619Sdes	char   *auth_methods[MAX_AUTH_METHODS];
188224638Sbrooks
189224638Sbrooks#ifdef	NONE_CIPHER_ENABLED
190224638Sbrooks	int	none_enabled;		/* Enable NONE cipher switch. */
191224638Sbrooks#endif
19257429Smarkm}       ServerOptions;
19357429Smarkm
194240075Sdes/* Information about the incoming connection as used by Match */
195240075Sdesstruct connection_info {
196240075Sdes	const char *user;
197240075Sdes	const char *host;	/* possibly resolved hostname */
198240075Sdes	const char *address; 	/* remote address */
199240075Sdes	const char *laddress;	/* local address */
200240075Sdes	int lport;		/* local port */
201240075Sdes};
202240075Sdes
203240075Sdes
204226046Sdes/*
205226046Sdes * These are string config options that must be copied between the
206226046Sdes * Match sub-config and the main config, and must be sent from the
207226046Sdes * privsep slave to the privsep master. We use a macro to ensure all
208226046Sdes * the options are copied and the copies are done in the correct order.
209226046Sdes */
210226046Sdes#define COPY_MATCH_STRING_OPTS() do { \
211226046Sdes		M_CP_STROPT(banner); \
212226046Sdes		M_CP_STROPT(trusted_user_ca_keys); \
213226046Sdes		M_CP_STROPT(revoked_keys_file); \
214226046Sdes		M_CP_STROPT(authorized_principals_file); \
215248619Sdes		M_CP_STROPT(authorized_keys_command); \
216248619Sdes		M_CP_STROPT(authorized_keys_command_user); \
217226046Sdes		M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
218240075Sdes		M_CP_STRARRAYOPT(allow_users, num_allow_users); \
219240075Sdes		M_CP_STRARRAYOPT(deny_users, num_deny_users); \
220240075Sdes		M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
221240075Sdes		M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
222240075Sdes		M_CP_STRARRAYOPT(accept_env, num_accept_env); \
223248619Sdes		M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
224226046Sdes	} while (0)
225226046Sdes
226240075Sdesstruct connection_info *get_connection_info(int, int);
22792559Sdesvoid	 initialize_server_options(ServerOptions *);
22892559Sdesvoid	 fill_default_server_options(ServerOptions *);
229162856Sdesint	 process_server_config_line(ServerOptions *, char *, const char *, int,
230240075Sdes	     int *, struct connection_info *);
231137019Sdesvoid	 load_server_config(const char *, Buffer *);
232162856Sdesvoid	 parse_server_config(ServerOptions *, const char *, Buffer *,
233240075Sdes	     struct connection_info *);
234240075Sdesvoid	 parse_server_match_config(ServerOptions *, struct connection_info *);
235240075Sdesint	 parse_server_match_testspec(struct connection_info *, char *);
236240075Sdesint	 server_match_spec_complete(struct connection_info *);
237181111Sdesvoid	 copy_set_server_options(ServerOptions *, ServerOptions *, int);
238181111Sdesvoid	 dump_config(ServerOptions *);
239204917Sdeschar	*derelativise_path(const char *);
24057429Smarkm
24157429Smarkm#endif				/* SERVCONF_H */
242