]> andersk Git - gssapi-openssh.git/blame - openssh/auth.h
merged OpenSSH 4.2p1 to trunk
[gssapi-openssh.git] / openssh / auth.h
CommitLineData
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
49typedef struct Authctxt Authctxt;
44a053a3 50typedef struct Authmethod Authmethod;
3c0ef626 51typedef struct KbdintDevice KbdintDevice;
52
53struct 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;
540d72c3 59 int force_pwchange;
7cac2b65 60 char *user; /* username sent by the client */
3c0ef626 61 char *service;
7cac2b65 62 struct passwd *pw; /* set if 'valid' */
3c0ef626 63 char *style;
64 void *kbdintctxt;
65#ifdef BSD_AUTH
66 auth_session_t *as;
67#endif
3c0ef626 68#ifdef KRB5
69 krb5_context krb5_ctx;
3c0ef626 70 krb5_ccache krb5_fwd_ccache;
71 krb5_principal krb5_user;
72 char *krb5_ticket_file;
12a403af 73 char *krb5_ccname;
75be3237 74#endif
75#ifdef SESSION_HOOKS
76 char *session_env_file;
3c0ef626 77#endif
8b32eddc 78 Buffer *loginmsg;
7cac2b65 79 void *methoddata;
3c0ef626 80};
7cac2b65 81/*
82 * Every authentication method has to handle authentication requests for
83 * non-existing users, or for users that are not allowed to login. In this
84 * case 'valid' is set to 0, but 'user' points to the username requested by
85 * the client.
86 */
3c0ef626 87
44a053a3 88struct Authmethod {
89 char *name;
90 int (*userauth)(Authctxt *authctxt);
91 int *enabled;
92};
93
3c0ef626 94/*
95 * Keyboard interactive device:
e9702f7d 96 * init_ctx returns: non NULL upon success
97 * query returns: 0 - success, otherwise failure
3c0ef626 98 * respond returns: 0 - success, 1 - need further interaction,
99 * otherwise - failure
100 */
101struct KbdintDevice
102{
103 const char *name;
e9702f7d 104 void* (*init_ctx)(Authctxt*);
105 int (*query)(void *ctx, char **name, char **infotxt,
106 u_int *numprompts, char ***prompts, u_int **echo_on);
107 int (*respond)(void *ctx, u_int numresp, char **responses);
108 void (*free_ctx)(void *ctx);
3c0ef626 109};
110
350391c5 111int auth_rhosts(struct passwd *, const char *);
3c0ef626 112int
113auth_rhosts2(struct passwd *, const char *, const char *, const char *);
114
540d72c3 115int auth_rhosts_rsa(Authctxt *, char *, Key *);
3c0ef626 116int auth_password(Authctxt *, const char *);
540d72c3 117int auth_rsa(Authctxt *, BIGNUM *);
350391c5 118int auth_rsa_challenge_dialog(Key *);
119BIGNUM *auth_rsa_generate_challenge(Key *);
120int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
121int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
122
123int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
124int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
125int user_key_allowed(struct passwd *, Key *);
3c0ef626 126
3c0ef626 127#ifdef KRB5
d03f4262 128int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client, krb5_data *);
3c0ef626 129int auth_krb5_tgt(Authctxt *authctxt, krb5_data *tgt);
130int auth_krb5_password(Authctxt *authctxt, const char *password);
540d72c3 131void krb5_cleanup_proc(Authctxt *authctxt);
3c0ef626 132#endif /* KRB5 */
133
540d72c3 134#if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
135#include <shadow.h>
136int auth_shadow_acctexpired(struct spwd *);
137int auth_shadow_pwexpired(Authctxt *);
138#endif
139
3c0ef626 140#include "auth-pam.h"
dfddba3d 141#include "audit.h"
142void remove_kbdint_device(const char *);
143
540d72c3 144void disable_forwarding(void);
3c0ef626 145
540d72c3 146void do_authentication(Authctxt *);
147void do_authentication2(Authctxt *);
3c0ef626 148
3c0ef626 149void auth_log(Authctxt *, int, char *, char *);
150void userauth_finish(Authctxt *, int, char *);
dfddba3d 151void userauth_send_banner(const char *);
3c0ef626 152int auth_root_allowed(char *);
153
350391c5 154char *auth2_read_banner(void);
155
156void privsep_challenge_enable(void);
157
3c0ef626 158int auth2_challenge(Authctxt *, char *);
e9702f7d 159void auth2_challenge_stop(Authctxt *);
350391c5 160int bsdauth_query(void *, char **, char **, u_int *, char ***, u_int **);
161int bsdauth_respond(void *, u_int, char **);
162int skey_query(void *, char **, char **, u_int *, char ***, u_int **);
163int skey_respond(void *, u_int, char **);
3c0ef626 164
165int allowed_user(struct passwd *);
350391c5 166struct passwd * getpwnamallow(const char *user);
3c0ef626 167
168char *get_challenge(Authctxt *);
169int verify_response(Authctxt *, const char *);
7cac2b65 170void abandon_challenge_response(Authctxt *);
3c0ef626 171
3c0ef626 172char *authorized_keys_file(struct passwd *);
173char *authorized_keys_file2(struct passwd *);
174
175int
176secure_filename(FILE *, const char *, struct passwd *, char *, size_t);
177
178HostStatus
179check_key_in_hostfiles(struct passwd *, Key *, const char *,
180 const char *, const char *);
181
350391c5 182/* hostkey handling */
183Key *get_hostkey_by_index(int);
184Key *get_hostkey_by_type(int);
185int get_hostkey_index(Key *);
186int ssh1_session_key(BIGNUM *);
187
188/* debug messages during authentication */
189void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
190void auth_debug_send(void);
191void auth_debug_reset(void);
192
7cac2b65 193struct passwd *fakepw(void);
194
8b32eddc 195int sys_auth_passwd(Authctxt *, const char *);
196
3c0ef626 197#define AUTH_FAIL_MSG "Too many authentication failures for %.100s"
198
350391c5 199#define SKEY_PROMPT "\nS/Key Password: "
2ce0bfe4 200
201#if defined(KRB5) && !defined(HEIMDAL)
202#include <krb5.h>
203krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
204#endif
3c0ef626 205#endif
This page took 0.088716 seconds and 5 git commands to generate.