00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef AUTH_H
00029 #define AUTH_H
00030
00031 #include "key.h"
00032 #include "hostfile.h"
00033 #include "buffer.h"
00034 #include <openssl/rsa.h>
00035
00036 #ifdef HAVE_LOGIN_CAP
00037 #include <login_cap.h>
00038 #endif
00039 #ifdef BSD_AUTH
00040 #include <bsd_auth.h>
00041 #endif
00042 #ifdef KRB5
00043 #include <krb5.h>
00044 #endif
00045
00046 typedef struct Authctxt Authctxt;
00047 typedef struct Authmethod Authmethod;
00048 typedef struct KbdintDevice KbdintDevice;
00049
00050 struct Authctxt {
00051 int success;
00052 int postponed;
00053 int valid;
00054 int attempt;
00055 int failures;
00056 int force_pwchange;
00057 char *user;
00058 char *service;
00059 struct passwd *pw;
00060 char *style;
00061 void *kbdintctxt;
00062 #ifdef BSD_AUTH
00063 auth_session_t *as;
00064 #endif
00065 #ifdef KRB5
00066 krb5_context krb5_ctx;
00067 krb5_ccache krb5_fwd_ccache;
00068 krb5_principal krb5_user;
00069 char *krb5_ticket_file;
00070 char *krb5_ccname;
00071 #endif
00072 Buffer *loginmsg;
00073 void *methoddata;
00074 };
00075
00076
00077
00078
00079
00080
00081
00082 struct Authmethod {
00083 char *name;
00084 int (*userauth)(Authctxt *authctxt);
00085 int *enabled;
00086 };
00087
00088
00089
00090
00091
00092
00093
00094
00095 struct KbdintDevice
00096 {
00097 const char *name;
00098 void* (*init_ctx)(Authctxt*);
00099 int (*query)(void *ctx, char **name, char **infotxt,
00100 u_int *numprompts, char ***prompts, u_int **echo_on);
00101 int (*respond)(void *ctx, u_int numresp, char **responses);
00102 void (*free_ctx)(void *ctx);
00103 };
00104
00105 int auth_rhosts(struct passwd *, const char *);
00106 int
00107 auth_rhosts2(struct passwd *, const char *, const char *, const char *);
00108
00109 int auth_rhosts_rsa(Authctxt *, char *, Key *);
00110 int auth_password(Authctxt *, const char *);
00111 int auth_rsa(Authctxt *, BIGNUM *);
00112 int auth_rsa_challenge_dialog(Key *);
00113 BIGNUM *auth_rsa_generate_challenge(Key *);
00114 int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
00115 int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
00116
00117 int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
00118 int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
00119 int user_key_allowed(struct passwd *, Key *);
00120
00121 #ifdef KRB5
00122 int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
00123 int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);
00124 int auth_krb5_password(Authctxt *authctxt, const char *password);
00125 void krb5_cleanup_proc(Authctxt *authctxt);
00126 #endif
00127
00128 #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
00129 #include <shadow.h>
00130 int auth_shadow_acctexpired(struct spwd *);
00131 int auth_shadow_pwexpired(Authctxt *);
00132 #endif
00133
00134 #include "auth-pam.h"
00135 #include "audit.h"
00136 void remove_kbdint_device(const char *);
00137
00138 void disable_forwarding(void);
00139
00140 void do_authentication(Authctxt *);
00141 void do_authentication2(Authctxt *);
00142
00143 void auth_log(Authctxt *, int, char *, char *);
00144 void userauth_finish(Authctxt *, int, char *);
00145 void userauth_send_banner(const char *);
00146 int auth_root_allowed(char *);
00147
00148 char *auth2_read_banner(void);
00149
00150 void privsep_challenge_enable(void);
00151
00152 int auth2_challenge(Authctxt *, char *);
00153 void auth2_challenge_stop(Authctxt *);
00154 int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **);
00155 int bsdauth_respond(void *, u_int, char **);
00156 int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
00157 int skey_respond(void *, u_int, char **);
00158
00159 int allowed_user(struct passwd *);
00160 struct passwd * getpwnamallow(const char *user);
00161
00162 char *get_challenge(Authctxt *);
00163 int verify_response(Authctxt *, const char *);
00164 void abandon_challenge_response(Authctxt *);
00165
00166 char *authorized_keys_file(struct passwd *);
00167 char *authorized_keys_file2(struct passwd *);
00168
00169 int
00170 secure_filename(FILE *, const char *, struct passwd *, char *, size_t);
00171
00172 HostStatus
00173 check_key_in_hostfiles(struct passwd *, Key *, const char *,
00174 const char *, const char *);
00175
00176
00177 Key *get_hostkey_by_index(int);
00178 Key *get_hostkey_by_type(int);
00179 int get_hostkey_index(Key *);
00180 int ssh1_session_key(BIGNUM *);
00181
00182
00183 void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
00184 void auth_debug_send(void);
00185 void auth_debug_reset(void);
00186
00187 struct passwd *fakepw(void);
00188
00189 int sys_auth_passwd(Authctxt *, const char *);
00190
00191 #define AUTH_FAIL_MSG "Too many authentication failures for %.100s"
00192
00193 #define SKEY_PROMPT "\nS/Key Password: "
00194
00195 #if defined(KRB5) && !defined(HEIMDAL)
00196 #include <krb5.h>
00197 krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
00198 #endif
00199 #endif