Zentyal Forum, Linux Small Business Server

Zentyal Server => Email and Groupware => Topic started by: metafarion on August 21, 2019, 01:23:32 am

Title: Batch Whitelisting [SOLVED]
Post by: metafarion 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.
Title: Re: Batch Whitelisting
Post by: tranthithanhmo on August 22, 2019, 12:16:32 pm
I have a similar situation. hope someone helps answer this question
Title: Re: Batch Whitelisting
Post by: doncamilo on August 22, 2019, 02:42:56 pm
 :)

Read this: https://doc.zentyal.org/en/appendix-c.html#stubs (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 (https://masonbook.houseabsolute.com)

Cheers!
Title: Re: Batch Whitelisting
Post by: metafarion 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.
Title: Re: Batch Whitelisting
Post by: doncamilo 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!
Title: Re: Batch Whitelisting
Post by: metafarion 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!