--- authlib/preauthvchkpw.c.orig Wed Mar 12 03:51:27 2003 +++ authlib/preauthvchkpw.c Sat Oct 25 04:11:17 2003 @@ -55,7 +55,7 @@ } notfound=EACCES; - parse_email(usercopy, User, Domain, 100); + parse_email_internal(usercopy, User, Domain, 100); vget_assign(Domain,NULL,0,&uid, &gid); vpw=vauth_getpw(User, Domain); if ( vpw!=NULL ) { @@ -108,4 +108,50 @@ auth.passwd=vpw->pw_passwd; return ((*callback)(&auth, arg)); +} + +int parse_email_internal(char *email, char *user, char *domain, int buff_size ) +{ + int i; + int n; + int len; + char *at = NULL; + + lowerit(email); + + len = strlen(ATCHARS); + for(i=0;i buff_size ) n = buff_size; + /* suck out the username */ + snprintf(user, n, "%s", email); + /* now suck out the domain name */ + snprintf(domain, buff_size, "%s", ++at); + } else { + /* No AT char found, so populate username, leave domain blank */ + snprintf(user, buff_size, "%s", email); + domain[0] = 0; + } + + /* check the username for any invalid chars */ + if ( is_username_valid( user ) != 0 ) { + fprintf(stderr, "user invalid %s\n", user); + return(-1); + } + + /* check the domain for any invalid chars */ + if ( is_domain_valid( domain ) != 0 ) { + fprintf(stderr, "domain invalid %s\n", domain); + return(-1); + } + + /* if we havent found a domain, try and set it to the the default domain */ + vset_default_domain(domain); + + return(0); }