create ACL in exim deny senders but exclude localdomains - exim

reading material on the internet, I found a way to block extensions (TLD) or e-mail accounts, it's an excellent option since I make the mail never get the antispam, so I save resources.
discard senders = /opt/exim/deny_senders
message = your are blacklisted
Into the file deny_senders contain this:
*.ru
*.online
*.bid
In to the file /opt/exim/localdomains are the local domains of the server.
One of the local domains ends with the extension "bla.online" is it possible to create a rule to exclude the local?

You need to ensure that you have the line in your exim's config like that:
acl_smtp_rcpt = acl_rcpt
That directive declare that you want to filter out the messages on the RCPT stage. Then you have to find the exact part of config defined the ACL for RCPT and add this two rules:
acl_rcpt:
. . . . .
accept condition = ${lookup{\$sender_address}nwildlsearch{/path/to/white.list}{yes}}
reject condition = ${lookup{\$sender_address}nwildlsearch{/path/to/black.list}{yes}}
message = Go mail yourself you unsolicited sender!
. . . . .
Those two conditions checks the sender address in the files containing regular expressions one per line like that:
## WHITE.LIST
^.*\.bla\.online
and
## BLACK.LIST
^.*\.ru
^.*\.online
^.*\.bid
Regular expressions should conform the PCRE syntax:
^ mean the beginning of line
.* mean any sequence of any symbols
\. mean the dot itself
You have to place the whitelist above the blacklist because the ACL terminates on the first match. So more specific white regexps should be tested first. Also this two rules should be placed before any other rules that can accept messages for delivery.

Related

Mule 4: SFTP List files that contain a variable

