]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to implement the relayable list
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 15 Jul 2025 22:47:43 +0000 (18:47 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 15 Jul 2025 22:48:25 +0000 (18:48 -0400)
conf/mailleur.conf
conf/mailleur.conf.dvl
conf/relayed.conf
lib/lvleml.c
lib/lvleml.h
lib/unieml.c
lib/unieml.h

index 73a179a4d98667b72959d47119d5df970b8bf365..f7471a415bb4f0e82ffe4ec1ff5dcca1acbc620d 100644 (file)
@@ -53,4 +53,6 @@ DOV_MAILDIR="/var/spool/mailleur/mails"
 #------------------------------------------------
 #The list of public blacklist serveur
 BLACKLISTER=/etc/mailleur/blacklister.conf
+#the list of IP from which we accept to releay email
+RELAYABLE=/etc/mailleur/relayable.conf
 #------------------------------------------------
index f834b3eada1df3098095eee2ad5c8b67e9293453..ee6d31275450f0662f78cc15588236b75157b82b 100644 (file)
@@ -57,4 +57,6 @@ SMTPPORTS="|127.127.10.25|1025|5,smtps|127.127.10.26|1465|3,smtp|127.127.10.26|1
 #------------------------------------------------
 #The list of public blacklist serveur
 BLACKLISTER=/etc/mailleur/blacklister.conf
+#the list of IP from which we accept to releay email
+RELAYABLE=/etc/mailleur/relayable.conf
 #------------------------------------------------
index 863788a7490e530fe4ebb4eb5788896da263e416..5c217dcf2c6f3723fea307db72ddb74ca1fb0aa9 100644 (file)
@@ -1,2 +1,6 @@
-#list of IP number which are relayable
-127.0.0.1/32
+#--------------------------------------------------------
+##Private address block which email can be relayed from
+127.0.0.0/8                    #local loop number
+192.168.254.0/24               #local network
+#--------------------------------------------------------
+#Setup you own list
index eeea4311991c202d2c4ff0fb7632d3c4fafcc387..f71b1077bcc3dc16976e3639e1d71c445e728a2b 100644 (file)
@@ -85,7 +85,6 @@ static CONTYP *freecontact(CONTYP *contact)
 
 if (contact!=(CONTYP *)0) {
   (void) freesessid(contact);
-  (void) sql_droplinks(contact->sqlptr);
   contact->sqlptr=sql_closesql(contact->sqlptr);
   contact->logptr=log_closelog(contact->logptr);
   contact->recipients=(RCPTYP **)rou_freelist((void **)contact->recipients,
@@ -2319,13 +2318,12 @@ while (proceed==true) {
       if (contact->sqlptr==(SQLPTR *)0) {
         (void) rou_alert(0,"%s Unable to contact database",OPEP);
         (void) sleep(2);//delay to avoid avalanche
-        (void) free(contact);
+        (void) eml_dropcontact(contact);
         contact=(CONTYP *)0;
         phase=999;      //no contact possible.
         }
       break;
     case 2      :       //waiting from contact
-      (void) sql_droplinks(contact->sqlptr);
       if ((contact->socptr=soc_accept(socptr,pos))==(SOCPTR *)0) {
         (void) rou_alert(3,"%s Unable to open contact",OPEP);
         contact=freecontact(contact);
index 7aec7b0f86ce751b46097dde0fddc2627ccff96a..8e685e79ab03116b40430cc08d358f0aaf456a4f 100644 (file)
@@ -28,6 +28,7 @@ typedef struct  {
         char *locserv;          //local service port
         char *peername;         //socket remote peer FQDN
         char *peerip;           //socket remote peer IP
+        char **relayok;         //List of IP which are relayable
         int numreset;           //number of SMTP reset received
         char *mainsesid;        //session main ID
         SESTYP *session;        //SMTP current session information
index f79f8497579d3df8fcdc7b3fb0febf3335195c02..935a0c86123b6245d3e1652c8ff7e8362f82ac89 100644 (file)
@@ -5,6 +5,7 @@
 /*     exchange.                                       */
 /*                                                     */
 /********************************************************/
+#include        <arpa/inet.h>
 #include        <sys/file.h>
 #include        <dirent.h>
 #include        <errno.h>
@@ -426,6 +427,80 @@ return qfile;
 */
 /********************************************************/
 /*                                                      */
+/*     Procedure to load a list of IP from which email */
+/*      to a NONE local domain can be accepted and      */
+/*      relayed.                                        */
+/*                                                      */
+/********************************************************/
+PUBLIC char **eml_load_relayed(char *relayedfile)
+
+{
+#define OPEP    "unieml.c:eml_load_relayed,"
+
+char **list;
+char *filename;
+FILE *relays;
+int phase;
+_Bool proceed;
+
+list=(char **)0;
+filename=(char *)0;
+relays=(FILE *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //Check if we have a ffilename
+      if ((relayedfile==(char *)0)||(strlen(relayedfile)==0)) {
+        (void) rou_alert(0,"%s No file name config?)",OPEP);
+        phase=999;      //*no need to go further
+        }
+      break;
+    case 1      :       //let open the relayable file
+      filename=rou_apppath(relayedfile);
+      if ((relays=fopen(filename,"r"))==(FILE *)0) {
+        (void) rou_alert(0,"%s Unable to open file <%s> (error=<%s>, config?)",
+                            OPEP,filename,strerror(errno));
+        phase=999;      //No need to go further
+        }
+      break;
+    case 2      :  {    //scanning relayable contents
+      char line[300];
+     
+      while (fgets(line,sizeof(line)-1,relays)!=(char *)0) {
+        struct sockaddr_in sa;
+
+        (void) rou_clean_conf_line(line);
+        if (strlen(line)==0)
+          continue;
+        if (inet_pton(AF_INET,line,&(sa.sin_addr))<=0) {
+          (void) rou_alert(0,"%s <%s> not a valie IP (error=<%s>, config?)",
+                            OPEP,line,strerror(errno));
+          continue;
+          }
+        list=(char **)rou_addlist((void **)list,strdup(line));
+        }
+      }
+      break;
+    case 3      :       //closing file
+      (void) fclose(relays);
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+filename=rou_freestr(filename);
+return list;
+
+#undef  OPEP
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
 /*     Procedure to list all file with a specific      */
 /*      extension with the queue directory.             */
 /*      Return a list or NULL if no file.               */
index 23c993c35b74749c5775eaf0003df38db5934544..2cfb0da73f8a602d8a3e260529d868ff04c63400 100644 (file)
@@ -131,6 +131,10 @@ extern FILE *eml_createqfile(char *qfilename,const char *ext);
 //procedure to close a file within the queue directory
 extern FILE *eml_closeqfile(FILE *qfile);
 
+//Procedure to load the list of IP/Network from
+//which incoming email can be relayed to another domain MX
+extern char **eml_load_relayed(char *relayedfile);
+
 //Procedure to list all file within queue directory
 //and with a specific extenstion
 extern char **eml_getqfilelist(char **dnames,const char *ext);