2 ** Copyright 1998 - 2005 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courierauthdebug.h"
14 static const char rcsid
[]="$Id: authmoduser3.c,v 1.6 2005/07/02 15:40:28 mrsam Exp $";
16 extern int auth_generic(const char *service
,
19 int (*callback_func
)(struct authinfo
*, void *),
22 static int badstr(const char *p
)
26 if ((int)(unsigned char)*p
< ' ')
33 /* Create a new string consisting of:
35 ** - DEFDOMAIN if username does not contain any characters from DOMAINSEP
36 ** (or if DOMAINSEP not set, then if username does not contain
37 ** the first char of DEFDOMAIN)
38 ** - strings s1, s2, s3
41 char *strdupdefdomain(const char *userid
, const char *s1
, const char *s2
,
46 q
=getenv("DEFDOMAIN");
49 r
=getenv("DOMAINSEP");
50 if (r
? strpbrk(userid
, r
) : strchr(userid
, q
[0])) q
= "";
55 p
=malloc(strlen(userid
)+strlen(q
)+strlen(s1
)+strlen(s2
)+strlen(s3
)+1);
57 strcat(strcat(strcat(strcat(strcpy(p
, userid
), q
), s1
), s2
), s3
);
61 int auth_login(const char *service
,
64 int (*callback_func
)(struct authinfo
*, void *),
71 if (badstr(userid
) || badstr(passwd
))
77 courier_authdebug_login_init();
78 courier_authdebug_login( 1, "username=%s", userid
);
79 courier_authdebug_login( 2, "password=%s", passwd
);
81 p
= strdupdefdomain(userid
, "\n", passwd
, "\n");
85 rc
=auth_generic(service
, AUTHTYPE_LOGIN
, p
,