xref: /titanic_44/usr/src/cmd/ssh/include/readconf.h (revision ab4a9beb2e4d596be0b3288c7d92919e27781b57)
1 /*
2  * Author: Tatu Ylonen <ylo@cs.hut.fi>
3  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4  *                    All rights reserved
5  * Functions for reading the configuration file.
6  *
7  * As far as I am concerned, the code I have written for this software
8  * can be used freely for any purpose.  Any derived versions of this
9  * software must be clearly marked as such, and if the derived work is
10  * incompatible with the protocol description in the RFC file, it must be
11  * called by a name other than "ssh" or "Secure Shell".
12  */
13 /*
14  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
15  * Use is subject to license terms.
16  */
17 
18 #ifndef	_READCONF_H
19 #define	_READCONF_H
20 
21 /*	$OpenBSD: readconf.h,v 1.43 2002/06/08 05:17:01 markus Exp $	*/
22 
23 #pragma ident	"%Z%%M%	%I%	%E% SMI"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "key.h"
30 
31 /*
32  * We accept only fixed amount of unknown options. Note that we must treat all
33  * options in different Host sections separately since we need to remember the
34  * line number. See IgnoreIfUnknown for more information.
35  */
36 #define	MAX_UNKNOWN_OPTIONS	64
37 
38 /* Data structure for representing a forwarding request. */
39 
40 typedef struct {
41 	u_short	  port;		/* Port to forward. */
42 	char	 *host;		/* Host to connect. */
43 	u_short	  host_port;	/* Port to connect on host. */
44 }       Forward;
45 /* Data structure for representing option data. */
46 
47 /* For postponed processing of option keywords. */
48 typedef struct {
49 	char   *keyword;	/* option keyword name */
50 	char   *filename;	/* config file it was found in */
51 	int	linenum;	/* line number in the config file */
52 }	StoredOption;
53 
54 typedef struct {
55 	int     forward_agent;	/* Forward authentication agent. */
56 	int     forward_x11;	/* Forward X11 display. */
57 	int     forward_x11_trusted;	/* Trust Forward X11 display. */
58 	char   *xauth_location;	/* Location for xauth program */
59 	int     gateway_ports;	/* Allow remote connects to forwarded ports. */
60 	int     use_privileged_port;	/* Don't use privileged port if false. */
61 	int     rhosts_authentication;	/* Try rhosts authentication. */
62 	int     rhosts_rsa_authentication;	/* Try rhosts with RSA
63 						 * authentication. */
64 	int     rsa_authentication;	/* Try RSA authentication. */
65 	int     pubkey_authentication;	/* Try ssh2 pubkey authentication. */
66 	int     hostbased_authentication;	/* ssh2's rhosts_rsa */
67 	int     challenge_response_authentication;
68 	int	fallback_to_rsh; /* Use rsh if cannot connect with ssh.  */
69 	int	use_rsh;	/* Always use rsh(don\'t try ssh). */
70 					/* Try S/Key or TIS, authentication. */
71 #if defined(KRB4) || defined(KRB5)
72 	int     kerberos_authentication;	/* Try Kerberos authentication. */
73 #endif
74 #if defined(AFS) || defined(KRB5)
75 	int     kerberos_tgt_passing;	/* Try Kerberos TGT passing. */
76 #endif
77 
78 #ifdef GSSAPI
79 	int 	gss_keyex;
80 	int 	gss_authentication;
81 	int	gss_deleg_creds;
82 #ifdef GSI
83 	int	gss_globus_deleg_limited_proxy;
84 #endif /* GSI */
85 #endif /* GSSAPI */
86 
87 #ifdef AFS
88 	int     afs_token_passing;	/* Try AFS token passing. */
89 #endif
90 	int     password_authentication;	/* Try password
91 						 * authentication. */
92 	int     kbd_interactive_authentication; /* Try keyboard-interactive auth. */
93 	char	*kbd_interactive_devices; /* Keyboard-interactive auth devices. */
94 	int     batch_mode;	/* Batch mode: do not ask for passwords. */
95 	int     check_host_ip;	/* Also keep track of keys for IP address */
96 	int     strict_host_key_checking;	/* Strict host key checking. */
97 	int     compression;	/* Compress packets in both directions. */
98 	int     compression_level;	/* Compression level 1 (fast) to 9
99 					 * (best). */
100 	int     keepalives;	/* Set SO_KEEPALIVE. */
101 	LogLevel log_level;	/* Level for logging. */
102 
103 	int     port;		/* Port to connect. */
104 	int     connection_attempts;	/* Max attempts (seconds) before
105 					 * giving up */
106 	int     connection_timeout;	/* Max time (seconds) before
107 					 * aborting connection attempt */
108 	int     number_of_password_prompts;	/* Max number of password
109 						 * prompts. */
110 	int     cipher;		/* Cipher to use. */
111 	char   *ciphers;	/* SSH2 ciphers in order of preference. */
112 	char   *macs;		/* SSH2 macs in order of preference. */
113 	char   *hostkeyalgorithms;	/* SSH2 server key types in order of preference. */
114 	int	protocol;	/* Protocol in order of preference. */
115 	char   *hostname;	/* Real host to connect. */
116 	char   *host_key_alias;	/* hostname alias for .ssh/known_hosts */
117 	char   *proxy_command;	/* Proxy command for connecting the host. */
118 	char   *user;		/* User to log in as. */
119 	int     escape_char;	/* Escape character; -2 = none */
120 
121 	char   *system_hostfile;/* Path for /etc/ssh/ssh_known_hosts. */
122 	char   *user_hostfile;	/* Path for $HOME/.ssh/known_hosts. */
123 	char   *system_hostfile2;
124 	char   *user_hostfile2;
125 	char   *preferred_authentications;
126 	char   *bind_address;	/* local socket address for connection to sshd */
127 	char   *smartcard_device; /* Smartcard reader device */
128 	int	disable_banner;	/* Disable display of banner */
129 
130 	/*
131 	 * Unknown options listed in IgnoreIfUnknown will not cause ssh to
132 	 * exit. So, we must store all unknown options here and can't process
133 	 * them before the command line options and all config files are read
134 	 * and IgnoreIfUnknown is properly set.
135 	 */
136 	char   *ignore_if_unknown;
137 	int	unknown_opts_num;
138 	StoredOption unknown_opts[MAX_UNKNOWN_OPTIONS];
139 
140 	int     num_identity_files;	/* Number of files for RSA/DSA identities. */
141 	char   *identity_files[SSH_MAX_IDENTITY_FILES];
142 	Key    *identity_keys[SSH_MAX_IDENTITY_FILES];
143 
144 	/* Local TCP/IP forward requests. */
145 	int     num_local_forwards;
146 	Forward local_forwards[SSH_MAX_FORWARDS_PER_DIRECTION];
147 
148 	/* Remote TCP/IP forward requests. */
149 	int     num_remote_forwards;
150 	Forward remote_forwards[SSH_MAX_FORWARDS_PER_DIRECTION];
151 	int	clear_forwardings;
152 	int	no_host_authentication_for_localhost;
153 	int	server_alive_interval;
154 	int	server_alive_count_max;
155 
156 	int	hash_known_hosts;
157 }       Options;
158 
159 
160 void     initialize_options(Options *);
161 void     fill_default_options(Options *);
162 int	 read_config_file(const char *, const char *, Options *);
163 
164 int
165 process_config_line(Options *, const char *, char *, const char *, int, int *);
166 
167 void	 add_local_forward(Options *, u_short, const char *, u_short);
168 void	 add_remote_forward(Options *, u_short, const char *, u_short);
169 
170 void	 process_unknown_options(Options *options);
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* _READCONF_H */
177