servconf.h revision 255767
1180750Sdes/* $OpenBSD: servconf.h,v 1.109 2013/07/19 07:37:48 markus Exp $ */
2180750Sdes/* $FreeBSD: head/crypto/openssh/servconf.h 255767 2013-09-21 21:36:09Z des $ */
3180750Sdes
4180750Sdes/*
5180750Sdes * Author: Tatu Ylonen <ylo@cs.hut.fi>
6180750Sdes * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
7180750Sdes *                    All rights reserved
8180750Sdes * Definitions for server configuration data and for the functions reading it.
9180750Sdes *
10180750Sdes * As far as I am concerned, the code I have written for this software
11180750Sdes * can be used freely for any purpose.  Any derived versions of this
12180750Sdes * software must be clearly marked as such, and if the derived work is
13180750Sdes * incompatible with the protocol description in the RFC file, it must be
14180750Sdes * called by a name other than "ssh" or "Secure Shell".
15180750Sdes */
16180750Sdes
17180750Sdes#ifndef SERVCONF_H
18180750Sdes#define SERVCONF_H
19180750Sdes
20180750Sdes#define MAX_PORTS		256	/* Max # ports. */
21180750Sdes
22180750Sdes#define MAX_ALLOW_USERS		256	/* Max # users on allow list. */
23180750Sdes#define MAX_DENY_USERS		256	/* Max # users on deny list. */
24180750Sdes#define MAX_ALLOW_GROUPS	256	/* Max # groups on allow list. */
25180750Sdes#define MAX_DENY_GROUPS		256	/* Max # groups on deny list. */
26180750Sdes#define MAX_SUBSYSTEMS		256	/* Max # subsystems. */
27180750Sdes#define MAX_HOSTKEYS		256	/* Max # hostkeys. */
28180750Sdes#define MAX_HOSTCERTS		256	/* Max # host certificates. */
29180750Sdes#define MAX_ACCEPT_ENV		256	/* Max # of env vars. */
30180750Sdes#define MAX_MATCH_GROUPS	256	/* Max # of groups for Match. */
31180750Sdes#define MAX_AUTHKEYS_FILES	256	/* Max # of authorized_keys files. */
32180750Sdes#define MAX_AUTH_METHODS	256	/* Max # of AuthenticationMethods. */
33180750Sdes
34180750Sdes/* permit_root_login */
35180750Sdes#define	PERMIT_NOT_SET		-1
36180750Sdes#define	PERMIT_NO		0
37180750Sdes#define	PERMIT_FORCED_ONLY	1
38180750Sdes#define	PERMIT_NO_PASSWD	2
39180750Sdes#define	PERMIT_YES		3
40180750Sdes
41180750Sdes/* use_privsep */
42180750Sdes#define PRIVSEP_OFF		0
43180750Sdes#define PRIVSEP_ON		1
44180750Sdes#define PRIVSEP_NOSANDBOX	2
45180750Sdes
46180750Sdes/* AllowTCPForwarding */
47180750Sdes#define FORWARD_DENY		0
48180750Sdes#define FORWARD_REMOTE		(1)
49180750Sdes#define FORWARD_LOCAL		(1<<1)
50180750Sdes#define FORWARD_ALLOW		(FORWARD_REMOTE|FORWARD_LOCAL)
51180750Sdes
52180750Sdes#define DEFAULT_AUTH_FAIL_MAX	6	/* Default for MaxAuthTries */
53180750Sdes#define DEFAULT_SESSIONS_MAX	10	/* Default for MaxSessions */
54180750Sdes
55180750Sdes/* Magic name for internal sftp-server */
56180750Sdes#define INTERNAL_SFTP_NAME	"internal-sftp"
57180750Sdes
58180750Sdestypedef struct {
59180750Sdes	u_int	num_ports;
60180750Sdes	u_int	ports_from_cmdline;
61180750Sdes	int	ports[MAX_PORTS];	/* Port number to listen on. */
62180750Sdes	char   *listen_addr;		/* Address on which the server listens. */
63180750Sdes	struct addrinfo *listen_addrs;	/* Addresses on which the server listens. */
64180750Sdes	int     address_family;		/* Address family used by the server. */
65180750Sdes	char   *host_key_files[MAX_HOSTKEYS];	/* Files containing host keys. */
66180750Sdes	int     num_host_key_files;     /* Number of files for host keys. */
67180750Sdes	char   *host_cert_files[MAX_HOSTCERTS];	/* Files containing host certs. */
68180750Sdes	int     num_host_cert_files;     /* Number of files for host certs. */
69180750Sdes	char   *host_key_agent;		 /* ssh-agent socket for host keys. */
70180750Sdes	char   *pid_file;	/* Where to put our pid */
71180750Sdes	int     server_key_bits;/* Size of the server key. */
72180750Sdes	int     login_grace_time;	/* Disconnect if no auth in this time
73180750Sdes					 * (sec). */
74180750Sdes	int     key_regeneration_time;	/* Server key lifetime (seconds). */
75180750Sdes	int     permit_root_login;	/* PERMIT_*, see above */
76180750Sdes	int     ignore_rhosts;	/* Ignore .rhosts and .shosts. */
77180750Sdes	int     ignore_user_known_hosts;	/* Ignore ~/.ssh/known_hosts
78180750Sdes						 * for RhostsRsaAuth */
79180750Sdes	int     print_motd;	/* If true, print /etc/motd. */
80180750Sdes	int	print_lastlog;	/* If true, print lastlog */
81180750Sdes	int     x11_forwarding;	/* If true, permit inet (spoofing) X11 fwd. */
82180750Sdes	int     x11_display_offset;	/* What DISPLAY number to start
83180750Sdes					 * searching at */
84180750Sdes	int     x11_use_localhost;	/* If true, use localhost for fake X11 server. */
85180750Sdes	char   *xauth_location;	/* Location of xauth program */
86180750Sdes	int     strict_modes;	/* If true, require string home dir modes. */
87180750Sdes	int     tcp_keep_alive;	/* If true, set SO_KEEPALIVE. */
88180750Sdes	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
89180750Sdes	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
90180750Sdes	char   *ciphers;	/* Supported SSH2 ciphers. */
91180750Sdes	char   *macs;		/* Supported SSH2 macs. */
92180750Sdes	char   *kex_algorithms;	/* SSH2 kex methods in order of preference. */
93180750Sdes	int	protocol;	/* Supported protocol versions. */
94180750Sdes	int     gateway_ports;	/* If true, allow remote connects to forwarded ports. */
95180750Sdes	SyslogFacility log_facility;	/* Facility for system logging. */
96180750Sdes	LogLevel log_level;	/* Level for system logging. */
97180750Sdes	int     rhosts_rsa_authentication;	/* If true, permit rhosts RSA
98180750Sdes						 * authentication. */
99180750Sdes	int     hostbased_authentication;	/* If true, permit ssh2 hostbased auth */
100180750Sdes	int     hostbased_uses_name_from_packet_only; /* experimental */
101180750Sdes	int     rsa_authentication;	/* If true, permit RSA authentication. */
102180750Sdes	int     pubkey_authentication;	/* If true, permit ssh2 pubkey authentication. */
103180750Sdes	int     kerberos_authentication;	/* If true, permit Kerberos
104180750Sdes						 * authentication. */
105180750Sdes	int     kerberos_or_local_passwd;	/* If true, permit kerberos
106180750Sdes						 * and any other password
107180750Sdes						 * authentication mechanism,
108180750Sdes						 * such as SecurID or
109180750Sdes						 * /etc/passwd */
110180750Sdes	int     kerberos_ticket_cleanup;	/* If true, destroy ticket
111180750Sdes						 * file on logout. */
112180750Sdes	int     kerberos_get_afs_token;		/* If true, try to get AFS token if
113180750Sdes						 * authenticated with Kerberos. */
114180750Sdes	int     gss_authentication;	/* If true, permit GSSAPI authentication */
115180750Sdes	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
116180750Sdes	int     password_authentication;	/* If true, permit password
117180750Sdes						 * authentication. */
118180750Sdes	int     kbd_interactive_authentication;	/* If true, permit */
119180750Sdes	int     challenge_response_authentication;
120180750Sdes	int     zero_knowledge_password_authentication;
121180750Sdes					/* If true, permit jpake auth */
122180750Sdes	int     permit_empty_passwd;	/* If false, do not permit empty
123180750Sdes					 * passwords. */
124180750Sdes	int     permit_user_env;	/* If true, read ~/.ssh/environment */
125180750Sdes	int     use_login;	/* If true, login(1) is used */
126180750Sdes	int     compression;	/* If true, compression is allowed */
127180750Sdes	int	allow_tcp_forwarding; /* One of FORWARD_* */
128180750Sdes	int	allow_agent_forwarding;
129180750Sdes	u_int num_allow_users;
130180750Sdes	char   *allow_users[MAX_ALLOW_USERS];
131180750Sdes	u_int num_deny_users;
132180750Sdes	char   *deny_users[MAX_DENY_USERS];
133180750Sdes	u_int num_allow_groups;
134180750Sdes	char   *allow_groups[MAX_ALLOW_GROUPS];
135180750Sdes	u_int num_deny_groups;
136180750Sdes	char   *deny_groups[MAX_DENY_GROUPS];
137180750Sdes
138180750Sdes	u_int num_subsystems;
139180750Sdes	char   *subsystem_name[MAX_SUBSYSTEMS];
140180750Sdes	char   *subsystem_command[MAX_SUBSYSTEMS];
141180750Sdes	char   *subsystem_args[MAX_SUBSYSTEMS];
142180750Sdes
143180750Sdes	u_int num_accept_env;
144180750Sdes	char   *accept_env[MAX_ACCEPT_ENV];
145180750Sdes
146180750Sdes	int	max_startups_begin;
147180750Sdes	int	max_startups_rate;
148180750Sdes	int	max_startups;
149180750Sdes	int	max_authtries;
150180750Sdes	int	max_sessions;
151180750Sdes	char   *banner;			/* SSH-2 banner message */
152180750Sdes	int	use_dns;
153180750Sdes	int	client_alive_interval;	/*
154180750Sdes					 * poke the client this often to
155180750Sdes					 * see if it's still there
156180750Sdes					 */
157180750Sdes	int	client_alive_count_max;	/*
158180750Sdes					 * If the client is unresponsive
159180750Sdes					 * for this many intervals above,
160180750Sdes					 * disconnect the session
161180750Sdes					 */
162180750Sdes
163180750Sdes	u_int num_authkeys_files;	/* Files containing public keys */
164180750Sdes	char   *authorized_keys_files[MAX_AUTHKEYS_FILES];
165180750Sdes
166180750Sdes	char   *adm_forced_command;
167180750Sdes
168180750Sdes	int	use_pam;		/* Enable auth via PAM */
169180750Sdes
170180750Sdes	int	permit_tun;
171180750Sdes
172180750Sdes	int	num_permitted_opens;
173180750Sdes
174180750Sdes	char   *chroot_directory;
175180750Sdes	char   *revoked_keys_file;
176180750Sdes	char   *trusted_user_ca_keys;
177180750Sdes	char   *authorized_principals_file;
178180750Sdes	char   *authorized_keys_command;
179180750Sdes	char   *authorized_keys_command_user;
180180750Sdes
181180750Sdes	int64_t rekey_limit;
182180750Sdes	int	rekey_interval;
183180750Sdes
184180750Sdes	char   *version_addendum;	/* Appended to SSH banner */
185180750Sdes
186180750Sdes	int	hpn_disabled;		/* Disable HPN functionality. */
187180750Sdes	int	hpn_buffer_size;	/* Set HPN buffer size - default 2MB.*/
188180750Sdes	int	tcp_rcv_buf_poll;	/* Poll TCP rcv window in autotuning
189180750Sdes					 * kernels. */
190180750Sdes	u_int	num_auth_methods;
191180750Sdes	char   *auth_methods[MAX_AUTH_METHODS];
192180750Sdes
193180750Sdes#ifdef	NONE_CIPHER_ENABLED
194180750Sdes	int	none_enabled;		/* Enable NONE cipher switch. */
195180750Sdes#endif
196180750Sdes}       ServerOptions;
197180750Sdes
198180750Sdes/* Information about the incoming connection as used by Match */
199180750Sdesstruct connection_info {
200180750Sdes	const char *user;
201180750Sdes	const char *host;	/* possibly resolved hostname */
202180750Sdes	const char *address; 	/* remote address */
203180750Sdes	const char *laddress;	/* local address */
204180750Sdes	int lport;		/* local port */
205180750Sdes};
206180750Sdes
207180750Sdes
208180750Sdes/*
209180750Sdes * These are string config options that must be copied between the
210180750Sdes * Match sub-config and the main config, and must be sent from the
211180750Sdes * privsep slave to the privsep master. We use a macro to ensure all
212180750Sdes * the options are copied and the copies are done in the correct order.
213180750Sdes */
214180750Sdes#define COPY_MATCH_STRING_OPTS() do { \
215180750Sdes		M_CP_STROPT(banner); \
216180750Sdes		M_CP_STROPT(trusted_user_ca_keys); \
217180750Sdes		M_CP_STROPT(revoked_keys_file); \
218180750Sdes		M_CP_STROPT(authorized_principals_file); \
219180750Sdes		M_CP_STROPT(authorized_keys_command); \
220180750Sdes		M_CP_STROPT(authorized_keys_command_user); \
221180750Sdes		M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
222180750Sdes		M_CP_STRARRAYOPT(allow_users, num_allow_users); \
223180750Sdes		M_CP_STRARRAYOPT(deny_users, num_deny_users); \
224180750Sdes		M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
225180750Sdes		M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
226180750Sdes		M_CP_STRARRAYOPT(accept_env, num_accept_env); \
227180750Sdes		M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
228180750Sdes	} while (0)
229180750Sdes
230180750Sdesstruct connection_info *get_connection_info(int, int);
231180750Sdesvoid	 initialize_server_options(ServerOptions *);
232180750Sdesvoid	 fill_default_server_options(ServerOptions *);
233180750Sdesint	 process_server_config_line(ServerOptions *, char *, const char *, int,
234180750Sdes	     int *, struct connection_info *);
235180750Sdesvoid	 load_server_config(const char *, Buffer *);
236180750Sdesvoid	 parse_server_config(ServerOptions *, const char *, Buffer *,
237180750Sdes	     struct connection_info *);
238180750Sdesvoid	 parse_server_match_config(ServerOptions *, struct connection_info *);
239180750Sdesint	 parse_server_match_testspec(struct connection_info *, char *);
240180750Sdesint	 server_match_spec_complete(struct connection_info *);
241180750Sdesvoid	 copy_set_server_options(ServerOptions *, ServerOptions *, int);
242180750Sdesvoid	 dump_config(ServerOptions *);
243180750Sdeschar	*derelativise_path(const char *);
244180750Sdes
245180750Sdes#endif				/* SERVCONF_H */
246180750Sdes