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 /* 14*cd7d5fafSJan Pechanec * Copyright 2008 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 #ifdef __cplusplus 24442d23f4Sjp161948 extern "C" { 25442d23f4Sjp161948 #endif 26442d23f4Sjp161948 277c478bd9Sstevel@tonic-gate #include "key.h" 287c478bd9Sstevel@tonic-gate 295d7f3ec0Sjp161948 /* 305d7f3ec0Sjp161948 * We accept only fixed amount of unknown options. Note that we must treat all 315d7f3ec0Sjp161948 * options in different Host sections separately since we need to remember the 325d7f3ec0Sjp161948 * line number. See IgnoreIfUnknown for more information. 335d7f3ec0Sjp161948 */ 345d7f3ec0Sjp161948 #define MAX_UNKNOWN_OPTIONS 64 355d7f3ec0Sjp161948 367c478bd9Sstevel@tonic-gate /* Data structure for representing a forwarding request. */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate typedef struct { 399b03ea0fSjp161948 char *listen_host; /* Host (address) to listen on. */ 409b03ea0fSjp161948 u_short listen_port; /* Port to forward. */ 419b03ea0fSjp161948 char *connect_host; /* Host to connect. */ 429b03ea0fSjp161948 u_short connect_port; /* Port to connect on connect_host. */ 437c478bd9Sstevel@tonic-gate } Forward; 447c478bd9Sstevel@tonic-gate /* Data structure for representing option data. */ 457c478bd9Sstevel@tonic-gate 465d7f3ec0Sjp161948 /* For postponed processing of option keywords. */ 475d7f3ec0Sjp161948 typedef struct { 485d7f3ec0Sjp161948 char *keyword; /* option keyword name */ 495d7f3ec0Sjp161948 char *filename; /* config file it was found in */ 505d7f3ec0Sjp161948 int linenum; /* line number in the config file */ 515d7f3ec0Sjp161948 } StoredOption; 525d7f3ec0Sjp161948 537c478bd9Sstevel@tonic-gate typedef struct { 547c478bd9Sstevel@tonic-gate int forward_agent; /* Forward authentication agent. */ 557c478bd9Sstevel@tonic-gate int forward_x11; /* Forward X11 display. */ 56383a1232Sjp161948 int forward_x11_trusted; /* Trust Forward X11 display. */ 577c478bd9Sstevel@tonic-gate char *xauth_location; /* Location for xauth program */ 587c478bd9Sstevel@tonic-gate int gateway_ports; /* Allow remote connects to forwarded ports. */ 597c478bd9Sstevel@tonic-gate int use_privileged_port; /* Don't use privileged port if false. */ 607c478bd9Sstevel@tonic-gate int rhosts_authentication; /* Try rhosts authentication. */ 617c478bd9Sstevel@tonic-gate int rhosts_rsa_authentication; /* Try rhosts with RSA 627c478bd9Sstevel@tonic-gate * authentication. */ 637c478bd9Sstevel@tonic-gate int rsa_authentication; /* Try RSA authentication. */ 647c478bd9Sstevel@tonic-gate int pubkey_authentication; /* Try ssh2 pubkey authentication. */ 657c478bd9Sstevel@tonic-gate int hostbased_authentication; /* ssh2's rhosts_rsa */ 667c478bd9Sstevel@tonic-gate int challenge_response_authentication; 677c478bd9Sstevel@tonic-gate int fallback_to_rsh; /* Use rsh if cannot connect with ssh. */ 687c478bd9Sstevel@tonic-gate int use_rsh; /* Always use rsh(don\'t try ssh). */ 697c478bd9Sstevel@tonic-gate /* Try S/Key or TIS, authentication. */ 707c478bd9Sstevel@tonic-gate #if defined(KRB4) || defined(KRB5) 717c478bd9Sstevel@tonic-gate int kerberos_authentication; /* Try Kerberos authentication. */ 727c478bd9Sstevel@tonic-gate #endif 737c478bd9Sstevel@tonic-gate #if defined(AFS) || defined(KRB5) 747c478bd9Sstevel@tonic-gate int kerberos_tgt_passing; /* Try Kerberos TGT passing. */ 757c478bd9Sstevel@tonic-gate #endif 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #ifdef GSSAPI 787c478bd9Sstevel@tonic-gate int gss_keyex; 797c478bd9Sstevel@tonic-gate int gss_authentication; 807c478bd9Sstevel@tonic-gate int gss_deleg_creds; 817c478bd9Sstevel@tonic-gate #ifdef GSI 827c478bd9Sstevel@tonic-gate int gss_globus_deleg_limited_proxy; 837c478bd9Sstevel@tonic-gate #endif /* GSI */ 847c478bd9Sstevel@tonic-gate #endif /* GSSAPI */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #ifdef AFS 877c478bd9Sstevel@tonic-gate int afs_token_passing; /* Try AFS token passing. */ 887c478bd9Sstevel@tonic-gate #endif 897c478bd9Sstevel@tonic-gate int password_authentication; /* Try password 907c478bd9Sstevel@tonic-gate * authentication. */ 917c478bd9Sstevel@tonic-gate int kbd_interactive_authentication; /* Try keyboard-interactive auth. */ 927c478bd9Sstevel@tonic-gate char *kbd_interactive_devices; /* Keyboard-interactive auth devices. */ 937c478bd9Sstevel@tonic-gate int batch_mode; /* Batch mode: do not ask for passwords. */ 947c478bd9Sstevel@tonic-gate int check_host_ip; /* Also keep track of keys for IP address */ 957c478bd9Sstevel@tonic-gate int strict_host_key_checking; /* Strict host key checking. */ 967c478bd9Sstevel@tonic-gate int compression; /* Compress packets in both directions. */ 977c478bd9Sstevel@tonic-gate int compression_level; /* Compression level 1 (fast) to 9 987c478bd9Sstevel@tonic-gate * (best). */ 997c478bd9Sstevel@tonic-gate int keepalives; /* Set SO_KEEPALIVE. */ 1007c478bd9Sstevel@tonic-gate LogLevel log_level; /* Level for logging. */ 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate int port; /* Port to connect. */ 1037c478bd9Sstevel@tonic-gate int connection_attempts; /* Max attempts (seconds) before 1047c478bd9Sstevel@tonic-gate * giving up */ 10547b374ffSjp161948 int connection_timeout; /* Max time (seconds) before 10647b374ffSjp161948 * aborting connection attempt */ 1077c478bd9Sstevel@tonic-gate int number_of_password_prompts; /* Max number of password 1087c478bd9Sstevel@tonic-gate * prompts. */ 1097c478bd9Sstevel@tonic-gate int cipher; /* Cipher to use. */ 1107c478bd9Sstevel@tonic-gate char *ciphers; /* SSH2 ciphers in order of preference. */ 1117c478bd9Sstevel@tonic-gate char *macs; /* SSH2 macs in order of preference. */ 1127c478bd9Sstevel@tonic-gate char *hostkeyalgorithms; /* SSH2 server key types in order of preference. */ 1137c478bd9Sstevel@tonic-gate int protocol; /* Protocol in order of preference. */ 1147c478bd9Sstevel@tonic-gate char *hostname; /* Real host to connect. */ 1157c478bd9Sstevel@tonic-gate char *host_key_alias; /* hostname alias for .ssh/known_hosts */ 1167c478bd9Sstevel@tonic-gate char *proxy_command; /* Proxy command for connecting the host. */ 1177c478bd9Sstevel@tonic-gate char *user; /* User to log in as. */ 1187c478bd9Sstevel@tonic-gate int escape_char; /* Escape character; -2 = none */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate char *system_hostfile;/* Path for /etc/ssh/ssh_known_hosts. */ 1217c478bd9Sstevel@tonic-gate char *user_hostfile; /* Path for $HOME/.ssh/known_hosts. */ 1227c478bd9Sstevel@tonic-gate char *system_hostfile2; 1237c478bd9Sstevel@tonic-gate char *user_hostfile2; 1247c478bd9Sstevel@tonic-gate char *preferred_authentications; 1257c478bd9Sstevel@tonic-gate char *bind_address; /* local socket address for connection to sshd */ 1267c478bd9Sstevel@tonic-gate char *smartcard_device; /* Smartcard reader device */ 127e5e9dedaSjp161948 int disable_banner; /* Disable display of banner */ 1287c478bd9Sstevel@tonic-gate 1295d7f3ec0Sjp161948 /* 1305d7f3ec0Sjp161948 * Unknown options listed in IgnoreIfUnknown will not cause ssh to 1315d7f3ec0Sjp161948 * exit. So, we must store all unknown options here and can't process 1325d7f3ec0Sjp161948 * them before the command line options and all config files are read 1335d7f3ec0Sjp161948 * and IgnoreIfUnknown is properly set. 1345d7f3ec0Sjp161948 */ 1355d7f3ec0Sjp161948 char *ignore_if_unknown; 1365d7f3ec0Sjp161948 int unknown_opts_num; 1375d7f3ec0Sjp161948 StoredOption unknown_opts[MAX_UNKNOWN_OPTIONS]; 1385d7f3ec0Sjp161948 1397c478bd9Sstevel@tonic-gate int num_identity_files; /* Number of files for RSA/DSA identities. */ 1407c478bd9Sstevel@tonic-gate char *identity_files[SSH_MAX_IDENTITY_FILES]; 1417c478bd9Sstevel@tonic-gate Key *identity_keys[SSH_MAX_IDENTITY_FILES]; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* Local TCP/IP forward requests. */ 1447c478bd9Sstevel@tonic-gate int num_local_forwards; 1457c478bd9Sstevel@tonic-gate Forward local_forwards[SSH_MAX_FORWARDS_PER_DIRECTION]; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* Remote TCP/IP forward requests. */ 1487c478bd9Sstevel@tonic-gate int num_remote_forwards; 1497c478bd9Sstevel@tonic-gate Forward remote_forwards[SSH_MAX_FORWARDS_PER_DIRECTION]; 1507c478bd9Sstevel@tonic-gate int clear_forwardings; 1519a8058b5Sjp161948 1529a8058b5Sjp161948 int64_t rekey_limit; 1537c478bd9Sstevel@tonic-gate int no_host_authentication_for_localhost; 1541434cf01Sjp161948 int server_alive_interval; 1551434cf01Sjp161948 int server_alive_count_max; 156442d23f4Sjp161948 157442d23f4Sjp161948 int hash_known_hosts; 158*cd7d5fafSJan Pechanec int use_openssl_engine; 1597c478bd9Sstevel@tonic-gate } Options; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate void initialize_options(Options *); 1637c478bd9Sstevel@tonic-gate void fill_default_options(Options *); 1647c478bd9Sstevel@tonic-gate int read_config_file(const char *, const char *, Options *); 1659b03ea0fSjp161948 int parse_forward(int, Forward *, const char *); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate int 1687c478bd9Sstevel@tonic-gate process_config_line(Options *, const char *, char *, const char *, int, int *); 1697c478bd9Sstevel@tonic-gate 1709b03ea0fSjp161948 void add_local_forward(Options *, const Forward *); 1719b03ea0fSjp161948 void add_remote_forward(Options *, const Forward *); 1727c478bd9Sstevel@tonic-gate 1739b03ea0fSjp161948 void process_unknown_options(Options *); 1745d7f3ec0Sjp161948 1757c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate #endif 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #endif /* _READCONF_H */ 180