From: Jean-Marc Pigeon Date: Thu, 11 Sep 2025 11:14:04 +0000 (-0400) Subject: Able to store sfrom within database actions table X-Git-Tag: tag-0.17~76 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=f79c790ebd468792b58149c8896090c160a535bd;p=jmp%2Fmailleur Able to store sfrom within database actions table --- diff --git a/Makefile.dbg b/Makefile.dbg index d1842d4..557c527 100644 --- a/Makefile.dbg +++ b/Makefile.dbg @@ -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" diff --git a/lib/geseml.c b/lib/geseml.c index 82d1b47..23da02b 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -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 (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 diff --git a/lib/gessql.c b/lib/gessql.c index 71835c3..25796cf 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -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); diff --git a/lib/lvleml.c b/lib/lvleml.c index 7838bd2..ff4f67f 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -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'; } diff --git a/lib/unieml.c b/lib/unieml.c index 2199fcb..d713bd6 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -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; diff --git a/lib/unieml.h b/lib/unieml.h index 2733766..4e61fed 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -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 diff --git a/lib/unisql.h b/lib/unisql.h index fec9fb4..59994b5 100644 --- a/lib/unisql.h +++ b/lib/unisql.h @@ -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;