I have an SFTP directory that contains several files in this format
19328D_T001045863113302101909_20220721_103898.txt
1932A8_T001045863113302101909_20220721_103802.txt
The part starting with T i have saved as a dynamic variable vars.transaction (e.g. vars.transaction == "T001045863113302101909"). I want to do a check if I have any files in this directory that contain my vars.transaction in the filename.
So I think I need to use sftp list connector, edit inline and use filename pattern. But as there is numbers before and after the Transaction part I am not sure what to put in the filename pattern. Something like [#vars.transaction]
Thanks in advance
You can use the wildcard * along with your variable. Like *#[vars.transaction]* that will match all the files which has the vars.transaction in their name

Exim Verify Reciepient by existence of a file

I want to configure Exim to verify and accept emails only for users where a File exists. The File itself lies in a Folder constructed by paths of the Filename. (for use with modified mailman):
the mail for "mailing_address.tld#domain.tld" should only be accepted if a file exists:
/var/lib/mailman/a/ad/domain.tld/mailing/config.pck
So
/var/lib/mailman/{first letter of address "**a**"}/{first and second letter of address "**ad**"}/{first part of local_part delimtered by _ "**mailing**"}/config.pck
I've tried with exim sg and substring but I couldn't get it to work.
I found a solution with sg and substr:
MM_NAME=${sg{$local_part}{_.*}{}}
MM_DOMAIN=${sg{lc::$local_part}{.*_}{}}
MM_LISTCHK=/var/lib/mailman/lists/${substr{0}{1}{MM_DOMAIN}}/${substr{0}{2}{MM_DOMAIN}}/MM_DOMAIN/MM_NAME/config.pck
it's 3 parts but works like intended

With syslog-ng how do you embed regex's in templates

I am converting a rsyslog template to syslog-ng and I cannot find in the syslog-ng docs how to embed regex's in a template. The incoming message body looks like this:
123 1.2.3.4 4.3.2.1:80 someone#somewhere.com US
The original rsyslog template is:
$template graylog_json,"{\"version\":\"1.1\", \"host\":\"%HOSTNAME:::json%\", \"short_message\":\"Mail Authentication Log\", \"_LogDateTime\":\"%timereported:::date-rfc3339,json%\", \"_Cluster\":\"c25\", \"_ResponseCode\":\"%msg:R,ERE,1,BLANK:^[^ ]*? ([0-9]{3}) --end:json%\", \"_SourceIP\":\"%msg:R,ERE,2,BLANK:^ ([0-9]{3}) ([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})--end:json%\", \"_DestinationIP\":\"%msg:R,ERE,1,BLANK: ([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}):[0-9]{2,4}--end:json%\", \"_DestinationPort\":\"%msg:R,ERE,1,BLANK: [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:([0-9]{2,4})--end:json%\", \"_UserAccount\":\"%msg:R,ERE,1,BLANK::[0-9]{2,4} ([^ ]{1,})--end:json%\", \"_Country\":\"%msg:R,ERE,2,BLANK::[0-9]{2,4} ([^ ]{1,})( [A-Z?]{2})?--end:json%\"}\n"
The regex bits in the template parse out the relevant fields in the original message. I can't just dump messages to graylog because we use custom fields. I believe I want to use a template in syslog-ng, but I can't find examples, or even docs, showing how to embed regex's inside a template.
looking at the body of your message, you have the following options:
Parse the message with a csv-parser, using the whitespace as separator character. Note that the csv-parser will not split the IP:port, but you can run another csv-parser on the address (this time with : as separator) to do that. You can find examples for that in the syslog-ng documentation
Alternatively, you can write a custom syslog-ng parser in Python to process this message, and use the standard python string functions to separate the message into words and split the IP:port pair.
Using the csv-parser is probably easier and has better performance.
Also, syslog-ng version 3.13 includes a graylog destination (that's not included in the docs yet, but you can find an example in this blog post Graylog as destination in syslog-ng)

How to set and get variables when working in cmd

I am working in cmd to send HTTP GET and POST requests with cURL.
There are many times where I am sending requests to the same pages and typing them out every time is a huge pain.
I'm trying to figure out how to use set= so that I can save these URLs for each time I want to use them.
I've tried
C:\>set page = "http://www.mywebpage.com/api/user/friends"
C:\>page
'page' is not recognized as an internal or external command,
operable program or batch file.
C:\>echo %page%
%page%
but it won't return the page name.
How can I accomplish what I need?
C:\Windows\system32>set page="http://www.mywebpage.com/api/user/friends"
C:\Windows\system32>echo %page%
"http://www.mywebpage.com/api/user/friends"
C:\Windows\system32>set page=http://www.mywebpage.com/api/user/friends
C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/friends
Don't use spaces around =. Select version with or without " according to your needs. Variable value may contain spaces inside:
C:\Windows\system32>set page=http://www.mywebpage.com/api/user/my friends
C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/my friends
You are setting the value "http://www.mywebpage.com/api/user/friends" inside the variable "page " (notice the space) since you have a space before the =.
So you can either retrieve the value by using %page % or by using set page="http://..." without a space between page and the equals sign

Apache HTTPD Virtual Host,what is %1+ in a document root?

So I have a Virtual Host set up and I snagged this as my Document Root
VirtualDocumentRoot "/sites/%1+/www"
Everything works great but this one thing has been killing me. Does anyone have any idea what %1+ means? Could someone breakdown exactly what it is and how it works. I understand it is pointing the server to where to look but what is %1+ doing?
Read the documentation: http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html
All the directives in this module interpolate a string into a
pathname. The interpolated string [...] may be either the server name
[...] or the IP address of the virtual host on the server in
dotted-quad format. The interpolation is controlled by specifiers
inspired by printf which have a number of formats:
[...]
%N.M insert (part of) the name
N and M are used to specify substrings of the name. N selects from the
dot-separated components of the name, and M selects characters within
whatever N has selected. M is optional and defaults to zero if it
isn't present; the dot must be present if and only if M is present.
The interpretation is as follows:
0 the whole name
1 the first part
[...]
2+ the second and all subsequent parts
[...]
For a very large number of virtual hosts it is a good idea to arrange
the files to reduce the size of the vhosts directory. To do this you
might use the following in your configuration file:
UseCanonicalName Off
VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2
A request for http://www.domain.example.com/directory/file.html will
be satisfied by the file
/usr/local/apache/vhosts/example.com/d/o/m/domain/directory/file.html.
So, in
VirtualDocumentRoot "/sites/%1+/www"
the request
www.example.com
would resolve to
/sites/www.example.com/www