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 31*5d7f3ec0Sjp161948 /* 32*5d7f3ec0Sjp161948 * We accept only fixed amount of unknown options. Note that we must treat all 33*5d7f3ec0Sjp161948 * options in different Host sections separately since we need to remember the 34*5d7f3ec0Sjp161948 * line number. See IgnoreIfUnknown for more information. 35*5d7f3ec0Sjp161948 */ 36*5d7f3ec0Sjp161948 #define MAX_UNKNOWN_OPTIONS 64 37*5d7f3ec0Sjp161948 387c478bd9Sstevel@tonic-gate /* Data structure for representing a forwarding request. */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate typedef struct { 417c478bd9Sstevel@tonic-gate u_short port; /* Port to forward. */ 427c478bd9Sstevel@tonic-gate char *host; /* Host to connect. */ 437c478bd9Sstevel@tonic-gate u_short host_port; /* Port to connect on host. */ 447c478bd9Sstevel@tonic-gate } Forward; 457c478bd9Sstevel@tonic-gate /* Data structure for representing option data. */ 467c478bd9Sstevel@tonic-gate 47*5d7f3ec0Sjp161948 /* For postponed processing of option keywords. */ 48*5d7f3ec0Sjp161948 typedef struct { 49*5d7f3ec0Sjp161948 char *keyword; /* option keyword name */ 50*5d7f3ec0Sjp161948 char *filename; /* config file it was found in */ 51*5d7f3ec0Sjp161948 int linenum; /* line number in the config file */ 52*5d7f3ec0Sjp161948 } StoredOption; 53*5d7f3ec0Sjp161948 547c478bd9Sstevel@tonic-gate typedef struct { 557c478bd9Sstevel@tonic-gate int forward_agent; /* Forward authentication agent. */ 567c478bd9Sstevel@tonic-gate int forward_x11; /* Forward X11 display. */ 57383a1232Sjp161948 int forward_x11_trusted; /* Trust Forward X11 display. */ 587c478bd9Sstevel@tonic-gate char *xauth_location; /* Location for xauth program */ 597c478bd9Sstevel@tonic-gate int gateway_ports; /* Allow remote connects to forwarded ports. */ 607c478bd9Sstevel@tonic-gate int use_privileged_port; /* Don't use privileged port if false. */ 617c478bd9Sstevel@tonic-gate int rhosts_authentication; /* Try rhosts authentication. */ 627c478bd9Sstevel@tonic-gate int rhosts_rsa_authentication; /* Try rhosts with RSA 637c478bd9Sstevel@tonic-gate * authentication. */ 647c478bd9Sstevel@tonic-gate int rsa_authentication; /* Try RSA authentication. */ 657c478bd9Sstevel@tonic-gate int pubkey_authentication; /* Try ssh2 pubkey authentication. */ 667c478bd9Sstevel@tonic-gate int hostbased_authentication; /* ssh2's rhosts_rsa */ 677c478bd9Sstevel@tonic-gate int challenge_response_authentication; 687c478bd9Sstevel@tonic-gate int fallback_to_rsh; /* Use rsh if cannot connect with ssh. */ 697c478bd9Sstevel@tonic-gate int use_rsh; /* Always use rsh(don\'t try ssh). */ 707c478bd9Sstevel@tonic-gate /* Try S/Key or TIS, authentication. */ 717c478bd9Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 727c478bd9Sstevel@tonic-gate int kerberos_authentication; /* Try Kerberos authentication. */ 737c478bd9Sstevel@tonic-gate #endif 747c478bd9Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 757c478bd9Sstevel@tonic-gate int kerberos_tgt_passing; /* Try Kerberos TGT passing. */ 767c478bd9Sstevel@tonic-gate #endif 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #ifdef GSSAPI 797c478bd9Sstevel@tonic-gate int gss_keyex; 807c478bd9Sstevel@tonic-gate int gss_authentication; 817c478bd9Sstevel@tonic-gate int gss_deleg_creds; 827c478bd9Sstevel@tonic-gate #ifdef GSI 837c478bd9Sstevel@tonic-gate int gss_globus_deleg_limited_proxy; 847c478bd9Sstevel@tonic-gate #endif /* GSI */ 857c478bd9Sstevel@tonic-gate #endif /* GSSAPI */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #ifdef AFS 887c478bd9Sstevel@tonic-gate int afs_token_passing; /* Try AFS token passing. */ 897c478bd9Sstevel@tonic-gate #endif 907c478bd9Sstevel@tonic-gate int password_authentication; /* Try password 917c478bd9Sstevel@tonic-gate * authentication. */ 927c478bd9Sstevel@tonic-gate int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ 937c478bd9Sstevel@tonic-gate char *kbd_interactive_devices; /* Keyboard-interactive auth devices. */ 947c478bd9Sstevel@tonic-gate int batch_mode; /* Batch mode: do not ask for passwords. */ 957c478bd9Sstevel@tonic-gate int check_host_ip; /* Also keep track of keys for IP address */ 967c478bd9Sstevel@tonic-gate int strict_host_key_checking; /* Strict host key checking. */ 977c478bd9Sstevel@tonic-gate int compression; /* Compress packets in both directions. */ 987c478bd9Sstevel@tonic-gate int compression_level; /* Compression level 1 (fast) to 9 997c478bd9Sstevel@tonic-gate * (best). */ 1007c478bd9Sstevel@tonic-gate int keepalives; /* Set SO_KEEPALIVE. */ 1017c478bd9Sstevel@tonic-gate LogLevel log_level; /* Level for logging. */ 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate int port; /* Port to connect. */ 1047c478bd9Sstevel@tonic-gate int connection_attempts; /* Max attempts (seconds) before 1057c478bd9Sstevel@tonic-gate * giving up */ 10647b374ffSjp161948 int connection_timeout; /* Max time (seconds) before 10747b374ffSjp161948 * aborting connection attempt */ 1087c478bd9Sstevel@tonic-gate int number_of_password_prompts; /* Max number of password 1097c478bd9Sstevel@tonic-gate * prompts. */ 1107c478bd9Sstevel@tonic-gate int cipher; /* Cipher to use. */ 1117c478bd9Sstevel@tonic-gate char *ciphers; /* SSH2 ciphers in order of preference. */ 1127c478bd9Sstevel@tonic-gate char *macs; /* SSH2 macs in order of preference. */ 1137c478bd9Sstevel@tonic-gate char *hostkeyalgorithms; /* SSH2 server key types in order of preference. */ 1147c478bd9Sstevel@tonic-gate int protocol; /* Protocol in order of preference. */ 1157c478bd9Sstevel@tonic-gate char *hostname; /* Real host to connect. */ 1167c478bd9Sstevel@tonic-gate char *host_key_alias; /* hostname alias for .ssh/known_hosts */ 1177c478bd9Sstevel@tonic-gate char *proxy_command; /* Proxy command for connecting the host. */ 1187c478bd9Sstevel@tonic-gate char *user; /* User to log in as. */ 1197c478bd9Sstevel@tonic-gate int escape_char; /* Escape character; -2 = none */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate char *system_hostfile;/* Path for /etc/ssh/ssh_known_hosts. */ 1227c478bd9Sstevel@tonic-gate char *user_hostfile; /* Path for $HOME/.ssh/known_hosts. */ 1237c478bd9Sstevel@tonic-gate char *system_hostfile2; 1247c478bd9Sstevel@tonic-gate char *user_hostfile2; 1257c478bd9Sstevel@tonic-gate char *preferred_authentications; 1267c478bd9Sstevel@tonic-gate char *bind_address; /* local socket address for connection to sshd */ 1277c478bd9Sstevel@tonic-gate char *smartcard_device; /* Smartcard reader device */ 128e5e9dedaSjp161948 int disable_banner; /* Disable display of banner */ 1297c478bd9Sstevel@tonic-gate 130*5d7f3ec0Sjp161948 /* 131*5d7f3ec0Sjp161948 * Unknown options listed in IgnoreIfUnknown will not cause ssh to 132*5d7f3ec0Sjp161948 * exit. So, we must store all unknown options here and can't process 133*5d7f3ec0Sjp161948 * them before the command line options and all config files are read 134*5d7f3ec0Sjp161948 * and IgnoreIfUnknown is properly set. 135*5d7f3ec0Sjp161948 */ 136*5d7f3ec0Sjp161948 char *ignore_if_unknown; 137*5d7f3ec0Sjp161948 int unknown_opts_num; 138*5d7f3ec0Sjp161948 StoredOption unknown_opts[MAX_UNKNOWN_OPTIONS]; 139*5d7f3ec0Sjp161948 1407c478bd9Sstevel@tonic-gate int num_identity_files; /* Number of files for RSA/DSA identities. */ 1417c478bd9Sstevel@tonic-gate char *identity_files[SSH_MAX_IDENTITY_FILES]; 1427c478bd9Sstevel@tonic-gate Key *identity_keys[SSH_MAX_IDENTITY_FILES]; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* Local TCP/IP forward requests. */ 1457c478bd9Sstevel@tonic-gate int num_local_forwards; 1467c478bd9Sstevel@tonic-gate Forward local_forwards[SSH_MAX_FORWARDS_PER_DIRECTION]; 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* Remote TCP/IP forward requests. */ 1497c478bd9Sstevel@tonic-gate int num_remote_forwards; 1507c478bd9Sstevel@tonic-gate Forward remote_forwards[SSH_MAX_FORWARDS_PER_DIRECTION]; 1517c478bd9Sstevel@tonic-gate int clear_forwardings; 1527c478bd9Sstevel@tonic-gate int no_host_authentication_for_localhost; 1531434cf01Sjp161948 int server_alive_interval; 1541434cf01Sjp161948 int server_alive_count_max; 155442d23f4Sjp161948 156442d23f4Sjp161948 int hash_known_hosts; 1577c478bd9Sstevel@tonic-gate } Options; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate void initialize_options(Options *); 1617c478bd9Sstevel@tonic-gate void fill_default_options(Options *); 1627c478bd9Sstevel@tonic-gate int read_config_file(const char *, const char *, Options *); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate int 1657c478bd9Sstevel@tonic-gate process_config_line(Options *, const char *, char *, const char *, int, int *); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate void add_local_forward(Options *, u_short, const char *, u_short); 1687c478bd9Sstevel@tonic-gate void add_remote_forward(Options *, u_short, const char *, u_short); 1697c478bd9Sstevel@tonic-gate 170*5d7f3ec0Sjp161948 void process_unknown_options(Options *options); 171*5d7f3ec0Sjp161948 1727c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1737c478bd9Sstevel@tonic-gate } 1747c478bd9Sstevel@tonic-gate #endif 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #endif /* _READCONF_H */ 177