]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adjusting Makefile to have a more generic sender parameters
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 20 May 2025 20:21:26 +0000 (16:21 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 20 May 2025 20:21:26 +0000 (16:21 -0400)
Makefile
app/sender.c
app/sorter.c
dovecot/mailleur.passwd [new file with mode: 0644]
lib/devlog.c
lib/geseml.c
lib/unieml.c

index 764a7bdcb626ad4dabc10727215d3fa74af30449..7109305a1c11b97deb5a25b79d0db8d17f483648 100644 (file)
--- 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)
index 663d9010baee7332788704ee49934c0d2d57efda..a17dcd501331c65a165b1f46477c5e38a9228021 100644 (file)
@@ -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++;
index 0a3f5f09cddae59a9fc42adc2aac484728143234..4ff820cfaf07d7a84fa0c1df9c341f89a674d56c 100644 (file)
@@ -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 (file)
index 0000000..5c65401
--- /dev/null
@@ -0,0 +1 @@
+webmaster@example.com:{plain}BigreA3::::
index cb1c64f86fb81666954dacff19c86fa037b88e41..dc03bad1787327413c85a9ca35a548a4804dc14d 100644 (file)
@@ -4,6 +4,7 @@
 /*     Log management implementation module            */
 /*                                                     */
 /********************************************************/
+#include        <sys/file.h>
 #include        <errno.h>
 #include        <malloc.h>
 #include        <stdbool.h>
@@ -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;
index c307fc5d859bf84388c4ec03027ab73591ea7aea..6187669e4d5dec4466c562396d76ce78cd8f99af 100644 (file)
@@ -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];
index 7d9fc56ceb576f75ab85dd8e91f1bc8960c8a71a..845035e392021b93033e47f56a155d2c4a8a4318 100644 (file)
@@ -5,6 +5,7 @@
 /*     exchange.                                       */
 /*                                                     */
 /********************************************************/
+#include        <sys/file.h>
 #include        <dirent.h>
 #include        <errno.h>
 #include        <fcntl.h>
@@ -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