Main Page | Namespace List | Class List | Directories | File List | Class Members | File Members

auth.h

Go to the documentation of this file.
00001 /*      $OpenBSD: auth.h,v 1.51 2005/06/06 11:20:36 djm Exp $   */
00002 
00003 /*
00004  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00017  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00018  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00019  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00020  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00021  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00022  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00024  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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;     /* authentication needs another step */
00053         int              valid;         /* user exists and is allowed to login */
00054         int              attempt;
00055         int              failures;
00056         int              force_pwchange;
00057         char            *user;          /* username sent by the client */
00058         char            *service;
00059         struct passwd   *pw;            /* set if 'valid' */
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  * Every authentication method has to handle authentication requests for
00077  * non-existing users, or for users that are not allowed to login. In this
00078  * case 'valid' is set to 0, but 'user' points to the username requested by
00079  * the client.
00080  */
00081 
00082 struct Authmethod {
00083         char    *name;
00084         int     (*userauth)(Authctxt *authctxt);
00085         int     *enabled;
00086 };
00087 
00088 /*
00089  * Keyboard interactive device:
00090  * init_ctx     returns: non NULL upon success
00091  * query        returns: 0 - success, otherwise failure
00092  * respond      returns: 0 - success, 1 - need further interaction,
00093  *              otherwise - failure
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 /* KRB5 */
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 /* hostkey handling */
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 /* debug messages during authentication */
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

© sourcejam.com 2005-2008