]>
Commit | Line | Data |
---|---|---|
2ce0bfe4 | 1 | /* $OpenBSD: auth.h,v 1.51 2005/06/06 11:20:36 djm Exp $ */ |
e9702f7d | 2 | |
3c0ef626 | 3 | /* |
4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | |
5 | * | |
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. | |
14 | * | |
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. | |
25 | * | |
3c0ef626 | 26 | */ |
e9702f7d | 27 | |
3c0ef626 | 28 | #ifndef AUTH_H |
29 | #define AUTH_H | |
30 | ||
31 | #include "key.h" | |
32 | #include "hostfile.h" | |
8b32eddc | 33 | #include "buffer.h" |
3c0ef626 | 34 | #include <openssl/rsa.h> |
35 | ||
36 | #ifdef HAVE_LOGIN_CAP | |
37 | #include <login_cap.h> | |
38 | #endif | |
39 | #ifdef BSD_AUTH | |
40 | #include <bsd_auth.h> | |
41 | #endif | |
42 | #ifdef KRB5 | |
43 | #include <krb5.h> | |
44 | #endif | |
7cac2b65 | 45 | #ifdef AFS_KRB5 |
46 | #include <krbafs.h> | |
47 | #endif | |
3c0ef626 | 48 | |
49 | typedef struct Authctxt Authctxt; | |
44a053a3 | 50 | typedef struct Authmethod Authmethod; |
3c0ef626 | 51 | typedef struct KbdintDevice KbdintDevice; |
52 | ||
53 | struct Authctxt { | |
54 | int success; | |
7cac2b65 | 55 | int postponed; /* authentication needs another step */ |
56 | int valid; /* user exists and is allowed to login */ | |
3c0ef626 | 57 | int attempt; |
58 | int failures; | |
fe4ad273 | 59 | int server_caused_failure; |
540d72c3 | 60 | int force_pwchange; |
7cac2b65 | 61 | char *user; /* username sent by the client */ |
3c0ef626 | 62 | char *service; |
7cac2b65 | 63 | struct passwd *pw; /* set if 'valid' */ |
3c0ef626 | 64 | char *style; |
65 | void *kbdintctxt; | |
66 | #ifdef BSD_AUTH | |
67 | auth_session_t *as; | |
68 | #endif | |
3c0ef626 | 69 | #ifdef KRB5 |
70 | krb5_context krb5_ctx; | |
3c0ef626 | 71 | krb5_ccache krb5_fwd_ccache; |
72 | krb5_principal krb5_user; | |
73 | char *krb5_ticket_file; | |
12a403af | 74 | char *krb5_ccname; |
75be3237 | 75 | #endif |
76 | #ifdef SESSION_HOOKS | |
77 | char *session_env_file; | |
3c0ef626 | 78 | #endif |
8b32eddc | 79 | Buffer *loginmsg; |
7cac2b65 | 80 | void *methoddata; |
3c0ef626 | 81 | }; |
7cac2b65 | 82 | /* |
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. | |
87 | */ | |
3c0ef626 | 88 | |
44a053a3 | 89 | struct Authmethod { |
90 | char *name; | |
91 | int (*userauth)(Authctxt *authctxt); | |
92 | int *enabled; | |
93 | }; | |
94 | ||
3c0ef626 | 95 | /* |
96 | * Keyboard interactive device: | |
e9702f7d | 97 | * init_ctx returns: non NULL upon success |
98 | * query returns: 0 - success, otherwise failure | |
3c0ef626 | 99 | * respond returns: 0 - success, 1 - need further interaction, |
100 | * otherwise - failure | |
101 | */ | |
102 | struct KbdintDevice | |
103 | { | |
104 | const char *name; | |
e9702f7d | 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); | |
3c0ef626 | 110 | }; |
111 | ||
350391c5 | 112 | int auth_rhosts(struct passwd *, const char *); |
3c0ef626 | 113 | int |
114 | auth_rhosts2(struct passwd *, const char *, const char *, const char *); | |
115 | ||
540d72c3 | 116 | int auth_rhosts_rsa(Authctxt *, char *, Key *); |
3c0ef626 | 117 | int auth_password(Authctxt *, const char *); |
540d72c3 | 118 | int auth_rsa(Authctxt *, BIGNUM *); |
350391c5 | 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 **); | |
123 | ||
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 *); | |
3c0ef626 | 127 | |
3c0ef626 | 128 | #ifdef KRB5 |
d03f4262 | 129 | int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *); |
3c0ef626 | 130 | int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt); |
131 | int auth_krb5_password(Authctxt *authctxt, const char *password); | |
540d72c3 | 132 | void krb5_cleanup_proc(Authctxt *authctxt); |
3c0ef626 | 133 | #endif /* KRB5 */ |
134 | ||
540d72c3 | 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 | |
140 | ||
3c0ef626 | 141 | #include "auth-pam.h" |
dfddba3d | 142 | #include "audit.h" |
143 | void remove_kbdint_device(const char *); | |
144 | ||
540d72c3 | 145 | void disable_forwarding(void); |
3c0ef626 | 146 | |
540d72c3 | 147 | void do_authentication(Authctxt *); |
148 | void do_authentication2(Authctxt *); | |
3c0ef626 | 149 | |
3c0ef626 | 150 | void auth_log(Authctxt *, int, char *, char *); |
151 | void userauth_finish(Authctxt *, int, char *); | |
dfddba3d | 152 | void userauth_send_banner(const char *); |
3c0ef626 | 153 | int auth_root_allowed(char *); |
154 | ||
350391c5 | 155 | char *auth2_read_banner(void); |
156 | ||
157 | void privsep_challenge_enable(void); | |
158 | ||
3c0ef626 | 159 | int auth2_challenge(Authctxt *, char *); |
e9702f7d | 160 | void auth2_challenge_stop(Authctxt *); |
350391c5 | 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 **); | |
3c0ef626 | 165 | |
166 | int allowed_user(struct passwd *); | |
350391c5 | 167 | struct passwd * getpwnamallow(const char *user); |
3c0ef626 | 168 | |
169 | char *get_challenge(Authctxt *); | |
170 | int verify_response(Authctxt *, const char *); | |
7cac2b65 | 171 | void abandon_challenge_response(Authctxt *); |
3c0ef626 | 172 | |
3c0ef626 | 173 | char *authorized_keys_file(struct passwd *); |
174 | char *authorized_keys_file2(struct passwd *); | |
175 | ||
176 | int | |
177 | secure_filename(FILE *, const char *, struct passwd *, char *, size_t); | |
178 | ||
179 | HostStatus | |
180 | check_key_in_hostfiles(struct passwd *, Key *, const char *, | |
181 | const char *, const char *); | |
182 | ||
350391c5 | 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 *); | |
188 | ||
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); | |
193 | ||
7cac2b65 | 194 | struct passwd *fakepw(void); |
195 | ||
8b32eddc | 196 | int sys_auth_passwd(Authctxt *, const char *); |
197 | ||
3c0ef626 | 198 | #define AUTH_FAIL_MSG "Too many authentication failures for %.100s" |
199 | ||
350391c5 | 200 | #define SKEY_PROMPT "\nS/Key Password: " |
2ce0bfe4 | 201 | |
202 | #if defined(KRB5) && !defined(HEIMDAL) | |
203 | #include <krb5.h> | |
204 | krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *); | |
205 | #endif | |
3c0ef626 | 206 | #endif |