xref: /titanic_44/usr/src/cmd/ssh/include/readconf.h (revision 9a8058b57457911fab0e3b4b6f0a97740e7a816d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Author: Tatu Ylonen <ylo@cs.hut.fi>
37c478bd9Sstevel@tonic-gate  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
47c478bd9Sstevel@tonic-gate  *                    All rights reserved
57c478bd9Sstevel@tonic-gate  * Functions for reading the configuration file.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  * As far as I am concerned, the code I have written for this software
87c478bd9Sstevel@tonic-gate  * can be used freely for any purpose.  Any derived versions of this
97c478bd9Sstevel@tonic-gate  * software must be clearly marked as such, and if the derived work is
107c478bd9Sstevel@tonic-gate  * incompatible with the protocol description in the RFC file, it must be
117c478bd9Sstevel@tonic-gate  * called by a name other than "ssh" or "Secure Shell".
127c478bd9Sstevel@tonic-gate  */
137c478bd9Sstevel@tonic-gate /*
1447b374ffSjp161948  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
157c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
167c478bd9Sstevel@tonic-gate  */
177c478bd9Sstevel@tonic-gate 
18442d23f4Sjp161948 #ifndef	_READCONF_H
19442d23f4Sjp161948 #define	_READCONF_H
20442d23f4Sjp161948 
21442d23f4Sjp161948 /*	$OpenBSD: readconf.h,v 1.43 2002/06/08 05:17:01 markus Exp $	*/
22442d23f4Sjp161948 
23442d23f4Sjp161948 #pragma ident	"%Z%%M%	%I%	%E% SMI"
24442d23f4Sjp161948 
25442d23f4Sjp161948 #ifdef __cplusplus
26442d23f4Sjp161948 extern "C" {
27442d23f4Sjp161948 #endif
28442d23f4Sjp161948 
297c478bd9Sstevel@tonic-gate #include "key.h"
307c478bd9Sstevel@tonic-gate 
315d7f3ec0Sjp161948 /*
325d7f3ec0Sjp161948  * We accept only fixed amount of unknown options. Note that we must treat all
335d7f3ec0Sjp161948  * options in different Host sections separately since we need to remember the
345d7f3ec0Sjp161948  * line number. See IgnoreIfUnknown for more information.
355d7f3ec0Sjp161948  */
365d7f3ec0Sjp161948 #define	MAX_UNKNOWN_OPTIONS	64
375d7f3ec0Sjp161948 
387c478bd9Sstevel@tonic-gate /* Data structure for representing a forwarding request. */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate typedef struct {
419b03ea0fSjp161948 	char	 *listen_host;		/* Host (address) to listen on. */
429b03ea0fSjp161948 	u_short	  listen_port;		/* Port to forward. */
439b03ea0fSjp161948 	char	 *connect_host;		/* Host to connect. */
449b03ea0fSjp161948 	u_short	  connect_port;		/* Port to connect on connect_host. */
457c478bd9Sstevel@tonic-gate }       Forward;
467c478bd9Sstevel@tonic-gate /* Data structure for representing option data. */
477c478bd9Sstevel@tonic-gate 
485d7f3ec0Sjp161948 /* For postponed processing of option keywords. */
495d7f3ec0Sjp161948 typedef struct {
505d7f3ec0Sjp161948 	char   *keyword;	/* option keyword name */
515d7f3ec0Sjp161948 	char   *filename;	/* config file it was found in */
525d7f3ec0Sjp161948 	int	linenum;	/* line number in the config file */
535d7f3ec0Sjp161948 }	StoredOption;
545d7f3ec0Sjp161948 
557c478bd9Sstevel@tonic-gate typedef struct {
567c478bd9Sstevel@tonic-gate 	int     forward_agent;	/* Forward authentication agent. */
577c478bd9Sstevel@tonic-gate 	int     forward_x11;	/* Forward X11 display. */
58383a1232Sjp161948 	int     forward_x11_trusted;	/* Trust Forward X11 display. */
597c478bd9Sstevel@tonic-gate 	char   *xauth_location;	/* Location for xauth program */
607c478bd9Sstevel@tonic-gate 	int     gateway_ports;	/* Allow remote connects to forwarded ports. */
617c478bd9Sstevel@tonic-gate 	int     use_privileged_port;	/* Don't use privileged port if false. */
627c478bd9Sstevel@tonic-gate 	int     rhosts_authentication;	/* Try rhosts authentication. */
637c478bd9Sstevel@tonic-gate 	int     rhosts_rsa_authentication;	/* Try rhosts with RSA
647c478bd9Sstevel@tonic-gate 						 * authentication. */
657c478bd9Sstevel@tonic-gate 	int     rsa_authentication;	/* Try RSA authentication. */
667c478bd9Sstevel@tonic-gate 	int     pubkey_authentication;	/* Try ssh2 pubkey authentication. */
677c478bd9Sstevel@tonic-gate 	int     hostbased_authentication;	/* ssh2's rhosts_rsa */
687c478bd9Sstevel@tonic-gate 	int     challenge_response_authentication;
697c478bd9Sstevel@tonic-gate 	int	fallback_to_rsh; /* Use rsh if cannot connect with ssh.  */
707c478bd9Sstevel@tonic-gate 	int	use_rsh;	/* Always use rsh(don\'t try ssh). */
717c478bd9Sstevel@tonic-gate 					/* Try S/Key or TIS, authentication. */
727c478bd9Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5)
737c478bd9Sstevel@tonic-gate 	int     kerberos_authentication;	/* Try Kerberos authentication. */
747c478bd9Sstevel@tonic-gate #endif
757c478bd9Sstevel@tonic-gate #if defined(AFS) || defined(KRB5)
767c478bd9Sstevel@tonic-gate 	int     kerberos_tgt_passing;	/* Try Kerberos TGT passing. */
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #ifdef GSSAPI
807c478bd9Sstevel@tonic-gate 	int 	gss_keyex;
817c478bd9Sstevel@tonic-gate 	int 	gss_authentication;
827c478bd9Sstevel@tonic-gate 	int	gss_deleg_creds;
837c478bd9Sstevel@tonic-gate #ifdef GSI
847c478bd9Sstevel@tonic-gate 	int	gss_globus_deleg_limited_proxy;
857c478bd9Sstevel@tonic-gate #endif /* GSI */
867c478bd9Sstevel@tonic-gate #endif /* GSSAPI */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #ifdef AFS
897c478bd9Sstevel@tonic-gate 	int     afs_token_passing;	/* Try AFS token passing. */
907c478bd9Sstevel@tonic-gate #endif
917c478bd9Sstevel@tonic-gate 	int     password_authentication;	/* Try password
927c478bd9Sstevel@tonic-gate 						 * authentication. */
937c478bd9Sstevel@tonic-gate 	int     kbd_interactive_authentication; /* Try keyboard-interactive auth. */
947c478bd9Sstevel@tonic-gate 	char	*kbd_interactive_devices; /* Keyboard-interactive auth devices. */
957c478bd9Sstevel@tonic-gate 	int     batch_mode;	/* Batch mode: do not ask for passwords. */
967c478bd9Sstevel@tonic-gate 	int     check_host_ip;	/* Also keep track of keys for IP address */
977c478bd9Sstevel@tonic-gate 	int     strict_host_key_checking;	/* Strict host key checking. */
987c478bd9Sstevel@tonic-gate 	int     compression;	/* Compress packets in both directions. */
997c478bd9Sstevel@tonic-gate 	int     compression_level;	/* Compression level 1 (fast) to 9
1007c478bd9Sstevel@tonic-gate 					 * (best). */
1017c478bd9Sstevel@tonic-gate 	int     keepalives;	/* Set SO_KEEPALIVE. */
1027c478bd9Sstevel@tonic-gate 	LogLevel log_level;	/* Level for logging. */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	int     port;		/* Port to connect. */
1057c478bd9Sstevel@tonic-gate 	int     connection_attempts;	/* Max attempts (seconds) before
1067c478bd9Sstevel@tonic-gate 					 * giving up */
10747b374ffSjp161948 	int     connection_timeout;	/* Max time (seconds) before
10847b374ffSjp161948 					 * aborting connection attempt */
1097c478bd9Sstevel@tonic-gate 	int     number_of_password_prompts;	/* Max number of password
1107c478bd9Sstevel@tonic-gate 						 * prompts. */
1117c478bd9Sstevel@tonic-gate 	int     cipher;		/* Cipher to use. */
1127c478bd9Sstevel@tonic-gate 	char   *ciphers;	/* SSH2 ciphers in order of preference. */
1137c478bd9Sstevel@tonic-gate 	char   *macs;		/* SSH2 macs in order of preference. */
1147c478bd9Sstevel@tonic-gate 	char   *hostkeyalgorithms;	/* SSH2 server key types in order of preference. */
1157c478bd9Sstevel@tonic-gate 	int	protocol;	/* Protocol in order of preference. */
1167c478bd9Sstevel@tonic-gate 	char   *hostname;	/* Real host to connect. */
1177c478bd9Sstevel@tonic-gate 	char   *host_key_alias;	/* hostname alias for .ssh/known_hosts */
1187c478bd9Sstevel@tonic-gate 	char   *proxy_command;	/* Proxy command for connecting the host. */
1197c478bd9Sstevel@tonic-gate 	char   *user;		/* User to log in as. */
1207c478bd9Sstevel@tonic-gate 	int     escape_char;	/* Escape character; -2 = none */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	char   *system_hostfile;/* Path for /etc/ssh/ssh_known_hosts. */
1237c478bd9Sstevel@tonic-gate 	char   *user_hostfile;	/* Path for $HOME/.ssh/known_hosts. */
1247c478bd9Sstevel@tonic-gate 	char   *system_hostfile2;
1257c478bd9Sstevel@tonic-gate 	char   *user_hostfile2;
1267c478bd9Sstevel@tonic-gate 	char   *preferred_authentications;
1277c478bd9Sstevel@tonic-gate 	char   *bind_address;	/* local socket address for connection to sshd */
1287c478bd9Sstevel@tonic-gate 	char   *smartcard_device; /* Smartcard reader device */
129e5e9dedaSjp161948 	int	disable_banner;	/* Disable display of banner */
1307c478bd9Sstevel@tonic-gate 
1315d7f3ec0Sjp161948 	/*
1325d7f3ec0Sjp161948 	 * Unknown options listed in IgnoreIfUnknown will not cause ssh to
1335d7f3ec0Sjp161948 	 * exit. So, we must store all unknown options here and can't process
1345d7f3ec0Sjp161948 	 * them before the command line options and all config files are read
1355d7f3ec0Sjp161948 	 * and IgnoreIfUnknown is properly set.
1365d7f3ec0Sjp161948 	 */
1375d7f3ec0Sjp161948 	char   *ignore_if_unknown;
1385d7f3ec0Sjp161948 	int	unknown_opts_num;
1395d7f3ec0Sjp161948 	StoredOption unknown_opts[MAX_UNKNOWN_OPTIONS];
1405d7f3ec0Sjp161948 
1417c478bd9Sstevel@tonic-gate 	int     num_identity_files;	/* Number of files for RSA/DSA identities. */
1427c478bd9Sstevel@tonic-gate 	char   *identity_files[SSH_MAX_IDENTITY_FILES];
1437c478bd9Sstevel@tonic-gate 	Key    *identity_keys[SSH_MAX_IDENTITY_FILES];
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	/* Local TCP/IP forward requests. */
1467c478bd9Sstevel@tonic-gate 	int     num_local_forwards;
1477c478bd9Sstevel@tonic-gate 	Forward local_forwards[SSH_MAX_FORWARDS_PER_DIRECTION];
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	/* Remote TCP/IP forward requests. */
1507c478bd9Sstevel@tonic-gate 	int     num_remote_forwards;
1517c478bd9Sstevel@tonic-gate 	Forward remote_forwards[SSH_MAX_FORWARDS_PER_DIRECTION];
1527c478bd9Sstevel@tonic-gate 	int	clear_forwardings;
153*9a8058b5Sjp161948 
154*9a8058b5Sjp161948 	int64_t rekey_limit;
1557c478bd9Sstevel@tonic-gate 	int	no_host_authentication_for_localhost;
1561434cf01Sjp161948 	int	server_alive_interval;
1571434cf01Sjp161948 	int	server_alive_count_max;
158442d23f4Sjp161948 
159442d23f4Sjp161948 	int	hash_known_hosts;
1607c478bd9Sstevel@tonic-gate }       Options;
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate void     initialize_options(Options *);
1647c478bd9Sstevel@tonic-gate void     fill_default_options(Options *);
1657c478bd9Sstevel@tonic-gate int	 read_config_file(const char *, const char *, Options *);
1669b03ea0fSjp161948 int	 parse_forward(int, Forward *, const char *);
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate int
1697c478bd9Sstevel@tonic-gate process_config_line(Options *, const char *, char *, const char *, int, int *);
1707c478bd9Sstevel@tonic-gate 
1719b03ea0fSjp161948 void	 add_local_forward(Options *, const Forward *);
1729b03ea0fSjp161948 void	 add_remote_forward(Options *, const Forward *);
1737c478bd9Sstevel@tonic-gate 
1749b03ea0fSjp161948 void	 process_unknown_options(Options *);
1755d7f3ec0Sjp161948 
1767c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate #endif
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate #endif /* _READCONF_H */
181