Imported Upstream version 1.8.7
[debian/sudo] / plugins / sudoers / auth / sudo_auth.h
1 /*
2  * Copyright (c) 1999-2005, 2007-2012 Todd C. Miller <Todd.Miller@courtesan.com>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef SUDO_AUTH_H
18 #define SUDO_AUTH_H
19
20 /* Auth function return values.  */
21 #define AUTH_SUCCESS    0
22 #define AUTH_FAILURE    1
23 #define AUTH_INTR       2
24 #define AUTH_FATAL      3
25
26 typedef struct sudo_auth {
27     int flags;                  /* various flags, see below */
28     int status;                 /* status from verify routine */
29     char *name;                 /* name of the method as a string */
30     void *data;                 /* method-specific data pointer */
31     int (*init)(struct passwd *pw, struct sudo_auth *auth);
32     int (*setup)(struct passwd *pw, char **prompt, struct sudo_auth *auth);
33     int (*verify)(struct passwd *pw, char *p, struct sudo_auth *auth);
34     int (*cleanup)(struct passwd *pw, struct sudo_auth *auth);
35     int (*begin_session)(struct passwd *pw, char **user_env[], struct sudo_auth *auth);
36     int (*end_session)(struct passwd *pw, struct sudo_auth *auth);
37 } sudo_auth;
38
39 /* Values for sudo_auth.flags.  */
40 #define FLAG_USER       0x01    /* functions must run as the user, not root */
41 #define FLAG_DISABLED   0x02    /* method disabled */
42 #define FLAG_STANDALONE 0x04    /* standalone auth method */
43 #define FLAG_ONEANDONLY 0x08    /* one and only auth method */
44
45 /* Shortcuts for using the flags above. */
46 #define NEEDS_USER(x)           ((x)->flags & FLAG_USER)
47 #define IS_DISABLED(x)          ((x)->flags & FLAG_DISABLED)
48 #define IS_STANDALONE(x)        ((x)->flags & FLAG_STANDALONE)
49 #define IS_ONEANDONLY(x)        ((x)->flags & FLAG_ONEANDONLY)
50
51 /* Like tgetpass() but uses conversation function */
52 char *auth_getpass(const char *prompt, int timeout, int type);
53
54 /* Pointer to conversation function to use with auth_getpass(). */
55 extern sudo_conv_t sudo_conv;
56
57 /* Prototypes for standalone methods */
58 int bsdauth_init(struct passwd *pw, sudo_auth *auth);
59 int bsdauth_verify(struct passwd *pw, char *prompt, sudo_auth *auth);
60 int bsdauth_cleanup(struct passwd *pw, sudo_auth *auth);
61 int sudo_aix_verify(struct passwd *pw, char *pass, sudo_auth *auth);
62 int sudo_aix_cleanup(struct passwd *pw, sudo_auth *auth);
63 int sudo_fwtk_init(struct passwd *pw, sudo_auth *auth);
64 int sudo_fwtk_verify(struct passwd *pw, char *prompt, sudo_auth *auth);
65 int sudo_fwtk_cleanup(struct passwd *pw, sudo_auth *auth);
66 int sudo_pam_init(struct passwd *pw, sudo_auth *auth);
67 int sudo_pam_verify(struct passwd *pw, char *prompt, sudo_auth *auth);
68 int sudo_pam_cleanup(struct passwd *pw, sudo_auth *auth);
69 int sudo_pam_begin_session(struct passwd *pw, char **user_env[], sudo_auth *auth);
70 int sudo_pam_end_session(struct passwd *pw, sudo_auth *auth);
71 int sudo_securid_init(struct passwd *pw, sudo_auth *auth);
72 int sudo_securid_setup(struct passwd *pw, char **prompt, sudo_auth *auth);
73 int sudo_securid_verify(struct passwd *pw, char *pass, sudo_auth *auth);
74 int sudo_sia_setup(struct passwd *pw, char **prompt, sudo_auth *auth);
75 int sudo_sia_verify(struct passwd *pw, char *prompt, sudo_auth *auth);
76 int sudo_sia_cleanup(struct passwd *pw, sudo_auth *auth);
77
78 /* Prototypes for normal methods */
79 int sudo_afs_verify(struct passwd *pw, char *pass, sudo_auth *auth);
80 int sudo_dce_verify(struct passwd *pw, char *pass, sudo_auth *auth);
81 int sudo_krb5_init(struct passwd *pw, sudo_auth *auth);
82 int sudo_krb5_setup(struct passwd *pw, char **prompt, sudo_auth *auth);
83 int sudo_krb5_verify(struct passwd *pw, char *pass, sudo_auth *auth);
84 int sudo_krb5_cleanup(struct passwd *pw, sudo_auth *auth);
85 int sudo_passwd_init(struct passwd *pw, sudo_auth *auth);
86 int sudo_passwd_verify(struct passwd *pw, char *pass, sudo_auth *auth);
87 int sudo_passwd_cleanup(struct passwd *pw, sudo_auth *auth);
88 int sudo_rfc1938_setup(struct passwd *pw, char **prompt, sudo_auth *auth);
89 int sudo_rfc1938_verify(struct passwd *pw, char *pass, sudo_auth *auth);
90 int sudo_secureware_init(struct passwd *pw, sudo_auth *auth);
91 int sudo_secureware_verify(struct passwd *pw, char *pass, sudo_auth *auth);
92 int sudo_secureware_cleanup(struct passwd *pw, sudo_auth *auth);
93
94 /* Fields: name, flags, init, setup, verify, cleanup, begin_sess, end_sess */
95 #define AUTH_ENTRY(n, f, i, s, v, c, b, e) \
96         { (f), AUTH_FAILURE, (n), NULL, (i), (s), (v), (c) , (b), (e) },
97
98 #endif /* SUDO_AUTH_H */