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 "courierauth.h"
18 #include "courierauthstaticlist.h"
19 #include "libhmac/hmac.h"
22 static int auth_custom_login(const char *service
, char *authdata
,
23 int (*callback_func
)(struct authinfo
*, void *),
26 const char *user
, *pass
;
28 if ((user
=strtok(authdata
, "\n")) == 0 ||
29 (pass
=strtok(0, "\n")) == 0)
35 return authcustomcommon(user
, pass
, callback_func
, callback_arg
);
38 static int auth_custom_cram(const char *service
,
41 int (*callback_func
)(struct authinfo
*, void *),
44 struct cram_callback_info cci
;
46 if (auth_get_cram(authtype
, authdata
, &cci
))
49 cci
.callback_func
=callback_func
;
50 cci
.callback_arg
=callback_arg
;
52 return authcustomcommon(cci
.user
, 0, &auth_cram_callback
, &cci
);
55 int auth_custom(const char *service
, const char *authtype
, char *authdata
,
56 int (*callback_func
)(struct authinfo
*, void *),
59 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
60 return (auth_custom_login(service
, authdata
,
61 callback_func
, callback_arg
));
63 return (auth_custom_cram(service
, authtype
, authdata
,
64 callback_func
, callback_arg
));
68 extern int auth_custom_pre(const char *userid
, const char *service
,
69 int (*callback
)(struct authinfo
*, void *),
72 static int auth_custom_chgpwd(const char *service
,
78 ** Insert code to change the account's password here.
80 ** return 0 if changed.
82 ** return 1 if failed.
83 ** Set errno to EPERM if we had a temporary failure (such as invalid
86 ** Set errno to EINVAL if we failed because we did not recognize uid.
93 static void auth_custom_idle()
96 ** Insert code to temporarily deallocate resources after remaining
97 ** idle (as part of authdaemond) for more than 5 minutes.
101 static struct authstaticinfo authcustom_info
={
110 struct authstaticinfo
*courier_authcustom_init()
112 return &authcustom_info
;