]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Able to store sfrom within database actions table
authorJean-Marc Pigeon <jmp@safe.c>
Thu, 11 Sep 2025 11:14:04 +0000 (07:14 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Thu, 11 Sep 2025 11:14:04 +0000 (07:14 -0400)
Makefile.dbg
lib/geseml.c
lib/gessql.c
lib/lvleml.c
lib/unieml.c
lib/unieml.h
lib/unisql.h

index d1842d439f7af385b0b1fd769cc981bb9ee59ad7..557c527ad412965cc5f877f0a687663848705f95 100644 (file)
@@ -108,7 +108,7 @@ onesortr:  debug
 restart        :  killall dosortr dorcvr doscarmt dosendr
           @ echo "Restart completed"
 
-actions        :  debug newtest restart
+actions        :  killall debug newtest restart
 
 dosortr :  
           @  echo "Starting Sorter"
index 82d1b473deed095ce87dd328fde380fd3a7a6a36..23da02b43b2d92e14e5f04572d948e7669365be2 100644 (file)
@@ -199,7 +199,7 @@ if (tra!=(TRATYP *)0) {
                                     tra->date,
                                     tra->delay,
                                     tra->sessid,
-                                    tra->mailfrom,
+                                    tra->sfrom,
                                     tra->rcptto
                                     );
   (void) print_tra(qfile,line,temps);
@@ -296,8 +296,8 @@ if (tra!=(TRATYP *)0) {
   dup->code=tra->code;
   dup->date=tra->date;
   dup->delay=tra->delay;
+  dup->sfrom=strdup(tra->sfrom);
   dup->rcptto=strdup(tra->rcptto);
-  dup->mailfrom=strdup(tra->mailfrom);
   dup->sessid=strdup(tra->sessid);
   if (tra->resp!=(char **)0) {
     char **ptr;
@@ -333,7 +333,7 @@ char line[300];
 cur=(TRATYP *)0;
 while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
   char id[300];
-  char from[100];
+  char sfrom[100];
   char to[100];
   char code;
   u_long date;
@@ -363,7 +363,7 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
           case 'L'      :       
           case 'R'      :       
           case 'W'      :       
-            if (sscanf(line,FMT,&code,&date,&delay,id,from,to)!=6) {
+            if (sscanf(line,FMT,&code,&date,&delay,id,sfrom,to)!=6) {
               (void) rou_alert(0,"%s Unable to scan <line=%s> (config?)",OPEP,line);
               phase=999;    //No data within line
               }
@@ -382,7 +382,7 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) {
           cur->date=date;
           cur->delay=delay;
           cur->sessid=strdup(id);
-          cur->mailfrom=strdup(from);
+          cur->sfrom=strdup(sfrom);
           cur->rcptto=strdup(to);
           list=(TRATYP **)rou_addlist((void **)list,(void *)cur); 
           }
@@ -805,7 +805,7 @@ while (proceed==true) {
       break;
     case 1      :       //Preparing attachement email
       (void) fprintf(qout,"%s%s Email daemon <%s>\n",HFROM,APPNAME,orig);
-      (void) fprintf(qout,"To: <%s>\n",tra->mailfrom);
+      (void) fprintf(qout,"To: <%s>\n",tra->sfrom);
       (void) fprintf(qout,"Date: %s\n",rou_ascsysstamp(time((time_t *)0)));
       (void) fprintf(qout,"%s%s\n",HTITLE,*(tra->resp)+4);
       break;
@@ -850,7 +850,7 @@ while (proceed==true) {
       char *domain;
       int status;
 
-      domain=strchr(tra->mailfrom,'@');
+      domain=strchr(tra->sfrom,'@');
       status=dns_is_domain_local(domain,tls_get_bind_afn());
       switch (status) {
         case dns_local  :
@@ -876,8 +876,8 @@ while (proceed==true) {
       tra->sessid=rou_freestr(tra->sessid);
       tra->sessid=strdup(sessata);
       tra->rcptto=rou_freestr(tra->rcptto);
-      tra->rcptto=tra->mailfrom;
-      tra->mailfrom=strdup(orig);
+      tra->rcptto=tra->sfrom;
+      tra->sfrom=strdup(orig);
       done=true;
       break;
     case 8      :       //building the new sessid file
index 71835c39daae8e600efff8e134c2ed41e0c3057e..25796cfde0c1ef95f9077ef1e97d356a9a6698df 100644 (file)
@@ -46,27 +46,29 @@ static _Bool mngact(SQLPTR *sqlptr,ACTTYP *act)
 #define OPEP    "gessql.c:sql_mngact,"
 
 static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s";
-static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%d,%s)";
+static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%s,%d,%s)";
 
 _Bool isok;
 
 isok=false;
 if (act!=(ACTTYP *)0) {
   char strcode[10];
-  char *goodid;
-  char *goodrcpt;
-  char *goodcode;
+  char *gid;
+  char *gsfrom;         //SMTP "mail from:"
+  char *grcpt;
+  char *gcode;
 
   (void) memset(strcode,'\000',sizeof(strcode));
   strcode[0]=act->code;
-  goodid=sql_gooddata(sqlptr,act->sessid);
-  goodrcpt=sql_gooddata(sqlptr,act->rcptto);
-  goodcode=sql_gooddata(sqlptr,strcode);
+  gid=sql_gooddata(sqlptr,act->sessid);
+  gsfrom=sql_gooddata(sqlptr,act->sfrom);
+  grcpt=sql_gooddata(sqlptr,act->rcptto);
+  gcode=sql_gooddata(sqlptr,strcode);
   if (act->resp!=(char **)0) {
     char *field;
 
-    field="code,sessid,rcptto,numline,info";
-    (void) sql_request(sqlptr,del,goodid,goodrcpt);
+    field="code,sessid,smtpfrom,rcptto,numline,info";
+    (void) sql_request(sqlptr,del,gid,grcpt);
     if (act->resp!=(char **)0) {
       char **resp;
       int num;
@@ -74,19 +76,20 @@ if (act!=(ACTTYP *)0) {
       resp=act->resp;
       num=1;
       while (*resp!=(char *)0) {
-        char *goodinfo;
+        char *ginfo;
 
-        goodinfo=sql_gooddata(sqlptr,*resp);
-        (void) sql_request(sqlptr,ins,field,goodcode,goodid,goodrcpt,num,goodinfo);
-        goodinfo=rou_freestr(goodinfo);
+        ginfo=sql_gooddata(sqlptr,*resp);
+        (void) sql_request(sqlptr,ins,field,gcode,gid,gsfrom,grcpt,num,ginfo);
+        ginfo=rou_freestr(ginfo);
         resp++;
         num++;
         }
       }
     }
-  goodcode=rou_freestr(goodcode);
-  goodrcpt=rou_freestr(goodrcpt);
-  goodid=rou_freestr(goodid);
+  gcode=rou_freestr(gcode);
+  grcpt=rou_freestr(grcpt);
+  gsfrom=rou_freestr(gsfrom);
+  gid=rou_freestr(gid);
   isok=true;
   }
 return isok;
@@ -132,6 +135,7 @@ if (tralist!=(TRATYP **)0) {
 
       action.sessid=(*tralist)->sessid;
       action.code=(*tralist)->code;
+      action.sfrom=(*tralist)->sfrom;
       action.rcptto=(*tralist)->rcptto;
       action.resp=(*tralist)->resp;
       (void) mngact(sqlptr,&action); 
index 7838bd207b24528898f03d99ccabfe98958aef14..ff4f67fc3f8abe3bc283b77587dbb55b45629419 100644 (file)
@@ -2029,7 +2029,7 @@ int phase;
 int proceed;
 
 done=false;
-orgdomain=strrchr(tra->mailfrom,'@');
+orgdomain=strrchr(tra->sfrom,'@');
 dstdomain=strrchr(tra->rcptto,'@');
 mxs=(MXTYP **)0;
 rmt=(RMTTYP *)0;
@@ -2042,7 +2042,7 @@ while (proceed==true) {
         char cmt[100];
 
         (void) snprintf(cmt,sizeof(cmt),"from <%s> or rcpt <%s>, without domain",
-                                        tra->mailfrom,tra->rcptto);
+                                        tra->sfrom,tra->rcptto);
         (void) log_fprintlog(rmt->logptr,false,cmt);
         (void) rou_alert(0,"%s  %s (Bug!)",OPEP,cmt);
         phase=999;
@@ -2400,7 +2400,7 @@ while (proceed==true) {
     case 7      :  {    //sending originator
       int rspcode;
 
-      rspcode=simple_smtp_command(rmt,"MAIL FROM: <%s>",(*tosend)->mailfrom);
+      rspcode=simple_smtp_command(rmt,"MAIL FROM: <%s>",(*tosend)->sfrom);
       switch (rspcode) {
         case CMDOK      :       //originator accepted
           break;
@@ -2842,7 +2842,7 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
     tra->date=isnow;
     tra->delay=0;
     tra->sessid=strdup(contact->session->sessid);
-    tra->mailfrom=strdup(contact->mailfrom);
+    tra->sfrom=strdup(contact->mailfrom);
     tra->rcptto=strdup(data);
     tralist=(TRATYP **)rou_addlist((void **)tralist,(void *)tra);
     ptr++;
@@ -2891,7 +2891,7 @@ while (*tra!=(TRATYP *)0) {
                           (*tra)->date,
                           (*tra)->delay,
                           (*tra)->sessid,
-                          (*tra)->mailfrom,
+                          (*tra)->sfrom,
                           (*tra)->rcptto);
       break;
     }
@@ -2981,9 +2981,9 @@ PUBLIC void eml_rebounce_email(TRATYP *tra)
 char *tmp;
 
 (void) rou_alert(0,"JMPDG rebounce");
-tmp=tra->mailfrom;
-tra->mailfrom=tra->rcptto;
-tra->mailfrom=tmp;
+tmp=tra->sfrom;
+tra->sfrom=tra->rcptto;
+tra->sfrom=tmp;
 tra->code='L';
 }
 
index 2199fcb2747744708957392cb9c1d51939ed8200..d713bd60f651acfbfad4dcb981154da546012d6e 100644 (file)
@@ -97,7 +97,9 @@ PUBLIC TRATYP *eml_freetra(TRATYP *tra)
 if (tra!=(TRATYP *)0) {
   (void) eml_freetra_resp(tra);
   tra->rcptto=rou_freestr(tra->rcptto);
-  tra->mailfrom=rou_freestr(tra->mailfrom);
+  tra->sfrom=rou_freestr(tra->sfrom);
+  tra->efrom=rou_freestr(tra->efrom);
+  tra->rcptto=rou_freestr(tra->rcptto);
   tra->sessid=rou_freestr(tra->sessid);
   (void) free(tra);
   tra=(TRATYP *)0;
index 27337664cf98abe3f0317924782816d214eaa98c..4e61fed3afe23781d8000ec67ac183b9df605a0b 100644 (file)
@@ -99,7 +99,8 @@ typedef struct  {
         time_t date;    //Transaction date
         u_int delay;    //Transaction execution delay
         char *sessid;   //session id
-        char *mailfrom; //Email Originator
+        char *sfrom;    //Email SMTP Originator
+        char *efrom;    //Email HEADER originator
         char *rcptto;   //Email Recipient
         int sendcode;   //Email sending status;
         char **resp;    //Transfer response status
index fec9fb4ff57773adfa9fd44401f78748056ea1a7..59994b55a259bc44d224e3baf069c09c70d41761 100644 (file)
@@ -52,6 +52,8 @@ typedef struct  {
 typedef struct  {
         char *sessid;   //session id
         char code;      //Email status code
+        char *sfrom;    //the "MAIL FROM:" within the SMTP exchange
+        char *efrom;    //the "From:" within the email header
         char *rcptto;   //email recipient
         char **resp;    //Multiline status
         }ACTTYP;