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
------------------------------
==== login name wiht no password ====
[root@localhost authlib]# ./authtest -s imap -m authcustom kevin.wong
Authenticated: module authcustom
Home directory: /home/kevin
UID/GID: 500/500
AUTHADDR=kevin
AUTHFULLNAME=Kevin Wong
[root@localhost authlib]#

==== System username with correct password ====
[root@localhost authlib]# ./authtest -s imap -m authcustom kevin
correctpasswd
Authenticated: module authcustom
Home directory: /home/kevin
UID/GID: 500/500
AUTHADDR=kevin
AUTHFULLNAME=Kevin Wong
[root@localhost authlib]#

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

==== login name with wrong password ====
[root@localhost authlib]# ./authtest -s imap -m authcustom kevin.wong
wrongpasswd
Authentication FAILED!
[root@localhost authlib]#

==== login name with correct password ====
[root@localhost authlib]# ./authtest -s imap  -m authcustom kevin.wong
correctpasswd
AUTHFAILURE
[root@localhost authlib]#

_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to