2 ** Copyright 1998 - 2005 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courierauthdebug.h"
15 extern int auth_generic(const char *service
,
18 int (*callback_func
)(struct authinfo
*, void *),
21 static int badstr(const char *p
)
25 if ((int)(unsigned char)*p
< ' ')
32 /* Create a new string consisting of:
34 ** - DEFDOMAIN if username does not contain any characters from DOMAINSEP
35 ** (or if DOMAINSEP not set, then if username does not contain
36 ** the first char of DEFDOMAIN)
37 ** - strings s1, s2, s3
40 char *strdupdefdomain(const char *userid
, const char *s1
, const char *s2
,
45 q
=getenv("DEFDOMAIN");
48 r
=getenv("DOMAINSEP");
49 if (r
? strpbrk(userid
, r
) : strchr(userid
, q
[0])) q
= "";
54 p
=malloc(strlen(userid
)+strlen(q
)+strlen(s1
)+strlen(s2
)+strlen(s3
)+1);
56 strcat(strcat(strcat(strcat(strcpy(p
, userid
), q
), s1
), s2
), s3
);
60 int auth_login(const char *service
,
63 int (*callback_func
)(struct authinfo
*, void *),
70 if (badstr(userid
) || badstr(passwd
))
76 courier_authdebug_login_init();
77 courier_authdebug_login( 1, "username=%s", userid
);
78 courier_authdebug_login( 2, "password=%s", passwd
);
80 p
= strdupdefdomain(userid
, "\n", passwd
, "\n");
84 rc
=auth_generic(service
, AUTHTYPE_LOGIN
, p
,