5 ** Copyright 2004 Double Precision, Inc. See COPYING for
6 ** distribution information.
9 #include "courier_auth_config.h"
10 #include <sys/types.h>
16 static const char courierauth_h_rcsid
[]="$Id: courierauth.h,v 1.4 2005/02/21 03:34:19 mrsam Exp $";
19 Callback authentication structure:
23 const char *sysusername
;
24 const uid_t
*sysuserid
;
34 const char *clearpasswd
; /* For authldap */
40 Either sysusername or sysuserid may be NULL, but not both of them.
41 They, and sysgroupid, specify the authenticated user's system
42 userid and groupid. homedir points to the authenticated user's
43 home directory. address, fullname, and maildir, are obvious.
44 quota is populated with any maildir quota (see
45 maildir/README.maildirquota).
47 'options' is an optional string that contains per-user custom settings.
50 After populating this tructure, the lookup function calls the
51 callback function that's specified in its second argument. The
52 callback function receives a pointer to the authinfo structure.
54 The callback function also receives a context pointer, which is
55 the third argument to the lookup function.
57 The lookup function should return a negative value if he userid
58 does not exist, a positive value if there was a temporary error
59 looking up the userid, or whatever is the return code from the
60 callback function, if the user exists.
64 #define AUTHTYPE_LOGIN "login" /* authdata is userid\npassword\n */
65 #define AUTHTYPE_CRAMMD5 "cram-md5" /* authdata is challenge\nresponse\n */
66 #define AUTHTYPE_CRAMSHA1 "cram-sha1" /* authdata is challenge\nresponse\n */
67 #define AUTHTYPE_CRAMSHA256 "cram-sha256" /* authdata is challenge\nresponse\n */
69 /* auth_generic: INTERNAL */
71 int auth_generic(const char *service
,
74 int (*callback_func
)(struct authinfo
*, void *),
78 int auth_login(const char *service
,
81 int (*callback_func
)(struct authinfo
*, void *),
84 /* Return account info: */
85 int auth_getuserinfo(const char *service
, const char *uid
,
86 int (*callback
)(struct authinfo
*, void *),
89 /* Enumerate accounts */
90 void auth_enumerate( void(*cb_func
)(const char *name
,
99 /* Change the password */
100 int auth_passwd(const char *service
,
105 /* Utility function: parse OPTIONS string for a particular keyword */
107 extern int auth_getoptionenvint(const char *keyword
);
108 extern char *auth_getoptionenv(const char *keyword
);
109 extern char *auth_getoption(const char *options
, const char *keyword
);
113 ** Utility function: typical action in a callback for auth_generic
114 ** or auth_login. Does the following:
116 ** Drops root, takes uid/gid in ainfo.
118 ** Changes current directory to the home directory.
120 ** Returns: <0 - fatal error before dropping root.
121 ** >0 - fatal error after dropping root.
125 int auth_callback_default(struct authinfo
*ainfo
);