xref: /freebsd/crypto/openssh/readconf.h (revision 59e2ff550c448126b988150ce800cdf73bb5103e)
1 /* $OpenBSD: readconf.h,v 1.101 2014/02/23 20:11:36 djm Exp $ */
2 /* $FreeBSD$ */
3 
4 /*
5  * Author: Tatu Ylonen <ylo@cs.hut.fi>
6  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
7  *                    All rights reserved
8  * Functions for reading the configuration file.
9  *
10  * As far as I am concerned, the code I have written for this software
11  * can be used freely for any purpose.  Any derived versions of this
12  * software must be clearly marked as such, and if the derived work is
13  * incompatible with the protocol description in the RFC file, it must be
14  * called by a name other than "ssh" or "Secure Shell".
15  */
16 
17 #ifndef READCONF_H
18 #define READCONF_H
19 
20 /* Data structure for representing a forwarding request. */
21 
22 typedef struct {
23 	char	 *listen_host;		/* Host (address) to listen on. */
24 	int	  listen_port;		/* Port to forward. */
25 	char	 *connect_host;		/* Host to connect. */
26 	int	  connect_port;		/* Port to connect on connect_host. */
27 	int	  allocated_port;	/* Dynamically allocated listen port */
28 	int	  handle;		/* Handle for dynamic listen ports */
29 }       Forward;
30 /* Data structure for representing option data. */
31 
32 #define MAX_SEND_ENV		256
33 #define SSH_MAX_HOSTS_FILES	32
34 #define MAX_CANON_DOMAINS	32
35 
36 struct allowed_cname {
37 	char *source_list;
38 	char *target_list;
39 };
40 
41 typedef struct {
42 	int     forward_agent;	/* Forward authentication agent. */
43 	int     forward_x11;	/* Forward X11 display. */
44 	int     forward_x11_timeout;	/* Expiration for Cookies */
45 	int     forward_x11_trusted;	/* Trust Forward X11 display. */
46 	int     exit_on_forward_failure;	/* Exit if bind(2) fails for -L/-R */
47 	char   *xauth_location;	/* Location for xauth program */
48 	int     gateway_ports;	/* Allow remote connects to forwarded ports. */
49 	int     use_privileged_port;	/* Don't use privileged port if false. */
50 	int     rhosts_rsa_authentication;	/* Try rhosts with RSA
51 						 * authentication. */
52 	int     rsa_authentication;	/* Try RSA authentication. */
53 	int     pubkey_authentication;	/* Try ssh2 pubkey authentication. */
54 	int     hostbased_authentication;	/* ssh2's rhosts_rsa */
55 	int     challenge_response_authentication;
56 					/* Try S/Key or TIS, authentication. */
57 	int     gss_authentication;	/* Try GSS authentication */
58 	int     gss_deleg_creds;	/* Delegate GSS credentials */
59 	int     password_authentication;	/* Try password
60 						 * authentication. */
61 	int     kbd_interactive_authentication; /* Try keyboard-interactive auth. */
62 	char	*kbd_interactive_devices; /* Keyboard-interactive auth devices. */
63 	int     batch_mode;	/* Batch mode: do not ask for passwords. */
64 	int     check_host_ip;	/* Also keep track of keys for IP address */
65 	int     strict_host_key_checking;	/* Strict host key checking. */
66 	int     compression;	/* Compress packets in both directions. */
67 	int     compression_level;	/* Compression level 1 (fast) to 9
68 					 * (best). */
69 	int     tcp_keep_alive;	/* Set SO_KEEPALIVE. */
70 	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
71 	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
72 	LogLevel log_level;	/* Level for logging. */
73 
74 	int     port;		/* Port to connect. */
75 	int     address_family;
76 	int     connection_attempts;	/* Max attempts (seconds) before
77 					 * giving up */
78 	int     connection_timeout;	/* Max time (seconds) before
79 					 * aborting connection attempt */
80 	int     number_of_password_prompts;	/* Max number of password
81 						 * prompts. */
82 	int     cipher;		/* Cipher to use. */
83 	char   *ciphers;	/* SSH2 ciphers in order of preference. */
84 	char   *macs;		/* SSH2 macs in order of preference. */
85 	char   *hostkeyalgorithms;	/* SSH2 server key types in order of preference. */
86 	char   *kex_algorithms;	/* SSH2 kex methods in order of preference. */
87 	int	protocol;	/* Protocol in order of preference. */
88 	char   *hostname;	/* Real host to connect. */
89 	char   *host_key_alias;	/* hostname alias for .ssh/known_hosts */
90 	char   *proxy_command;	/* Proxy command for connecting the host. */
91 	char   *user;		/* User to log in as. */
92 	int     escape_char;	/* Escape character; -2 = none */
93 
94 	u_int	num_system_hostfiles;	/* Paths for /etc/ssh/ssh_known_hosts */
95 	char   *system_hostfiles[SSH_MAX_HOSTS_FILES];
96 	u_int	num_user_hostfiles;	/* Path for $HOME/.ssh/known_hosts */
97 	char   *user_hostfiles[SSH_MAX_HOSTS_FILES];
98 	char   *preferred_authentications;
99 	char   *bind_address;	/* local socket address for connection to sshd */
100 	char   *pkcs11_provider; /* PKCS#11 provider */
101 	int	verify_host_key_dns;	/* Verify host key using DNS */
102 
103 	int     num_identity_files;	/* Number of files for RSA/DSA identities. */
104 	char   *identity_files[SSH_MAX_IDENTITY_FILES];
105 	int    identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
106 	Key    *identity_keys[SSH_MAX_IDENTITY_FILES];
107 
108 	/* Local TCP/IP forward requests. */
109 	int     num_local_forwards;
110 	Forward *local_forwards;
111 
112 	/* Remote TCP/IP forward requests. */
113 	int     num_remote_forwards;
114 	Forward *remote_forwards;
115 	int	clear_forwardings;
116 
117 	int	enable_ssh_keysign;
118 	int64_t rekey_limit;
119 	int	rekey_interval;
120 	int	no_host_authentication_for_localhost;
121 	int	identities_only;
122 	int	server_alive_interval;
123 	int	server_alive_count_max;
124 
125 	int     num_send_env;
126 	char   *send_env[MAX_SEND_ENV];
127 
128 	char	*control_path;
129 	int	control_master;
130 	int     control_persist; /* ControlPersist flag */
131 	int     control_persist_timeout; /* ControlPersist timeout (seconds) */
132 
133 	int	hash_known_hosts;
134 
135 	int	tun_open;	/* tun(4) */
136 	int     tun_local;	/* force tun device (optional) */
137 	int     tun_remote;	/* force tun device (optional) */
138 
139 	char	*local_command;
140 	int	permit_local_command;
141 	int	visual_host_key;
142 
143 	int	use_roaming;
144 
145 	int	request_tty;
146 
147 	int	proxy_use_fdpass;
148 
149 	int	num_canonical_domains;
150 	char	*canonical_domains[MAX_CANON_DOMAINS];
151 	int	canonicalize_hostname;
152 	int	canonicalize_max_dots;
153 	int	canonicalize_fallback_local;
154 	int	num_permitted_cnames;
155 	struct allowed_cname permitted_cnames[MAX_CANON_DOMAINS];
156 
157 	char	*ignored_unknown; /* Pattern list of unknown tokens to ignore */
158 
159 	char   *version_addendum;	/* Appended to SSH banner */
160 
161 	int	hpn_disabled;	/* Switch to disable HPN buffer management. */
162 	int	hpn_buffer_size;	/* User definable size for HPN buffer
163 					 * window. */
164 	int	tcp_rcv_buf_poll;	/* Option to poll recv buf every window
165 					 * transfer. */
166 	int	tcp_rcv_buf;	/* User switch to set tcp recv buffer. */
167 
168 #ifdef	NONE_CIPHER_ENABLED
169 	int	none_enabled;	/* Allow none to be used */
170 	int	none_switch;	/* Use none cipher */
171 #endif
172 }       Options;
173 
174 #define SSH_CANONICALISE_NO	0
175 #define SSH_CANONICALISE_YES	1
176 #define SSH_CANONICALISE_ALWAYS	2
177 
178 #define SSHCTL_MASTER_NO	0
179 #define SSHCTL_MASTER_YES	1
180 #define SSHCTL_MASTER_AUTO	2
181 #define SSHCTL_MASTER_ASK	3
182 #define SSHCTL_MASTER_AUTO_ASK	4
183 
184 #define REQUEST_TTY_AUTO	0
185 #define REQUEST_TTY_NO		1
186 #define REQUEST_TTY_YES		2
187 #define REQUEST_TTY_FORCE	3
188 
189 #define SSHCONF_CHECKPERM	1  /* check permissions on config file */
190 #define SSHCONF_USERCONF	2  /* user provided config file not system */
191 
192 void     initialize_options(Options *);
193 void     fill_default_options(Options *);
194 void	 fill_default_options_for_canonicalization(Options *);
195 int	 process_config_line(Options *, struct passwd *, const char *, char *,
196     const char *, int, int *, int);
197 int	 read_config_file(const char *, struct passwd *, const char *,
198     Options *, int);
199 int	 parse_forward(Forward *, const char *, int, int);
200 int	 default_ssh_port(void);
201 int	 option_clear_or_none(const char *);
202 
203 void	 add_local_forward(Options *, const Forward *);
204 void	 add_remote_forward(Options *, const Forward *);
205 void	 add_identity_file(Options *, const char *, const char *, int);
206 
207 #endif				/* READCONF_H */
208