2 * Copyright (c) 1999-2005, 2007-2009 Todd C. Miller <Todd.Miller@courtesan.com>
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.
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.
16 * $Sudo: sudo_auth.h,v 1.29 2009/05/25 12:02:42 millert Exp $
22 /* Auth function return values. */
23 #define AUTH_SUCCESS 0
24 #define AUTH_FAILURE 1
28 typedef struct sudo_auth {
29 short flags; /* various flags, see below */
30 short status; /* status from verify routine */
31 char *name; /* name of the method as a string */
32 void *data; /* method-specific data pointer */
33 int (*init) __P((struct passwd *pw, char **prompt, struct sudo_auth *auth));
34 int (*setup) __P((struct passwd *pw, char **prompt, struct sudo_auth *auth));
35 int (*verify) __P((struct passwd *pw, char *p, struct sudo_auth *auth));
36 int (*cleanup) __P((struct passwd *pw, struct sudo_auth *auth));
39 /* Values for sudo_auth.flags. */
40 /* XXX - these names are too long for my liking */
41 #define FLAG_USER 0x01 /* functions must run as the user, not root */
42 #define FLAG_CONFIGURED 0x02 /* method configured ok */
43 #define FLAG_ONEANDONLY 0x04 /* one and only auth method */
45 /* Shortcuts for using the flags above. */
46 #define NEEDS_USER(x) ((x)->flags & FLAG_USER)
47 #define IS_CONFIGURED(x) ((x)->flags & FLAG_CONFIGURED)
48 #define IS_ONEANDONLY(x) ((x)->flags & FLAG_ONEANDONLY)
50 /* Prototypes for standalone methods */
51 int fwtk_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
52 int fwtk_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
53 int fwtk_cleanup __P((struct passwd *pw, sudo_auth *auth));
54 int pam_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
55 int pam_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
56 int pam_cleanup __P((struct passwd *pw, sudo_auth *auth));
57 int sia_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
58 int sia_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
59 int sia_cleanup __P((struct passwd *pw, sudo_auth *auth));
60 int aixauth_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
61 int aixauth_cleanup __P((struct passwd *pw, sudo_auth *auth));
62 int bsdauth_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
63 int bsdauth_verify __P((struct passwd *pw, char *prompt, sudo_auth *auth));
64 int bsdauth_cleanup __P((struct passwd *pw, sudo_auth *auth));
66 /* Prototypes for normal methods */
67 int passwd_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
68 int passwd_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
69 int secureware_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
70 int secureware_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
71 int rfc1938_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
72 int rfc1938_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
73 int afs_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
74 int dce_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
75 int kerb4_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
76 int kerb4_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
77 int kerb5_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
78 int kerb5_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
79 int kerb5_cleanup __P((struct passwd *pw, sudo_auth *auth));
80 int securid_init __P((struct passwd *pw, char **prompt, sudo_auth *auth));
81 int securid_setup __P((struct passwd *pw, char **prompt, sudo_auth *auth));
82 int securid_verify __P((struct passwd *pw, char *pass, sudo_auth *auth));
84 /* Fields: need_root, name, init, setup, verify, cleanup */
85 #define AUTH_ENTRY(r, n, i, s, v, c) \
86 { (r|FLAG_CONFIGURED), AUTH_FAILURE, n, NULL, i, s, v, c },
88 /* Some methods cannots (or should not) interoperate with any others */
90 # define AUTH_STANDALONE \
91 AUTH_ENTRY(0, "pam", \
92 pam_init, NULL, pam_verify, pam_cleanup)
93 #elif defined(HAVE_SECURID)
94 # define AUTH_STANDALONE \
95 AUTH_ENTRY(0, "SecurId", \
96 securid_init, securid_setup, securid_verify, NULL)
97 #elif defined(HAVE_SIA_SES_INIT)
98 # define AUTH_STANDALONE \
99 AUTH_ENTRY(0, "sia", \
100 NULL, sia_setup, sia_verify, sia_cleanup)
101 #elif defined(HAVE_AIXAUTH)
102 # define AUTH_STANDALONE \
103 AUTH_ENTRY(0, "aixauth", \
104 NULL, NULL, aixauth_verify, aixauth_cleanup)
105 #elif defined(HAVE_FWTK)
106 # define AUTH_STANDALONE \
107 AUTH_ENTRY(0, "fwtk", \
108 fwtk_init, NULL, fwtk_verify, fwtk_cleanup)
109 #elif defined(HAVE_BSD_AUTH_H)
110 # define AUTH_STANDALONE \
111 AUTH_ENTRY(0, "bsdauth", \
112 bsdauth_init, NULL, bsdauth_verify, bsdauth_cleanup)
115 #endif /* SUDO_AUTH_H */