From: Jean-Marc Pigeon (Delson) Date: Tue, 20 May 2025 20:21:26 +0000 (-0400) Subject: Adjusting Makefile to have a more generic sender parameters X-Git-Tag: tag-0.8~91 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=5e47b571f4f4111f97508c8b73de9ba51b7a0618;p=jmp%2Fmailleur Adjusting Makefile to have a more generic sender parameters --- diff --git a/Makefile b/Makefile index 764a7bd..7109305 100644 --- a/Makefile +++ b/Makefile @@ -38,20 +38,29 @@ EXTPORT = 25 TESTITER= 4 #-------------------------------------------------------------------- #To test sorter -sorter : clean debug - @ bin/sorter \ +sorter : clean debug + @ bin/sorter \ + -f \ -d 2 \ -c ./conf/mailleur.conf.dvl \ -r $(TESTDIR) + @ cp -a \ + $(TESTDIR)/var/spool/$(APPNAME)/queue/* \ + ./data-queue/ + #-------------------------------------------------------------------- #To test sender sender : clean debug newtest - @ bin/$@ \ + @ cp -a \ + ./data-queue/* \ + $(TESTDIR)/var/spool/$(APPNAME)/queue + @ ./bin/$@ \ -d 2 \ -c ./conf/mailleur.conf.dvl \ -r $(TESTDIR) \ - example.com-1747698127-0000.todo + `basename -a data-queue/*.todo | \ + tr '\\n' ' ' ` dbgsend : clean debug @ gdb \ @@ -91,10 +100,16 @@ onefeed : debug # # -i 127.63.31.15 #direct test -tstfeed : debug +tstfeed : debug newtest + @ rm -fr ./data-queue/* + @ rm -fr $(TESTDIR)/var/spool/$(APPNAME)/queue/* @ bin/feeder \ -c ./conf/feeder.conf.dvl \ $(FEEDPAR) + @ cp -a \ + $(TESTDIR)/var/spool/$(APPNAME)/queue/* \ + ./data-queue + #using gdb dbgfeed : debug @@ -264,9 +279,6 @@ newtest : deltest @ cp -a \ bin \ $(TESTDIR)/$(SBINDIR) - @ cp -a \ - data-queue/* \ - $(TESTDIR)/var/spool/$(APPNAME)/queue deltest : @ rm -fr $(TESTDIR) diff --git a/app/sender.c b/app/sender.c index 663d901..a17dcd5 100644 --- a/app/sender.c +++ b/app/sender.c @@ -129,12 +129,15 @@ while (proceed==true) { } } break; - case 5 : //job completed + case 5 : //job completed renameing file if (eml_renameqfile(fname,EXDOING,EXDONE)==false) { (void) rou_alert(0,"%s Unable to rename file <%s.%s>",OPEP,fname,EXDONE); phase=999; //No need to go further } break; + case 6 : //job fully compltedt, good + status=true; + break; default : //SAFE Guard if (qfile!=(FILE *)0) (void) eml_closeqfile(qfile); @@ -202,6 +205,7 @@ while (proceed==true) { char *ptr; fname=params->argv[num]; + (void) rou_alert(0,"%s fname file <%s>",appname,fname); if ((hangup==true)||(reload==true)) break; if ((ptr=strrchr(fname,'.'))==(char *)0) { @@ -215,6 +219,7 @@ while (proceed==true) { SENDER,fname,ptr); break; } + (void) rou_alert(0,"%s scanning file <%s>",appname,fname); if (scantodo(fname)==false) break; num++; diff --git a/app/sorter.c b/app/sorter.c index 0a3f5f0..4ff820c 100644 --- a/app/sorter.c +++ b/app/sorter.c @@ -126,13 +126,19 @@ while (proceed==true) { (void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON); (void) closelog(); break; - case 2 : //Scanning all file - phase--; //Looping on same phase + case 2 : //check about signal if ((hangup==true)||(reload==true)) phase=999; //Process + break; + case 3 : //Scanning all file if (scantrans()==false) phase=999; - (void) sleep(5); + break; + case 4 : //one shot deal?? + if (foreground==false) { + (void) sleep(5); + phase=1; //restarting + } break; default : //end of task params=par_freeparams(params); diff --git a/dovecot/mailleur.passwd b/dovecot/mailleur.passwd new file mode 100644 index 0000000..5c65401 --- /dev/null +++ b/dovecot/mailleur.passwd @@ -0,0 +1 @@ +webmaster@example.com:{plain}BigreA3:::: diff --git a/lib/devlog.c b/lib/devlog.c index cb1c64f..dc03bad 100644 --- a/lib/devlog.c +++ b/lib/devlog.c @@ -4,6 +4,7 @@ /* Log management implementation module */ /* */ /********************************************************/ +#include #include #include #include @@ -88,13 +89,7 @@ while (proceed==true) { proceed=false; //trouble trouble } break; - case 1 : //locking access to event file - if (prc_locking(EVENT,true,5)==false) { - (void) rou_alert(0,"%s Unable to log event (Timing!?)",OPEP); - proceed=false; //trouble trouble - } - break; - case 2 : //duplicat logname + case 1 : //duplicat logname (void) strncpy(daily,logname,sizeof(daily)-strlen(daily)); if (strlen(daily)>0) { char *ptr; @@ -104,14 +99,14 @@ while (proceed==true) { } (void) rou_asprintf(&event,"%s/event-%s.jrl",daily,asctemps); break; - case 3 : //opening log file + case 2 : //opening log file if ((flog=fopen(logname,"r"))==(FILE *)0) { (void) rou_alert(0,"%s Unable to open log file <%s> (error=<%s>)", OPEP,logname,strerror(errno)); phase=999; //no need to go further } break; - case 4 : //opening log file + case 3 : //opening log file if ((fevent=fopen(event,"a+"))==(FILE *)0) { (void) rou_alert(0,"%s Unable to open event file <%s> (error=<%s>)", OPEP,event,strerror(errno)); @@ -119,6 +114,16 @@ while (proceed==true) { phase=999; //no need to go further } break; + case 4 : //locking access to logname + if (flock(fileno(fevent),LOCK_EX)<0) { + (void) rou_alert(0,"%s Unable to lock acces to log file <%s> " + "(error=<%s>) (Bug?)", + OPEP,event,strerror(errno)); + (void) fclose(fevent); + (void) fclose(flog); + phase=999; //no need to go further + } + break; case 5 : //merging file if (fevent!=(FILE *)0) { //always char ch; @@ -126,6 +131,7 @@ while (proceed==true) { while ((ch=fgetc(flog))!=EOF) fputc(ch,fevent); } + (void) flock(fileno(fevent),LOCK_UN); (void) fclose(fevent); (void) fclose(flog); break; @@ -136,7 +142,6 @@ while (proceed==true) { } break; default : //SAFE guard - (void) prc_locking(EVENT,false,1); event=rou_freestr(event); proceed=false; break; diff --git a/lib/geseml.c b/lib/geseml.c index c307fc5..6187669 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -355,8 +355,9 @@ while (proceed==true) { char *path; path=rou_apppath(getenv(DIRDOV)); - (void) snprintf(dirname,sizeof(dirname),"%s/%s/%s/",path,locdom,tra->rcptto); + (void) snprintf(dirname,sizeof(dirname),"%s/%s/%s",path,locdom,tra->rcptto); *(strrchr(dirname,'@'))='\000'; //keeping username only + (void) strncat(dirname,"/new",sizeof(dirname)-strlen(dirname)); if ((dir=opendir(dirname))==(DIR *)0) { int status; char cmd[400]; diff --git a/lib/unieml.c b/lib/unieml.c index 7d9fc56..845035e 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -5,6 +5,7 @@ /* exchange. */ /* */ /********************************************************/ +#include #include #include #include @@ -554,23 +555,35 @@ while (proceed==true) { } } break; - case 3 : //duplicating file + case 3 : //lock the fout file + if (flock(fileno(fout),LOCK_EX)<0) { + (void) rou_alert(0,"%s unable to lock destination file <%s> " + "(error=<%s> (Bug?))", + OPEP,qfilename,strerror(errno)); + (void) fclose(fout); + (void) fclose(fin); + phase=999; //Big trouble + } + break; + case 4 : //duplicating file if (fout!=(FILE *)0) { int count; char buffer[2048]; while ((count=fread(buffer,sizeof(char),sizeof(buffer),fin))>0) { if (fwrite(buffer,sizeof(char),count,fout)!=count) { - (void) rou_alert(0,"%s unable to fully write destination (error=<%s>)", - OPEP,strerror(errno)); + (void) rou_alert(0,"%s unable to fully write destination file " + "<%s> (error=<%s>)", + OPEP,qfilename,strerror(errno)); phase=999; } } + (void) flock(fileno(fout),LOCK_UN); (void) fclose(fout); (void) fclose(fin); } break; - case 4 : //duplication is a success + case 5 : //duplication is a success status=true; break; default : //SAFE Guard