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 "courierauthstaticlist.h"
20 static int auth_custom_login(const char *service
, char *authdata
,
21 int (*callback_func
)(struct authinfo
*, void *),
24 const char *user
, *pass
;
26 if ((user
=strtok(authdata
, "\n")) == 0 ||
27 (pass
=strtok(0, "\n")) == 0)
33 return authcustomcommon(user
, pass
, callback_func
, callback_arg
);
36 #include "libhmac/hmac.h"
39 static int auth_custom_cram(const char *service
,
42 int (*callback_func
)(struct authinfo
*, void *),
45 struct cram_callback_info cci
;
47 if (auth_get_cram(authtype
, authdata
, &cci
))
50 cci
.callback_func
=callback_func
;
51 cci
.callback_arg
=callback_arg
;
53 return authcustomcommon(cci
.user
, 0, &auth_cram_callback
, &cci
);
56 int auth_custom(const char *service
, const char *authtype
, char *authdata
,
57 int (*callback_func
)(struct authinfo
*, void *),
60 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
61 return (auth_custom_login(service
, authdata
,
62 callback_func
, callback_arg
));
64 return (auth_custom_cram(service
, authtype
, authdata
,
65 callback_func
, callback_arg
));
69 extern int auth_custom_pre(const char *userid
, const char *service
,
70 int (*callback
)(struct authinfo
*, void *),
73 static int auth_custom_chgpwd(const char *service
,
79 ** Insert code to change the account's password here.
81 ** return 0 if changed.
83 ** return 1 if failed.
84 ** Set errno to EPERM if we had a temporary failure (such as invalid
87 ** Set errno to EINVAL if we failed because we did not recognize uid.
94 static void auth_custom_idle()
97 ** Insert code to temporarily deallocate resources after remaining
98 ** idle (as part of authdaemond) for more than 5 minutes.
102 static struct authstaticinfo authcustom_info
={
111 struct authstaticinfo
*courier_authcustom_init()
113 return &authcustom_info
;