summaryrefslogtreecommitdiffstats
path: root/README.qregex
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-02-04 02:32:40 +0100
committermanuel <manuel@mausz.at>2013-02-04 02:32:40 +0100
commit8514473287c9594137c6fbc39f5619672ebc2430 (patch)
treea5b965d8c7b60dee396bf8ebe25dd3eddfaa6753 /README.qregex
parent35ddb916045abafaa4ae2c778b9383059fa06726 (diff)
downloadqmail-8514473287c9594137c6fbc39f5619672ebc2430.tar.gz
qmail-8514473287c9594137c6fbc39f5619672ebc2430.tar.bz2
qmail-8514473287c9594137c6fbc39f5619672ebc2430.zip
[PATCH] qregex-starttls-2way-auth-20060423-mm
Diffstat (limited to 'README.qregex')
-rw-r--r--README.qregex203
1 files changed, 203 insertions, 0 deletions
diff --git a/README.qregex b/README.qregex
new file mode 100644
index 0000000..60c1aeb
--- /dev/null
+++ b/README.qregex
@@ -0,0 +1,203 @@
1QREGEX (v2) 20060423 - README April 23, 2006
2A Regular Expression matching patch for qmail 1.03 and netqmail
3
4
5OVERVIEW:
6
7qregex adds the ability to match address evelopes via Regular Expressions (REs)
8in the qmail-smtpd process. It has the abiltiy to match `helo/ehlo` (host name),
9`mail from` (envelope sender), and `rcpt to` (envelope recipient) commands.
10It follows all the base rules that are set out with qmail (ie using control
11files) so it makes for easy integretion into an existing setup (see the
12install instructions for more info). The v2 is specified because qregex was
13re-written to better conform to the security guarantee set forth by the author
14of qmail. The original version used stdio.h and stdlib.h for reading the
15control files whereas v2 now uses all stralloc functions which are much more
16regulated against buffer overruns and the like.
17See: http://cr.yp.to/qmail/guarantee.html
18
19
20FEATURES:
21
22Features of qregex include:
23
241. Performs pattern matching on envelope senders and envelope
25 recipients against REs in the badmailfrom and badmailto control
26 files. Two additional control files, badmailfromnorelay and
27 badmailtonorelay, are used for pattern matching when the
28 RELAYCLIENT environment variable is not set.
29
302. Performs pattern matching on the helo/ehlo host name. Setting the
31 NOBADHELO environment variable prevents the host name from being
32 compared to the patterns in the badhelo control file.
33
343. Matches to patterns are logged. Setting the LOGREGEX environment
35 variable causes the matched regex pattern to be included in the log.
36
374. Matching is case insensitive.
38
395. qregex ignores empty envelope senders. An empty envelope sender is not
40 compared to the patterns in the badmailfrom and badmailfromnorelay
41 control files and is always accepted.
42
43
44PLATFORMS:
45
46qregex has been built and tested on the following platforms. I'm sure it won't
47have any problems on any platform that qmail will run on (providing they have
48a regex interface) but if you run into problems let me know.
49
50 - OpenBSD 3.x
51 - FreeBSD 4.x, 5.x
52 - Mandrake Linux 9.x
53 - SuSE Linux 8.x
54
55
56
57INSTALLATION INSTRUCTIONS:
58
59Installation is very simple, there is only one requirement. You need to use the
60GNU version of the patch utility (http://www.gnu.org/software/patch/patch.html).
61(For Solaris 8 users it is installed as 'gpatch')
62
63- If this is a new setup.
64Unpack the qmail archive, cd into the qmail-1.03 directory and run
65"patch < /path/to/qregex-<version>.patch". Follow the instructions as per the
66included qmail INSTALL file. Once you are done come back to this file and read
67the section on the control files.
68
69If you are using netqmail, then unpack the netqmail archive. Run the collate.sh
70script and cd into the resulting netqmail-<version> directory. From there, run
71"patch < /path/to/qregex-<version>.patch". Complete the netqmail installation
72normally. Once you are done, come back to this file and read the section on the
73control files.
74
75- If this is an existing setup.
76FIRST: create your control files (see below).
77cd into your existing qmail or netqmail source directory. Run
78"patch < /path/to/qregex-<version>.patch" then "make qmail-smtpd". Now run
79./qmail-smtpd and test your new rules to make sure they work as expected.
80
81Install the new binary by cd'ing to /var/qmail/bin and as root (in one command)
82copy the existing binary to 'qmail-smtpd.old' and copy the new binary from the
83source directory to 'qmail-smtpd'.
84(ex. cp qmail-smtpd qmail-smtpd.old && cp ~/qmail-1.03/qmail-smtpd qmail-smtpd)
85
86You can also optionally just run "make setup check" as it will install the
87updated documentation and man pages provided with this patch. Stopping qmail
88before doing the "make setup check" is always a good idea.
89
90
91LOGGING:
92
93qregex will log matches to the patterns in the various control files. Log
94messages will take these three forms depending on which control file was
95matched:
96
97badhelo
98qmail-smtpd: badhelo: <host> at <remote IP>
99
100badmailfrom and badmailfromnorelay
101qmail-smtpd: badmailfrom: <sender address> at <remote IP>
102
103badmailto and badmailtonorelay
104qmail-smtpd: badmailto: <rcpt address> at <remote IP>
105
106When the LOGREGEX environment variable is set, the matched pattern will
107be included in the log. Log messages will have the regex pattern appended
108to them. For example, a badhelo log message will look like this:
109
110qmail-smtpd: badhelo: <host> at <remote IP> matches pattern: <regex>
111
112
113CONTROL FILES:
114
115qregex provides you with five control files. None of these control files
116is mandatory and you can use them in any combination you choose in your setup.
117
118The "control/badmailfrom" and "control/badmailto" files contain your REs for
119matching against the 'mail from' (envelope sender) and 'rcpt to' (envelope
120recipient) smtp commands respectively.
121The "control/badmailfromnorelay" and "control/badmailtonorelay" match against
122the same commands but are read only when the RELAYCLIENT environment variable
123is not set.
124The "control/badhelo" file matches against the 'helo/ehlo' smtp command.
125
126If you prefer you can symlink the badmailfrom and badmailto control files
127(ln -s badmailfrom badmailto) and maintain fewer sets of rules. Beware
128this might cause problems in certain setups.
129
130 Here's an example "badhelo" file.
131 -----------------------------------
132 # block host strings with no dot (not a FQDN)
133 !\.
134 -----------------------------------
135
136 An example "badmailfrom" file.
137 -----------------------------------
138 # this will drop everything containing the string
139 # bad.domain.com or Bad.Domain.Com or BAD.domain.COM
140 bad\.domain\.com
141 # force users to fully qualify themselves
142 # (i.e. deny "user", accept "user@domain")
143 !@
144 -----------------------------------
145
146 And "badmailto" (a little more interesting)
147 -----------------------------------
148 # must not contain invalid characters, brakets or multiple @'s
149 [!%#:*^(){}]
150 @.*@
151 -----------------------------------
152
153You can use the non-RE character '!' to start an RE as a signal to qregex to
154negate the action. As used above in the badmailfrom file, by negating the '@'
155symbol qregex will signal qmail-smtpd to deny the 'mail from' command whenever
156the address doesn't contain an @ symbol. When used inside a bracket expression,
157the '!' character looses this special meaning. This is shown in the badmailto
158example.
159
160The norelay control files follow the same rules as the other control files but
161are intended to address two specific scenarios.
162The badmailfromnorelay file can be used to block mail trying to spoof a domain
163hosted on your mail server. It prevents a mail client that is not allowed to
164relay email through your server from using one of your hosted domains as its
165envelope sender.
166The badmailtonorelay file can be used to create email addresses that cannot
167receive mail from any source not allowed to relay email through your server.
168This is handy for creating email addresses for use only within your own
169domain(s) that can't receive spam from the world at large.
170
171
172INTERNALS:
173
174qregex (or regexmatch as the function is called) will be called during the
175`helo/ehlo`, `rcpt to` and `mail from` handling routines in "qmail-smtpd.c".
176When called, it will read the proper control file then one by one compile and
177execute the regex on the string passed into qmail-smtpd. If the regex matches
178it returns TRUE (1) and the qmail-smtpd process will deny the user the ability
179to continue. If you change anything and think it betters this patch please
180send me a new diff file so I can take a peek.
181
182
183CONTACT:
184qregex is maintained by:
185 Andrew St. Jean
186 andrew@arda.homeunix.net
187 www.arda.homeunix.net/store/qmail/
188
189Contributers to qregex:
190 Jeremy Kitchen
191 kitchen at scriptkitchen dot com
192 http://www.scriptkitchen.com/qmail
193
194 Alex Pleiner
195 alex@zeitform.de
196 zeitform Internet Dienste
197 http://www.zeitform.de/
198
199 Thanos Massias
200
201Original qregex patch written by:
202 Evan Borgstrom
203 evan at unixpimps dot org