- (djm) [openbsd-compat/glob.c]
[openssh-git.git] / auth.h
blob65250138fa3a26ed683962ca5a2853989a3eccb7
1 /* $OpenBSD: auth.h,v 1.55 2006/07/23 01:11:05 stevesk Exp $ */
3 /*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef AUTH_H
29 #define AUTH_H
31 #include <sys/types.h>
33 #include <signal.h>
34 #include <pwd.h>
35 #include <signal.h>
37 #include "buffer.h"
38 #include <openssl/rsa.h>
40 #ifdef HAVE_LOGIN_CAP
41 #include <login_cap.h>
42 #endif
43 #ifdef BSD_AUTH
44 #include <bsd_auth.h>
45 #endif
46 #ifdef KRB5
47 #include <krb5.h>
48 #endif
50 #include "key.h"
51 #include "hostfile.h"
53 typedef struct Authctxt Authctxt;
54 typedef struct Authmethod Authmethod;
55 typedef struct KbdintDevice KbdintDevice;
57 struct Authctxt {
58 sig_atomic_t success;
59 int postponed; /* authentication needs another step */
60 int valid; /* user exists and is allowed to login */
61 int attempt;
62 int failures;
63 int force_pwchange;
64 char *user; /* username sent by the client */
65 char *service;
66 struct passwd *pw; /* set if 'valid' */
67 char *style;
68 void *kbdintctxt;
69 #ifdef BSD_AUTH
70 auth_session_t *as;
71 #endif
72 #ifdef KRB5
73 krb5_context krb5_ctx;
74 krb5_ccache krb5_fwd_ccache;
75 krb5_principal krb5_user;
76 char *krb5_ticket_file;
77 char *krb5_ccname;
78 #endif
79 Buffer *loginmsg;
80 void *methoddata;
83 * Every authentication method has to handle authentication requests for
84 * non-existing users, or for users that are not allowed to login. In this
85 * case 'valid' is set to 0, but 'user' points to the username requested by
86 * the client.
89 struct Authmethod {
90 char *name;
91 int (*userauth)(Authctxt *authctxt);
92 int *enabled;
96 * Keyboard interactive device:
97 * init_ctx returns: non NULL upon success
98 * query returns: 0 - success, otherwise failure
99 * respond returns: 0 - success, 1 - need further interaction,
100 * otherwise - failure
102 struct KbdintDevice
104 const char *name;
105 void* (*init_ctx)(Authctxt*);
106 int (*query)(void *ctx, char **name, char **infotxt,
107 u_int *numprompts, char ***prompts, u_int **echo_on);
108 int (*respond)(void *ctx, u_int numresp, char **responses);
109 void (*free_ctx)(void *ctx);
112 int auth_rhosts(struct passwd *, const char *);
114 auth_rhosts2(struct passwd *, const char *, const char *, const char *);
116 int auth_rhosts_rsa(Authctxt *, char *, Key *);
117 int auth_password(Authctxt *, const char *);
118 int auth_rsa(Authctxt *, BIGNUM *);
119 int auth_rsa_challenge_dialog(Key *);
120 BIGNUM *auth_rsa_generate_challenge(Key *);
121 int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
122 int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
124 int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
125 int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
126 int user_key_allowed(struct passwd *, Key *);
128 #ifdef KRB5
129 int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
130 int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);
131 int auth_krb5_password(Authctxt *authctxt, const char *password);
132 void krb5_cleanup_proc(Authctxt *authctxt);
133 #endif /* KRB5 */
135 #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
136 #include <shadow.h>
137 int auth_shadow_acctexpired(struct spwd *);
138 int auth_shadow_pwexpired(Authctxt *);
139 #endif
141 #include "auth-pam.h"
142 #include "audit.h"
143 void remove_kbdint_device(const char *);
145 void disable_forwarding(void);
147 void do_authentication(Authctxt *);
148 void do_authentication2(Authctxt *);
150 void auth_log(Authctxt *, int, char *, char *);
151 void userauth_finish(Authctxt *, int, char *);
152 void userauth_send_banner(const char *);
153 int auth_root_allowed(char *);
155 char *auth2_read_banner(void);
157 void privsep_challenge_enable(void);
159 int auth2_challenge(Authctxt *, char *);
160 void auth2_challenge_stop(Authctxt *);
161 int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **);
162 int bsdauth_respond(void *, u_int, char **);
163 int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
164 int skey_respond(void *, u_int, char **);
166 int allowed_user(struct passwd *);
167 struct passwd * getpwnamallow(const char *user);
169 char *get_challenge(Authctxt *);
170 int verify_response(Authctxt *, const char *);
171 void abandon_challenge_response(Authctxt *);
173 char *authorized_keys_file(struct passwd *);
174 char *authorized_keys_file2(struct passwd *);
177 secure_filename(FILE *, const char *, struct passwd *, char *, size_t);
179 HostStatus
180 check_key_in_hostfiles(struct passwd *, Key *, const char *,
181 const char *, const char *);
183 /* hostkey handling */
184 Key *get_hostkey_by_index(int);
185 Key *get_hostkey_by_type(int);
186 int get_hostkey_index(Key *);
187 int ssh1_session_key(BIGNUM *);
189 /* debug messages during authentication */
190 void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
191 void auth_debug_send(void);
192 void auth_debug_reset(void);
194 struct passwd *fakepw(void);
196 int sys_auth_passwd(Authctxt *, const char *);
198 #define AUTH_FAIL_MSG "Too many authentication failures for %.100s"
200 #define SKEY_PROMPT "\nS/Key Password: "
202 #if defined(KRB5) && !defined(HEIMDAL)
203 #include <krb5.h>
204 krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
205 #endif
206 #endif