From b605c9b5e819acdb8dbbf0c5d4eadf4f2f8119d9 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 13 Jul 2025 09:21:06 -0400 Subject: [PATCH] Extracting the blacklister list is working fine --- Makefile | 4 ++++ app/scarmt.c | 44 +++++++++++++++++++++++++++++++++++++++++- conf/mailleur.conf | 4 +++- conf/mailleur.conf.dvl | 4 +++- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e1519b7..ddb31a7 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,7 @@ tstspf : clean debug newtest : deltest @ mkdir -p $(TESTDIR)/var/run @ mkdir -p $(TESTDIR)/$(SBINDIR) + @ mkdir -p $(TESTDIR)/etc/$(APPNAME) @ mkdir -p $(TESTDIR)/usr/share/$(APPNAME) @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/queue @ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/mails @@ -194,6 +195,9 @@ newtest : deltest @ cp -a \ bin/* \ $(TESTDIR)/$(SBINDIR) + @ cp -a \ + conf/* \ + $(TESTDIR)/etc/$(APPNAME) @ cp -a \ sql \ $(TESTDIR)/usr/share/$(APPNAME)/ diff --git a/app/scarmt.c b/app/scarmt.c index 5aa3ad5..f419d06 100644 --- a/app/scarmt.c +++ b/app/scarmt.c @@ -9,7 +9,9 @@ /* */ /********************************************************/ #include +#include #include +#include #include #include @@ -35,14 +37,16 @@ static char **load_dnsbls() { #define OPEP "scarmt.c:load_dnsbls," -const char *blcklist="XBLACKLIST"; +const char *blcklist="BLACKLISTER"; char **dnsbls; +FILE *blkfile; const char *filename; int phase; _Bool proceed; dnsbls=(char **)0; +blkfile=(FILE *)0; phase=0; proceed=true; while (proceed==true) { @@ -54,6 +58,44 @@ while (proceed==true) { phase=999; //no need to go further } break; + case 1 : //opening the file + if (filename!=(char *)0) { //always + char *fullpath; + + fullpath=rou_apppath(filename); + if ((blkfile=fopen(fullpath,"r"))==(FILE *)0) { + (void) rou_alert(0,"%s Unable to open file <%s> (error=<%s>)", + OPEP,fullpath,strerror(errno)); + phase=999; //trouble trouble + } + fullpath=rou_freestr(fullpath); + } + break; + case 2 : //scaning file + if (blkfile!=(FILE *)0) { //always + char line[200]; + + while (fgets(line,sizeof(line)-1,blkfile)!=(char *)0) { + char *ptr; + int taille; + + if ((ptr=strchr(line,'#'))!=(char *)0) + *ptr='\000'; + taille=strlen(line); + while (taille>0) { + taille--; + ptr=line+taille; + if ((*ptr!=' ')&&(*ptr!='\t')) + break; + *ptr='\000'; + } + if (strlen(line)>0) { + dnsbls=(char **)rou_addlist((void **)dnsbls,(void *)strdup(line)); + } + } + (void) fclose(blkfile); + } + break; default : //SAFE Guard proceed=false; break; diff --git a/conf/mailleur.conf b/conf/mailleur.conf index c5e6a33..73a179a 100644 --- a/conf/mailleur.conf +++ b/conf/mailleur.conf @@ -51,4 +51,6 @@ DB_LANG="UTF-8" #Dovecot storage directory DOV_MAILDIR="/var/spool/mailleur/mails" #------------------------------------------------ -BLACKLIST=/etc/mailleur/blacklister.conf +#The list of public blacklist serveur +BLACKLISTER=/etc/mailleur/blacklister.conf +#------------------------------------------------ diff --git a/conf/mailleur.conf.dvl b/conf/mailleur.conf.dvl index 8363d40..bdd0ffb 100644 --- a/conf/mailleur.conf.dvl +++ b/conf/mailleur.conf.dvl @@ -55,4 +55,6 @@ DOV_MAILDIR="/var/spool/mailleur/mails" #------------------------------------------------ SMTPPORTS="|127.127.10.25|1025|5,smtps|127.127.10.26|1465|3,smtp|127.127.10.26|1587|2" #------------------------------------------------ -BLACKLIST=/home/jmp/safe-mailleur/mailleur/conf/blacklister.conf +#The list of public blacklist serveur +BLACKLISTER=/etc/mailleur/blacklister.conf +#------------------------------------------------ -- 2.47.3