From: Jean-Marc Pigeon Date: Thu, 11 Sep 2025 17:06:43 +0000 (-0400) Subject: hfrom information is properly inserted within data-base X-Git-Tag: tag-0.17~74 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=7e2d5caccdfad978677b66724b7267ea48969e79;p=jmp%2Fmailleur hfrom information is properly inserted within data-base --- diff --git a/lib/geseml.c b/lib/geseml.c index 36f0c49..b7aef4e 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -194,14 +194,14 @@ if (tra!=(TRATYP *)0) { status=true; (void) strftime(temps,sizeof(temps),"#%Y-%m-%d %H:%M:%S", localtime(&(tra->date))); - (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u%*s %*s %*s %*s", + (void) snprintf(line,sizeof(line),"%c\t%lu\t%05u%*s %*s %*s \"%*s\"", tra->code, tra->date, tra->delay, 32,tra->sessid, 30,tra->rcptto, 30,tra->sfrom, - 30,tra->efrom + 30,tra->hfrom ); (void) print_tra(qfile,line,temps); if (tra->resp!=(char **)0) { @@ -302,7 +302,7 @@ if (tra!=(TRATYP *)0) { dup->date=tra->date; dup->delay=tra->delay; dup->sfrom=strdup(tra->sfrom); - dup->efrom=strdup(tra->efrom); + dup->hfrom=strdup(tra->hfrom); dup->rcptto=strdup(tra->rcptto); dup->sessid=strdup(tra->sessid); if (tra->resp!=(char **)0) { @@ -330,7 +330,7 @@ PUBLIC TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile) { #define OPEP "geseml.c:eml_scanqfile," -#define FMT "%c %ld %d %s %s %s %s" +#define FMT "%c %ld %d %s %s %s \"%[^\"]\"" TRATYP *cur; //previous trans record char *ptr; @@ -340,7 +340,7 @@ cur=(TRATYP *)0; while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) { char id[300]; char sfrom[100]; - char efrom[100]; + char hfrom[100]; char to[100]; char code; u_long date; @@ -370,7 +370,8 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) { case 'L' : case 'R' : case 'W' : - if (sscanf(line,FMT,&code,&date,&delay,id,to,sfrom,efrom)!=7) { + (void) memset(hfrom,'\000',sizeof(hfrom)); + if (sscanf(line,FMT,&code,&date,&delay,id,to,sfrom,hfrom)!=7) { (void) rou_alert(0,"%s Unable to scan (config?)",OPEP,line); phase=999; //No data within line } @@ -382,16 +383,21 @@ while ((ptr=fgets(line,sizeof(line),qfile))!=(char *)0) { break; } break; - case 2 : //scanning line contents + case 2 : //cleaning element + while ((ptr=strchr(hfrom,'\"'))!=(char *)0) + *ptr=' '; + break; + case 3 : //storing line contents if (strlen(id)>0) { //always? cur=(TRATYP *)calloc(1,sizeof(TRATYP)); cur->code=code; cur->date=date; cur->delay=delay; cur->sessid=strdup(id); - cur->sfrom=strdup(sfrom); - cur->efrom=strdup(efrom); cur->rcptto=strdup(to); + cur->sfrom=strdup(sfrom); + cur->hfrom=strdup(hfrom); + (void) rou_alert(0,"%s hfrom=<%s>",OPEP,cur->hfrom); list=(TRATYP **)rou_addlist((void **)list,(void *)cur); } break; @@ -922,6 +928,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); for (int i=0;(extracted==false)&&(look[i]!=(char *)0);i++) { int max; diff --git a/lib/gessql.c b/lib/gessql.c index 173be49..40f0735 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -55,7 +55,7 @@ if (act!=(ACTTYP *)0) { char strcode[10]; char *gid; char *gsfrom; //SMTP "mail from:" - char *gefrom; //email Header "From:" + char *ghfrom; //email Header "From:" char *grcpt; char *gcode; @@ -63,7 +63,7 @@ if (act!=(ACTTYP *)0) { strcode[0]=act->code; gid=sql_gooddata(sqlptr,act->sessid); gsfrom=sql_gooddata(sqlptr,act->sfrom); - gefrom=sql_gooddata(sqlptr,act->efrom); + ghfrom=sql_gooddata(sqlptr,act->hfrom); grcpt=sql_gooddata(sqlptr,act->rcptto); gcode=sql_gooddata(sqlptr,strcode); if (act->resp!=(char **)0) { @@ -83,7 +83,7 @@ if (act!=(ACTTYP *)0) { ginfo=sql_gooddata(sqlptr,*resp); (void) sql_request(sqlptr,ins,field, gcode,gid, - gsfrom,gefrom, + gsfrom,ghfrom, grcpt,num,ginfo); ginfo=rou_freestr(ginfo); resp++; @@ -93,7 +93,7 @@ if (act!=(ACTTYP *)0) { } gcode=rou_freestr(gcode); grcpt=rou_freestr(grcpt); - gefrom=rou_freestr(gefrom); + ghfrom=rou_freestr(ghfrom); gsfrom=rou_freestr(gsfrom); gid=rou_freestr(gid); isok=true; @@ -142,7 +142,7 @@ if (tralist!=(TRATYP **)0) { action.sessid=(*tralist)->sessid; action.code=(*tralist)->code; action.sfrom=(*tralist)->sfrom; - action.efrom=(*tralist)->efrom; + action.hfrom=(*tralist)->hfrom; action.rcptto=(*tralist)->rcptto; action.resp=(*tralist)->resp; (void) mngact(sqlptr,&action); diff --git a/lib/lvleml.c b/lib/lvleml.c index 03cc718..bcc5776 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -1285,7 +1285,7 @@ inheader=true; completed=false; total=0; phase=0; -proceed=setdirectives(contact,EXTMP); +proceed=true; while (proceed==true) { //(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase); switch (phase) { @@ -1350,6 +1350,7 @@ while (proceed==true) { break; case 7 : //renameing directive contact->session->taille=total; + (void) setdirectives(contact,EXTMP); if (eml_renameqfile(contact->session->sessid,EXTMP,EXTRANS)==false) phase=999; //Trouble trouble break; @@ -2835,7 +2836,6 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) { TRATYP *tra; char data[300]; - (void) snprintf(data,sizeof(data),"%s@%s",(*ptr)->userid,(*ptr)->domain); tra=(TRATYP *)calloc(1,sizeof(TRATYP)); tra->code=(*ptr)->code; @@ -2843,9 +2843,11 @@ if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) { tra->delay=0; tra->sessid=strdup(contact->session->sessid); tra->sfrom=strdup(contact->mailfrom); - tra->sfrom=strdup(contact->mailfrom); - tra->efrom=strdup("XXX"); tra->rcptto=strdup(data); + (void) strcpy(data,"hfrom missing"); + if (contact->session->hfrom!=(char *)0) + (void) strcpy(data,contact->session->hfrom); + tra->hfrom=strdup(data); tralist=(TRATYP **)rou_addlist((void **)tralist,(void *)tra); ptr++; } diff --git a/lib/unieml.c b/lib/unieml.c index d713bd6..bc5ec08 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -98,7 +98,7 @@ if (tra!=(TRATYP *)0) { (void) eml_freetra_resp(tra); tra->rcptto=rou_freestr(tra->rcptto); tra->sfrom=rou_freestr(tra->sfrom); - tra->efrom=rou_freestr(tra->efrom); + tra->hfrom=rou_freestr(tra->hfrom); tra->rcptto=rou_freestr(tra->rcptto); tra->sessid=rou_freestr(tra->sessid); (void) free(tra); diff --git a/lib/unieml.h b/lib/unieml.h index 4e61fed..ea2b37b 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -100,7 +100,7 @@ typedef struct { u_int delay; //Transaction execution delay char *sessid; //session id char *sfrom; //Email SMTP Originator - char *efrom; //Email HEADER originator + char *hfrom; //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 59994b5..20bf8f4 100644 --- a/lib/unisql.h +++ b/lib/unisql.h @@ -53,7 +53,7 @@ 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 *hfrom; //the "From:" within the email header char *rcptto; //email recipient char **resp; //Multiline status }ACTTYP;