2 ** Copyright 1998 - 2004 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.6 2005/03/20 19:10:30 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
);
39 #include "libhmac/hmac.h"
42 static int auth_custom_cram(const char *service
,
45 int (*callback_func
)(struct authinfo
*, void *),
48 struct cram_callback_info cci
;
50 if (auth_get_cram(authtype
, authdata
, &cci
))
53 cci
.callback_func
=callback_func
;
54 cci
.callback_arg
=callback_arg
;
56 return authcustomcommon(cci
.user
, 0, &auth_cram_callback
, &cci
);
60 int auth_custom(const char *service
, const char *authtype
, char *authdata
,
61 int (*callback_func
)(struct authinfo
*, void *),
64 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
65 return (auth_custom_login(service
, authdata
,
66 callback_func
, callback_arg
));
69 return (auth_custom_cram(service
, authtype
, authdata
,
70 callback_func
, callback_arg
));
77 extern int auth_custom_pre(const char *userid
, const char *service
,
78 int (*callback
)(struct authinfo
*, void *),
81 static int auth_custom_chgpwd(const char *service
,
87 ** Insert code to change the account's password here.
89 ** return 0 if changed.
91 ** return 1 if failed.
92 ** Set errno to EPERM if we had a temporary failure (such as invalid
95 ** Set errno to EINVAL if we failed because we did not recognize uid.
102 static void auth_custom_idle()
105 ** Insert code to temporarily deallocate resources after remaining
106 ** idle (as part of authdaemond) for more than 5 minutes.
110 static struct authstaticinfo authcustom_info
={
119 struct authstaticinfo
*courier_authcustom_init()
121 return &authcustom_info
;