Imported Upstream version 1.7.4p6
[debian/sudo] / auth / sudo_auth.h
1 /*
2  * Copyright (c) 1999-2005, 2007-2009 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     short flags;                /* various flags, see below */
28     short 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) __P((struct passwd *pw, char **prompt, struct sudo_auth *auth));
32     int (*setup) __P((struct passwd *pw, char **prompt, struct sudo_auth *auth));
33     int (*verify) __P((struct passwd *pw, char *p, struct sudo_auth *auth));
34     int (*cleanup) __P((struct passwd *pw, struct sudo_auth *auth));
35 } sudo_auth;
36
37 /* Values for sudo_auth.flags.  */
38 /* XXX - these names are too long for my liking */
39 #define FLAG_USER       0x01    /* functions must run as the user, not root */
40 #define FLAG_CONFIGURED 0x02    /* method configured ok */
41 #define FLAG_ONEANDONLY 0x04    /* one and only auth method */
42
43 /* Shortcuts for using the flags above. */
44 #define NEEDS_USER(x)           ((x)->flags & FLAG_USER)
45 #define IS_CONFIGURED(x)        ((x)->flags & FLAG_CONFIGURED)
46 #define IS_ONEANDONLY(x)        ((x)->flags & FLAG_ONEANDONLY)
47
48 /* Prototypes for standalone methods */
49 int fwtk_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
50 int fwtk_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
51 int fwtk_cleanup __P((struct passwd *pw, sudo_auth *auth));
52 int pam_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
53 int pam_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
54 int pam_cleanup __P((struct passwd *pw, sudo_auth *auth));
55 int sia_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
56 int sia_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
57 int sia_cleanup __P((struct passwd *pw, sudo_auth *auth));
58 int aixauth_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
59 int aixauth_cleanup __P((struct passwd *pw, sudo_auth *auth));
60 int bsdauth_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
61 int bsdauth_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
62 int bsdauth_cleanup __P((struct passwd *pw, sudo_auth *auth));
63
64 /* Prototypes for normal methods */
65 int passwd_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
66 int passwd_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
67 int secureware_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
68 int secureware_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
69 int rfc1938_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
70 int rfc1938_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
71 int afs_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
72 int dce_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
73 int kerb4_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
74 int kerb4_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
75 int kerb5_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
76 int kerb5_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
77 int kerb5_cleanup __P((struct passwd *pw, sudo_auth *auth));
78 int securid_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
79 int securid_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
80 int securid_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
81
82 /* Fields: need_root, name, init, setup, verify, cleanup */
83 #define AUTH_ENTRY(r, n, i, s, v, c) \
84         { (r|FLAG_CONFIGURED), AUTH_FAILURE, n, NULL, i, s, v, c },
85
86 /* Some methods cannots (or should not) interoperate with any others */
87 #if defined(HAVE_PAM)
88 #  define AUTH_STANDALONE \
89         AUTH_ENTRY(0, "pam", \
90             pam_init, NULL, pam_verify, pam_cleanup)
91 #elif defined(HAVE_SECURID)
92 #  define AUTH_STANDALONE \
93         AUTH_ENTRY(0, "SecurId", \
94             securid_init, securid_setup, securid_verify, NULL)
95 #elif defined(HAVE_SIA_SES_INIT)
96 #  define AUTH_STANDALONE \
97         AUTH_ENTRY(0, "sia", \
98             NULL, sia_setup, sia_verify, sia_cleanup)
99 #elif defined(HAVE_AIXAUTH)
100 #  define AUTH_STANDALONE \
101         AUTH_ENTRY(0, "aixauth", \
102             NULL, NULL, aixauth_verify, aixauth_cleanup)
103 #elif defined(HAVE_FWTK)
104 #  define AUTH_STANDALONE \
105         AUTH_ENTRY(0, "fwtk", \
106             fwtk_init, NULL, fwtk_verify, fwtk_cleanup)
107 #elif defined(HAVE_BSD_AUTH_H)
108 #  define AUTH_STANDALONE \
109         AUTH_ENTRY(0, "bsdauth", \
110             bsdauth_init, NULL, bsdauth_verify, bsdauth_cleanup)
111 #endif
112
113 #endif /* SUDO_AUTH_H */