5 ** Copyright 2004 Double Precision, Inc. See COPYING for
6 ** distribution information.
9 #include "courier_auth_config.h"
10 #include <sys/types.h>
18 Callback authentication structure:
22 const char *sysusername
;
23 const uid_t
*sysuserid
;
33 const char *clearpasswd
; /* For authldap */
39 Either sysusername or sysuserid may be NULL, but not both of them.
40 They, and sysgroupid, specify the authenticated user's system
41 userid and groupid. homedir points to the authenticated user's
42 home directory. address, fullname, and maildir, are obvious.
43 quota is populated with any maildir quota (see
44 maildir/README.maildirquota).
46 'options' is an optional string that contains per-user custom settings.
49 After populating this tructure, the lookup function calls the
50 callback function that's specified in its second argument. The
51 callback function receives a pointer to the authinfo structure.
53 The callback function also receives a context pointer, which is
54 the third argument to the lookup function.
56 The lookup function should return a negative value if he userid
57 does not exist, a positive value if there was a temporary error
58 looking up the userid, or whatever is the return code from the
59 callback function, if the user exists.
63 #define AUTHTYPE_LOGIN "login" /* authdata is userid\npassword\n */
64 #define AUTHTYPE_CRAMMD5 "cram-md5" /* authdata is challenge\nresponse\n */
65 #define AUTHTYPE_CRAMSHA1 "cram-sha1" /* authdata is challenge\nresponse\n */
66 #define AUTHTYPE_CRAMSHA256 "cram-sha256" /* authdata is challenge\nresponse\n */
68 /* auth_generic: INTERNAL */
70 int auth_generic(const char *service
,
73 int (*callback_func
)(struct authinfo
*, void *),
77 int auth_login(const char *service
,
80 int (*callback_func
)(struct authinfo
*, void *),
83 /* Return account info: */
84 int auth_getuserinfo(const char *service
, const char *uid
,
85 int (*callback
)(struct authinfo
*, void *),
88 /* Enumerate accounts */
89 void auth_enumerate( void(*cb_func
)(const char *name
,
98 /* Change the password */
99 int auth_passwd(const char *service
,
104 /* Utility function: parse OPTIONS string for a particular keyword */
106 extern int auth_getoptionenvint(const char *keyword
);
107 extern char *auth_getoptionenv(const char *keyword
);
108 extern char *auth_getoption(const char *options
, const char *keyword
);
112 ** Utility function: typical action in a callback for auth_generic
113 ** or auth_login. Does the following:
115 ** Drops root, takes uid/gid in ainfo.
117 ** Changes current directory to the home directory.
119 ** Returns: <0 - fatal error before dropping root.
120 ** >0 - fatal error after dropping root.
124 int auth_callback_default(struct authinfo
*ainfo
);
126 /* Utility function: escape LDAP special characters */
128 char *courier_auth_ldap_escape(const char *str
);