{
#define OPEP "devsql.c:sql_getuser,"
-#define SELUSR "%s %s WHERE username=%s"
+#define SELUSR "%s %s WHERE email='%s'"
USRTYP *usr;
SQLTYP *sql;
break;
case 2 : //check email structure
for (int i=0,l=strlen(email);i<l;i++) {
- char car;
+ register char car;
car=email[i];
- if (isalnum((int)car)!=0)
- continue;
- if (car=='@')
- continue;
+ switch (car) {
+ case '@' :
+ case '.' :
+ continue;
+ break;
+ default :
+ if (isalnum((int)car)!=0)
+ continue;
+ break;
+ }
(void) rou_alert(0,"%s Email <%s> not accepted, '%c' not an email char",
OPEP,email,car);
phase=999;
+ break;
}
break;
case 3 : //getting user information
- if ((rs=gettupple(sql,SELUSR,SELFROM,EMAILS,email))!=(SQLRES *)0) {
+ if ((rs=gettupple(sql,SELUSR,SELFROM,EMAILS,email))==(SQLRES *)0) {
(void) rou_alert(0,"%s Unable to get data for user <%s> (Database?)",
OPEP,email);
phase=999; //Trouble trouble
}
break;
case 4 : //getting user information
- if (nbrtupple(sql,rs)>0) {
+ int nbr;
+
+ if ((nbr=nbrtupple(sql,rs))>0) {
+ (void) rou_alert(0,"%s jmpdbg NBR='%d'",OPEP,nbr);
}
rs=dropresult(rs);
break;
/* checking if local recipient is acceptable. */
/* */
/********************************************************/
-static _Bool is_user_good(CONTYP *contact,RCPTYP *user)
+static _Bool is_user_good(CONTYP *contact,char *rcptto)
{
_Bool isok;
+USRTYP *usr;
int phase;
_Bool proceed;
-isok=true;
+isok=false;
+usr=(USRTYP *)0;
phase=0;
proceed=true;
while (proceed==true) {
switch (phase) {
case 0 : //is user a local user
- if (user->code!='L')
- phase=999; //User is Not local
+ if ((usr=sql_getusr(contact->sqlptr,rcptto))==(USRTYP *)0) {
+ (void) transmit(contact,true,"%d 5.6.5 <%s> unknown user",UKNUSER,rcptto);
+ phase=999; //No user found in database
+ }
break;
- case 1 : //is user existing within database
+ case 1 : //user is existing
+ isok=true;
break;
default : //SAFE Guard
+ usr=sql_freeusr(usr);
proceed=false;
break;
}
phase=999; //no need to go further
}
break;
- case 5 : //if the user is acceptable
- if (is_user_good(contact,neu)==false) {
+ case 5 : //if the local user acceptable
+ if ((neu->code=='L')&&(is_user_good(contact,rcptto)==false)) {
neu=eml_freerecipient(neu);
phase=999;
}
#procedure to dele or craate a postgresql test database
newtest : dbpostg dbmysql
- @ echo NEWTEST?
deltest : ndbpostg ndbmysql
#endif
//adding a list of local email
-INSERT INTO emails (email) values ('postmaster@localdomain');
-INSERT INTO emails (email) values ('webmaster@localdomain');
+INSERT INTO emails (email) values ('postmaster@example.com');
+INSERT INTO emails (email) values ('webmaster@example.com');