]> andersk Git - gssapi-openssh.git/blame - openssh/auth.h
merged OpenSSH 5.1p1 to trunk
[gssapi-openssh.git] / openssh / auth.h
CommitLineData
5156b1a1 1/* $OpenBSD: auth.h,v 1.61 2008/07/02 12:03:51 dtucker 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
30460aeb 31#include <signal.h>
32
3c0ef626 33#include <openssl/rsa.h>
34
35#ifdef HAVE_LOGIN_CAP
36#include <login_cap.h>
37#endif
38#ifdef BSD_AUTH
39#include <bsd_auth.h>
40#endif
41#ifdef KRB5
42#include <krb5.h>
43#endif
7cac2b65 44#ifdef AFS_KRB5
45#include <krbafs.h>
46#endif
3c0ef626 47
48typedef struct Authctxt Authctxt;
44a053a3 49typedef struct Authmethod Authmethod;
3c0ef626 50typedef struct KbdintDevice KbdintDevice;
51
52struct Authctxt {
30460aeb 53 sig_atomic_t success;
54 int authenticated; /* authenticated and alarms cancelled */
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 89struct 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 */
102struct 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 112int auth_rhosts(struct passwd *, const char *);
3c0ef626 113int
114auth_rhosts2(struct passwd *, const char *, const char *, const char *);
115
540d72c3 116int auth_rhosts_rsa(Authctxt *, char *, Key *);
3c0ef626 117int auth_password(Authctxt *, const char *);
540d72c3 118int auth_rsa(Authctxt *, BIGNUM *);
350391c5 119int auth_rsa_challenge_dialog(Key *);
120BIGNUM *auth_rsa_generate_challenge(Key *);
121int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
122int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
123
124int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
125int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
126int user_key_allowed(struct passwd *, Key *);
3c0ef626 127
3c0ef626 128#ifdef KRB5
d03f4262 129int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
3c0ef626 130int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);
131int auth_krb5_password(Authctxt *authctxt, const char *password);
540d72c3 132void krb5_cleanup_proc(Authctxt *authctxt);
3c0ef626 133#endif /* KRB5 */
134
540d72c3 135#if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
136#include <shadow.h>
137int auth_shadow_acctexpired(struct spwd *);
138int auth_shadow_pwexpired(Authctxt *);
139#endif
140
3c0ef626 141#include "auth-pam.h"
dfddba3d 142#include "audit.h"
143void remove_kbdint_device(const char *);
144
540d72c3 145void disable_forwarding(void);
3c0ef626 146
540d72c3 147void do_authentication(Authctxt *);
148void do_authentication2(Authctxt *);
3c0ef626 149
3c0ef626 150void auth_log(Authctxt *, int, char *, char *);
151void userauth_finish(Authctxt *, int, char *);
dfddba3d 152void userauth_send_banner(const char *);
3c0ef626 153int auth_root_allowed(char *);
5fe1e2a8 154char *expand_authorized_keys(const char *filename, struct passwd *pw);
3c0ef626 155
350391c5 156char *auth2_read_banner(void);
157
158void privsep_challenge_enable(void);
159
3c0ef626 160int auth2_challenge(Authctxt *, char *);
e9702f7d 161void auth2_challenge_stop(Authctxt *);
350391c5 162int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **);
163int bsdauth_respond(void *, u_int, char **);
164int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
165int skey_respond(void *, u_int, char **);
3c0ef626 166
167int allowed_user(struct passwd *);
350391c5 168struct passwd * getpwnamallow(const char *user);
3c0ef626 169
170char *get_challenge(Authctxt *);
171int verify_response(Authctxt *, const char *);
7cac2b65 172void abandon_challenge_response(Authctxt *);
3c0ef626 173
3c0ef626 174char *authorized_keys_file(struct passwd *);
175char *authorized_keys_file2(struct passwd *);
176
5156b1a1 177FILE *auth_openkeyfile(const char *, struct passwd *, int);
3c0ef626 178
179HostStatus
180check_key_in_hostfiles(struct passwd *, Key *, const char *,
181 const char *, const char *);
182
350391c5 183/* hostkey handling */
184Key *get_hostkey_by_index(int);
185Key *get_hostkey_by_type(int);
186int get_hostkey_index(Key *);
187int ssh1_session_key(BIGNUM *);
188
189/* debug messages during authentication */
190void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
191void auth_debug_send(void);
192void auth_debug_reset(void);
193
7cac2b65 194struct passwd *fakepw(void);
195
8b32eddc 196int 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>
204krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
205#endif
3c0ef626 206#endif
This page took 0.087688 seconds and 5 git commands to generate.