]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working on the SPF value detection
authorJean-Marc Pigeon <jmp@safe.c>
Sun, 16 Nov 2025 21:21:11 +0000 (16:21 -0500)
committerJean-Marc Pigeon <jmp@safe.c>
Sun, 16 Nov 2025 21:21:11 +0000 (16:21 -0500)
lib/geseml.c
lib/gesspf.c
lib/gesspf.h
lib/lvleml.c
lib/lvleml.h

index 648b156c4a64a59742660de02e71365679629153..8b091ddcb75f96b96fa7faf6cea6228e33c56fa9 100644 (file)
@@ -620,7 +620,7 @@ locdom=(char *)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
-  //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
+  (void) rou_dbglive(9,OPEP,"phase='%d'",phase);
   switch (phase) {
     case 0      :       //Extracting recipient email
       if ((tra!=(TRATYP *)0)&&(tra->rcptto!=(char *)0)&&(strlen(tra->rcptto)>0))
@@ -747,8 +747,7 @@ switch (fork()) {
       argv[6]=rootdir;
       argv[7]=buffer;
       }
-    (void) rou_alert(0,"%s JMPDBG starting sender=<%s> todo= <%s>",
-                        OPEP,execpath,buffer);
+    (void) rou_dbglive(2,OPEP,"Starting sender=<%s> todo= <%s>",execpath,buffer);
     if (execv(execpath,argv)<0) {
       (void) rou_alert(0,"%s Unable to exec process=<%s> (error=<%s> Bug?)",
                         OPEP,execpath,strerror(errno));
@@ -818,7 +817,7 @@ qout=(FILE *)0;
 phase=0;
 proceed=true;
 while (proceed==true) {
-  //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+  (void) rou_dbglive(9,OPEP,"phase='%d'",phase);
   switch (phase) {
     case 0      :       //create the new attachement file
       if ((qout=eml_createqfile(sessata,(char *)0))==(FILE *)0) {
@@ -938,7 +937,7 @@ const char *look[]={HFROM,HTITLE,(char *)0};
 
 extracted=false;
 if ((line!=(char *)0)&&(strlen(line)>0)) {
-  (void) rou_alert(0,"%s JMPDBG scan header <%s>",OPEP,line);
+  (void) rou_dbglive(0,OPEP,"scaning header <%s>",line);
   for (int i=0;(extracted==false)&&(look[i]!=(char *)0);i++) {
     int max;
 
index 2794b098aa658aeeddad75f5bddec3efcd70d3de..6a20a42ddf924f59459edfc950071c8a5feb71d7 100644 (file)
@@ -635,3 +635,37 @@ return spf;
 
 #undef  OPEP
 }
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to get the SPF domain/peerip status   */
+/*      return the SPF status.                          */
+/*                                                      */
+/********************************************************/
+PUBLIC SPFENU spf_getspf(char *domain,char *peerip)
+
+{
+#define OPEP    "gesspf.c:spf_getspf"
+
+SPFENU spf;
+AFNTYP **afns;
+
+spf=spf_unknown;
+afns=afn_getipnums(peerip);
+if (afns!=(AFNTYP **)0) {
+  int try;
+
+  try=0;
+  for (int i=0;afns[i]!=(AFNTYP *)0;i++) {
+    spf=spf_getstatus(&try,domain,afns[i]);
+    (void) rou_dbglive(9,OPEP,"SPF[%d] for [%s]=<%s>",
+                         i,afns[i]->strnumip,spf_spfASCII(spf));
+    }
+  afns=(AFNTYP **)rou_freelist((void **)afns,(genfree_t)afn_freeipnum);
+  }
+return spf;
+
+#undef  OPEP
+}
index dfd63fffe02ec36a4fe0128ddcf37ef168005ae2..5d5f89acd3d656df044f3a78ee019816c98d2ec3 100644 (file)
@@ -9,6 +9,7 @@
 #define GESSPF
 
 #include        "subafn.h"
+#include        "gesspf.h"
 
 typedef enum    {
        spf_pass,       //OK if condition apply
@@ -24,7 +25,10 @@ typedef enum    {
 //procedure to return spf status as an ASCII string
 extern const char *spf_spfASCII(SPFENU spf);
 
-//get the SPF status for a specific domain and a remote peer IP
+//get the SPF status for a specific domain and an IP
 extern SPFENU spf_getstatus(int *try,char *domain,AFNTYP *afnnum);
 
+//get the SPF status for a specific domain according remote peer ipnumer
+extern SPFENU spf_getspf(char *domain,char *peerip);
+
 #endif
index 1aaa8e2b1d3b4761db43ec686952c00bf1cd32df..b5e22e1281c4d574647879dd8f37ed3373d68e9d 100644 (file)
@@ -1715,6 +1715,7 @@ status=CMDOK;
 proceed=true;
 phase=0;
 while (proceed==true) {
+  (void) rou_dbglive(9,OPEP,"Phase='%d'",phase);
   switch (phase) {
     case 0      :       //do we have an originator
       if ((mailfrom==(char *)0)||(strlen(mailfrom)<3)) {
@@ -1770,7 +1771,9 @@ while (proceed==true) {
           break;
         }
       break;
-    case 5      :       //everything ok
+    case 5      :       //Checking if the SPF is good from the originator
+      break;
+    case 6      :       //everything ok
       contact->mailfrom=strdup(mailfrom);
       (void) eml_transmit(contact,true,"%d 2.1.3 %s sender ok",
                                         CMDOK,contact->mailfrom);
index 9e0f5f167dba3a397ee3bb93f5247a486c79bad8..45b83ffbaade46bbf89696d0083a039cf32121ac 100644 (file)
 #include        "devsoc.h"
 #include        "devsql.h"
 #include        "gestcp.h"
+#include        "gesspf.h"
 #include        "geseml.h"
 
 typedef struct  {
         SOCPTR *socptr;         //established contact socket context
         SQLPTR *sqlptr;         //established contact database access
         int delay;              //communication max delay
-        _Bool isgoodfqdn;       //Remoted presented a valid fqdn
+        _Bool isgoodfqdn;       //Remote presented a valid fqdn
         char *fqdn;             //fully qualified domain from peer
         int credit;             //Credits to be added or removed from contact
         RELTYP privilege;       //onnection privilege
@@ -36,6 +37,7 @@ typedef struct  {
         char *termend;          //contact ending condition
         SESTYP *session;        //SMTP current session information
         char *mailfrom;         //current mail from originator
+        SPFENU isgoodspf;       //remote mail spf status
         RCPTYP **recipients;    //List of email recipient
         LOGPTR *logptr;         //reference to session log
         char *transout;         //data to be flush out to remote