1 message in net.sourceforge.lists.courier-users[courier-users] authcustom - success ...
FromSent OnAttachments
Kevin WongFeb 15, 2002 5:17 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[courier-users] authcustom - success in authtest only when no password providedActions...
From:Kevin Wong (kevi@pingan.com)
Date:Feb 15, 2002 5:17:51 pm
List:net.sourceforge.lists.courier-users

Hi,

I'd try to write my own auth by modifying the do_auth_custom in preauthcustom.c. The authtest success only when no password provided, however, when password is correct, "AUTHFAILURE" came out.

My auth is simply map a login name to a system user name (using getpwnam() ).

Thanks a lot, Kevin.

Here is the code: static int do_auth_custom(const char *userid, struct authinfo *authinfo) {

#if HAVE_GETSPENT struct spwd *spw; #endif struct passwd *pw; char *uname;

if (strcmp(userid, "kevin.wong")==0) uname=strdup("kevin"); else uanme=strdup(userid);

if ((pw=getpwnam(uname)) == 0) { if (errno == ENOMEM) return (1); errno=EPERM; free(uname); return (-1); }

authinfo->sysusername=uname; authinfo->sysgroupid=pw->pw_gid; authinfo->homedir=pw->pw_dir; authinfo->address=uname; authinfo->fullname=pw->pw_gecos; authinfo->passwd=pw->pw_passwd;

#if HAVE_GETSPENT if ((spw=getspnam(uname)) != 0) authinfo->passwd=spw->sp_pwdp; #endif return (0); }

----------------------------- RESULT of authtest

==== not a auth user ==== [root@localhost authlib]# ./authtest -s imap -m authcustom abc Authentication FAILED! [root@localhost authlib]#