From: Jean-Marc Pigeon Date: Mon, 22 Sep 2025 13:43:39 +0000 (-0400) Subject: Working to improve data-feed set X-Git-Tag: tag-0.17~59 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=c0f4eeefead998f4642f00de17cd3f987f6273e4;p=jmp%2Fmailleur Working to improve data-feed set --- diff --git a/data-feed/feed000.tst b/data-feed/feed000.tst index 817337f..5e1bf21 100644 --- a/data-feed/feed000.tst +++ b/data-feed/feed000.tst @@ -34,9 +34,9 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 postmaster@example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed001.tst b/data-feed/feed001.tst index 503b59e..50655e7 100644 --- a/data-feed/feed001.tst +++ b/data-feed/feed001.tst @@ -21,9 +21,9 @@ R:250 ENHANCEDSTATUSCODES S:MAIL FROM: SIZE=1024 R:250 2.1.3 postmaster@example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed002.tst b/data-feed/feed002.tst index ebbe7fb..361f350 100644 --- a/data-feed/feed002.tst +++ b/data-feed/feed002.tst @@ -7,13 +7,13 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 trouble@mailref1.example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed003.tst b/data-feed/feed003.tst index ed279b9..a15ee68 100644 --- a/data-feed/feed003.tst +++ b/data-feed/feed003.tst @@ -7,9 +7,11 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 trouble@mailref1.example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed +S:RCPT TO: +R:551 5.6.0 unknown user #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . @@ -35,9 +37,9 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 postmaster@mailref1.example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed004.tst b/data-feed/feed004.tst index 5ffb43b..71c82e3 100644 --- a/data-feed/feed004.tst +++ b/data-feed/feed004.tst @@ -7,7 +7,7 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 postmaster@example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed006.tst b/data-feed/feed006.tst index 26ea228..47bd2c8 100644 --- a/data-feed/feed006.tst +++ b/data-feed/feed006.tst @@ -20,7 +20,7 @@ R:235 5.7.5 Authentication successful S:MAIL FROM: R:250 2.1.3 trouble@mailref1.example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #-sending data C:DATA 354 3.5.0 End data with . D:Subject: (feed006) A email to a not existing user after authentication diff --git a/data-feed/feed007.tst b/data-feed/feed007.tst index 9e082e0..b907720 100644 --- a/data-feed/feed007.tst +++ b/data-feed/feed007.tst @@ -15,7 +15,7 @@ R:250 ENHANCEDSTATUSCODES S:MAIL FROM: R:250 2.1.3 trouble@mailref1.example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #-sending data C:DATA 354 3.5.0 End data with . D:Subject: (feed006) A email to a not existing user after authentication diff --git a/data-feed/feed008.tst b/data-feed/feed008.tst index e891b0f..18ea76b 100644 --- a/data-feed/feed008.tst +++ b/data-feed/feed008.tst @@ -15,11 +15,11 @@ R:250 ENHANCEDSTATUSCODES S:MAIL FROM: R:250 2.1.3 supertool@mxtoolboxsmtpdiag.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:555 2.7.0 No MX nor IP for for domain +R:555 2.8.0 No MX nor IP for for domain S:RCPT TO: -R:555 2.7.0 No relay accepted for domain +R:555 2.8.0 No relay accepted for domain #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed009.tst b/data-feed/feed009.tst index 24d8b70..66b5911 100644 --- a/data-feed/feed009.tst +++ b/data-feed/feed009.tst @@ -15,7 +15,7 @@ R:250 ENHANCEDSTATUSCODES S:MAIL FROM: SIZE=2958 R:250 2.1.3 nobody@gmail.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed10.tst b/data-feed/feed10.tst index 46f0fed..d4ab7a0 100644 --- a/data-feed/feed10.tst +++ b/data-feed/feed10.tst @@ -10,7 +10,7 @@ R:250 2.1.3 postmaster@example.com sender ok S:RCPT TO: R:563 5.6.4 No valid MX found for recipient domain name (domain=subdom0.example.com) S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:QUIT R:221 2.0.0 Bye, closing connection... #------------------------------------------------------------------------- diff --git a/data-feed/feed11.tst b/data-feed/feed11.tst index 20b8f4c..1f41d5a 100644 --- a/data-feed/feed11.tst +++ b/data-feed/feed11.tst @@ -23,9 +23,9 @@ R:250 2.1.3 trouble@mailref1.example.com sender ok S:RCPT TO: R:551 5.6.5 unknown user S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/data-feed/feed30.tst b/data-feed/feed30.tst index cf853ed..f3e8d32 100644 --- a/data-feed/feed30.tst +++ b/data-feed/feed30.tst @@ -9,9 +9,9 @@ R:250 mailleur.example.com, link (cleartext) ready,... S:MAIL FROM: R:250 2.1.3 postmaster@example.com sender ok S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed S:RCPT TO: -R:250 5.6.6 Address will be processed +R:250 5.6.7 Address will be processed #------------------------------------------------------------------------- #-sending data C:DATA 354 3.5.0 End data with . diff --git a/lib/lvleml.c b/lib/lvleml.c index 353abc4..cc12345 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -883,6 +883,51 @@ rmtpass=rou_freestr(rmtpass); return (contact->privilege==rel_authentic); #undef DISP +#undef OPEP +} +/* + +*/ +/************************************************/ +/* */ +/* Procedure to report rcpt problem and */ +/* store status within the database. */ +/* */ +/************************************************/ +static void note_rcpt(CONTYP *contact,char *rcpt,int smtpcode,char *fmt,...) + +{ +#define OPEP "lvleml.c:note_rcpt," + +va_list args; +char **resp; +char *report; +char *info; +ACTTYP action; + +va_start(args,fmt); +resp=(char **)0; +(void) rou_vasprintf(&report,fmt,args); +(void) rou_asprintf(&info,"%d %s",smtpcode,report); +resp=(char **)rou_addlist((void **)resp,(void *)info); +(void) memset(&action,'\000',sizeof(ACTTYP)); +action.sessid=contact->session->sessid; +action.code='X'; +action.reverse=contact->peername; +action.sfrom=contact->mailfrom; +if (contact->session->hfrom!=(char *)0) + action.hfrom=contact->session->hfrom; +if (contact->session->hsubject!=(char *)0) + action.hsubject=contact->session->hsubject; +action.rcptto=rcpt; +action.resp=resp; +if (sql_mngact(contact->sqlptr,&action)==false) + (void) rou_alert(0,"%s unable to store report within database (bug?",OPEP); +(void) eml_transmit(contact,true,"%s",info); +resp=(char **)rou_freelist((void **)resp,(genfree_t)rou_freestr); +report=rou_freestr(report); +va_end(args); + #undef OPEP } /* @@ -909,15 +954,13 @@ while (proceed==true) { switch (phase) { case 0 : //is user a local user if ((sql_mngusr(contact->sqlptr,sql_select,rcptto,&usr))==false) { - (void) eml_transmit(contact,true,"%d 5.6.5 <%s> unknown user", - UKNUSER,rcptto); + (void) note_rcpt(contact,rcptto,UKNUSER,"5.6.0 <%s> unknown user",rcptto); phase=999; //No user found in database } break; case 1 : //is user lock? if (usr->lock==1) { - (void) eml_transmit(contact,true,"%d 5.6.6 <%s> account lock", - EXPIRED,rcptto); + (void) note_rcpt(contact,rcptto,EXPIRED,"5.6.1 <%s> account lock",rcptto); phase=999; //No user found in database } break; @@ -1003,7 +1046,7 @@ while (proceed==true) { default : //SAFE Guard if (remotegood==false) { - (void) eml_transmit(contact,true,"%d 2.7.0 %s for domain <%s>", + (void) eml_transmit(contact,true,"%d 2.8.0 %s for domain <%s>", NORELAY,cmt,rmtusr->domain); } proceed=false; @@ -1235,54 +1278,6 @@ return status; */ /************************************************/ /* */ -/* Procedure to report rcpt problem and */ -/* store status within the database. */ -/* */ -/************************************************/ -static void note_rcpt(CONTYP *contact,char *rcpt,int smtpcode,char *fmt,...) - -{ -#define OPEP "lvleml.c:note_rcpt," - -va_list args; -char **resp; -char *report; -char *info; -ACTTYP action; - -va_start(args,fmt); -resp=(char **)0; -(void) rou_vasprintf(&report,fmt,args); -(void) rou_asprintf(&info,"%d %s",smtpcode,report); -(void) rou_alert(0,"JMPDBG info=<%s>",info); -resp=(char **)rou_addlist((void **)resp,(void *)info); -(void) memset(&action,'\000',sizeof(ACTTYP)); -action.sessid=contact->session->sessid; -action.code='X'; -action.reverse=contact->peername; -action.sfrom=contact->mailfrom; -action.hfrom="----"; -action.hsubject="----"; -if (contact->session->hfrom!=(char *)0) - action.hfrom=contact->session->hfrom; -if (contact->session->hsubject!=(char *)0) - action.hsubject=contact->session->hsubject; -action.rcptto=rcpt; -action.resp=resp; -if (sql_mngact(contact->sqlptr,&action)==false) - (void) rou_alert(0,"%s unable to store report within database (bug?",OPEP); -(void) eml_transmit(contact,true,"%s",info); -resp=(char **)rou_freelist((void **)resp,(genfree_t)rou_freestr); -report=rou_freestr(report); -va_end(args); - -#undef OPEP -} -/* - -*/ -/************************************************/ -/* */ /* Procedure to send a simple SMTP ccommand*/ /* (no need to have the response wording) */ /* */ @@ -1839,7 +1834,7 @@ while (proceed==true) { } break; case 7 : //everything ok - (void) note_rcpt(contact,rcptto,CMDOK,"5.6.6 %s <%s>",detail,rcptto); + (void) note_rcpt(contact,rcptto,CMDOK,"5.6.7 %s <%s>",detail,rcptto); success=true; break; default : //SAFE guard diff --git a/sql/Makefile b/sql/Makefile index 6e91402..ed1208f 100644 --- a/sql/Makefile +++ b/sql/Makefile @@ -36,8 +36,10 @@ dbmysql : mailleur.mysql CHARACTER SET utf8;"; \ ) | sudo mariadb -q @ cat mailleur.mysql | mariadb -q mailleur; - @ cpp -P -DMYSQL datatest.sql | mariadb -q mailleur; - @ cpp -P -DMYSQL popul.sql | mariadb -q mailleur; + @ cpp -P -DMYSQL \ + datatest.sql | mariadb -q mailleur; + cpp -P -traditional -DMYSQL \ + popul.sql | mariadb -q mailleur; @ echo "MYSQL database ready" @@ -58,8 +60,18 @@ dbpostg : mailleur.postg echo " ENCODING='UTF8';"; \ ) | psql -q -U postgres template1 @ cat mailleur.postg | psql -q mailleur; - @ cpp -P -DPOSTGRESQL datatest.sql | psql -q mailleur; - @ cpp -P -DPOSTGRESQL popul.sql | psql -q mailleur; + @ cpp -DPOSTGRESQL \ + -P \ + -traditional \ + datatest.sql | \ + sed -e"/^\/\//d" | \ + psql -q mailleur; + @ cpp -DPOSTGRESQL \ + -P \ + -traditional \ + popul.sql | \ + sed -e"/^\/\//d" | \ + psql -q mailleur; @ echo "POSGRESQL database ready" ndbpostg: diff --git a/sql/datatest.def b/sql/datatest.def index c2f751c..c09079f 100644 --- a/sql/datatest.def +++ b/sql/datatest.def @@ -1,6 +1,7 @@ -//------------------------------------------------------------------ + +//X------------------------------------------------------------------ //include file to ajuste result according database -//------------------------------------------------------------------ +//Y------------------------------------------------------------------ #ifdef POSTGRESQL #define ADDTIME(adding) 'adding' #define CONCAT(A,B) A||B diff --git a/sql/datatest.sql b/sql/datatest.sql index 4df35a7..6fc23a9 100644 --- a/sql/datatest.sql +++ b/sql/datatest.sql @@ -23,7 +23,7 @@ INSERT INTO emails (email,password) \ INSERT INTO emails (email,password) \ values ('user1@mailleur.example.com','user1'); -//Set for system iwith Postgresql database +//Set for system with Postgresql database INSERT INTO emails (email,password) \ values ('user1@posdb.example.com','user1'); INSERT INTO emails (email,password) \ @@ -47,7 +47,7 @@ INSERT INTO remotes (remoteip,credit,lastscan) \ INSERT INTO remotes (remoteip,credit,lastscan) \ values ('45.197.14.139',-5,now()); INSERT INTO remotes (remoteip,credit,lastscan) \ - values ('213.209.157.107',-5,now()); + values ('213.209.157.107',-5,now()+ADDTIME(200 day)); INSERT INTO remotes (remoteip,credit,lastscan) \ values ('122.175.193.134',-5,now()); INSERT INTO remotes (remoteip,credit,lastscan) \ diff --git a/www/lvlmai.php b/www/lvlmai.php index fdce6a0..4205f2b 100644 --- a/www/lvlmai.php +++ b/www/lvlmai.php @@ -47,21 +47,24 @@ foreach($actions as $action) { $date=$action['creation']; $reverse=$action['reverse']; $smtpfrom=$action['smtpfrom']; - $emailfrom=$action['emailfrom']; - $emailfrom=htmlspecialchars($emailfrom,ENT_QUOTES); $recipient=$action['rcptto']; + $emailfrom=htmlspecialchars($action['emailfrom'],ENT_QUOTES); $subject=$action['subject']; + if (($subject==NULL) || (strlen($subject)==0)) + $subject=$action['info']; + //generating the table contents $line=$line."\r\n"; $line=$line."$count $status\r\n"; $line=$line."$date\r\n"; $line=$line."$reverse\r\n"; $line=$line.""; - $line=$line."$emailfrom
"; - $line=$line."$smtpfrom"; + $line=$line."$smtpfrom
"; + $line=$line."$emailfrom"; $line=$line."\r\n"; $line=$line."$recipient\r\n"; $line=$line."$subject\r\n"; $line=$line.""; + //end of generation $count++; } sql_close($dbsql);