2 ** Copyright 1998 - 2008 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
16 #include "authcustom.h"
17 #include "authstaticlist.h"
19 static const char rcsid
[]="$Id: authcustom.c,v 1.7 2008/07/10 02:43:55 mrsam Exp $";
21 static int auth_custom_login(const char *service
, char *authdata
,
22 int (*callback_func
)(struct authinfo
*, void *),
25 const char *user
, *pass
;
27 if ((user
=strtok(authdata
, "\n")) == 0 ||
28 (pass
=strtok(0, "\n")) == 0)
34 return authcustomcommon(user
, pass
, callback_func
, callback_arg
);
37 #include "libhmac/hmac.h"
40 static int auth_custom_cram(const char *service
,
43 int (*callback_func
)(struct authinfo
*, void *),
46 struct cram_callback_info cci
;
48 if (auth_get_cram(authtype
, authdata
, &cci
))
51 cci
.callback_func
=callback_func
;
52 cci
.callback_arg
=callback_arg
;
54 return authcustomcommon(cci
.user
, 0, &auth_cram_callback
, &cci
);
57 int auth_custom(const char *service
, const char *authtype
, char *authdata
,
58 int (*callback_func
)(struct authinfo
*, void *),
61 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
62 return (auth_custom_login(service
, authdata
,
63 callback_func
, callback_arg
));
65 return (auth_custom_cram(service
, authtype
, authdata
,
66 callback_func
, callback_arg
));
70 extern int auth_custom_pre(const char *userid
, const char *service
,
71 int (*callback
)(struct authinfo
*, void *),
74 static int auth_custom_chgpwd(const char *service
,
80 ** Insert code to change the account's password here.
82 ** return 0 if changed.
84 ** return 1 if failed.
85 ** Set errno to EPERM if we had a temporary failure (such as invalid
88 ** Set errno to EINVAL if we failed because we did not recognize uid.
95 static void auth_custom_idle()
98 ** Insert code to temporarily deallocate resources after remaining
99 ** idle (as part of authdaemond) for more than 5 minutes.
103 static struct authstaticinfo authcustom_info
={
112 struct authstaticinfo
*courier_authcustom_init()
114 return &authcustom_info
;