From 74b1dbce11c2703d1799fd6e2a1f090fa0f29a9c Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 25 Jun 2025 07:11:39 -0400 Subject: [PATCH] Able to find user within database --- lib/devsql.c | 26 ++++++++++++++++++-------- lib/lvleml.c | 20 +++++++++++++------- sql/Makefile | 1 - sql/datatest.sql | 4 ++-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/devsql.c b/lib/devsql.c index ddbbe4c..c3aeb72 100644 --- a/lib/devsql.c +++ b/lib/devsql.c @@ -343,7 +343,7 @@ PUBLIC USRTYP *sql_getusr(SQLPTR *sqlptr,char *email) { #define OPEP "devsql.c:sql_getuser," -#define SELUSR "%s %s WHERE username=%s" +#define SELUSR "%s %s WHERE email='%s'" USRTYP *usr; SQLTYP *sql; @@ -371,27 +371,37 @@ while (proceed==true) { break; case 2 : //check email structure for (int i=0,l=strlen(email);i 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; diff --git a/lib/lvleml.c b/lib/lvleml.c index 80a1e34..7de19f3 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -264,25 +264,31 @@ return status; /* 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; } @@ -815,8 +821,8 @@ while (proceed==true) { 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; } diff --git a/sql/Makefile b/sql/Makefile index 39bcfdf..3243dd2 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -55,7 +55,6 @@ ndbpostg: #procedure to dele or craate a postgresql test database newtest : dbpostg dbmysql - @ echo NEWTEST? deltest : ndbpostg ndbmysql diff --git a/sql/datatest.sql b/sql/datatest.sql index 7e22d5c..be869a5 100644 --- a/sql/datatest.sql +++ b/sql/datatest.sql @@ -13,5 +13,5 @@ #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'); -- 2.47.3