Author Topic: Batch Whitelisting [SOLVED]  (Read 323 times)

metafarion

  • Zen Apprentice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Batch Whitelisting [SOLVED]
« on: August 21, 2019, 01:23:32 am »
Does anyone know how to import a bunch of whitelisted addresses and domains in a plain text file dumped from another mail filter?  I see the Sender Policy is reflected in /etc/amavis/conf.d/zentyal-01 and /etc/spamassassin/local.cf, but both of those files get overwritten by changes in the web GUI.
« Last Edit: September 04, 2019, 05:10:05 pm by metafarion »

tranthithanhmo

  • Zen Apprentice
  • *
  • Posts: 2
  • Karma: +0/-0
  • Computer
    • View Profile
    • Tùng Phát Computer
Re: Batch Whitelisting
« Reply #1 on: August 22, 2019, 12:16:32 pm »
I have a similar situation. hope someone helps answer this question
Tùng Phát Computer
>> My Homepage : https://tungphatcomputer.com/

doncamilo

  • Zen Warrior
  • ***
  • Posts: 168
  • Karma: +31/-0
    • View Profile
Re: Batch Whitelisting
« Reply #2 on: August 22, 2019, 02:42:56 pm »
 :)

Read this: https://doc.zentyal.org/en/appendix-c.html#stubs

When you need customize services on Zentyal you have to work on the templates (stubs) that Zentyal uses in order to generate these services configuration files since Zentyal re-generates them each time restarts them.

The template type which Zentyal uses is "mason" perl templates. You can learn about it here https://masonbook.houseabsolute.com

Cheers!

metafarion

  • Zen Apprentice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Batch Whitelisting
« Reply #3 on: August 28, 2019, 05:54:36 pm »
I am familiar with using stubs to affect the generation of config files.  And I suppose I could put my whitelisted addresses into a stub to be written into /etc/spamassassin/local.cf, but they would be invisible and therefore uneditable by the web GUI.

doncamilo

  • Zen Warrior
  • ***
  • Posts: 168
  • Karma: +31/-0
    • View Profile
Re: Batch Whitelisting
« Reply #4 on: September 03, 2019, 05:44:14 pm »
 :)

Use this command:

Code: [Select]
sudo /usr/share/zentyal/redisvi

It opens the redis database in "vim". Looks into for this:

Code: [Select]
mailfilter/conf/AntispamACL/keys/ants1: {
   "sender" : "@lab6.lan",
   "policy" : "whitelist"
}

mailfilter/conf/AntispamACL/keys/ants2: {
   "sender" : "@test.lan",
   "policy" : "blacklist"
}

mailfilter/conf/AntispamACL/keys/ants3: {
   "sender" : "@gmail",
   "policy" : "whitelist"
}

mailfilter/conf/AntispamACL/keys/ants4: {
   "policy" : "whitelist",
   "sender" : "@viejoslibros.es"
}

mailfilter/conf/AntispamACL/keys/ants5: {
   "sender" : "@amano.es",
   "policy" : "whitelist"
}

mailfilter/conf/AntispamACL/max_id: 5

mailfilter/conf/AntispamACL/order: [
   "ants1",
   "ants2",
   "ants3",
   "ants4",
   "ants5"
]

This is an example on my machine. I have created by hand this:

Code: [Select]
##-> manual
mailfilter/conf/AntispamACL/keys/ants5: {
   "sender" : "@amano.es",
   "policy" : "whitelist"
}

mailfilter/conf/AntispamACL/max_id: 5 # add 1 to the previous max_id

mailfilter/conf/AntispamACL/order: [
   "ants1",
   "ants2",
   "ants3",
   "ants4",
   "ants5" # add manually the new record
]

You have to create the structure

mailfilter/conf/AntispamACL/keys/ants5: {
   "sender" : "@amano.es",
   "policy" : "whitelist"
}

for each one of the domains (use a script) . Afterwards paste it on redisvi and modify "mailfilter/conf/AntispamACL/max_id:" and add to this structure the new "ants" structures

mailfilter/conf/AntispamACL/order: [
   "ants1",
   "ants2",
   "ants3",
   "ants4",
   "ants5" # add manually the new record
]

Restart mail filter and your webadmin will reflect the changes. Be careful and respect the formats, etc. It could be dangerous (backup your redis database before)

Cheers!

metafarion

  • Zen Apprentice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Batch Whitelisting
« Reply #5 on: September 04, 2019, 05:09:17 pm »
Thanks!  That worked nicely with a little text processing to put the existing list in the right format.

redisvi is a really handy tool to have available!