diff options
| author | manuel <manuel@mausz.at> | 2013-02-04 02:32:40 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2013-02-04 02:32:40 +0100 |
| commit | 8514473287c9594137c6fbc39f5619672ebc2430 (patch) | |
| tree | a5b965d8c7b60dee396bf8ebe25dd3eddfaa6753 /README.qregex | |
| parent | 35ddb916045abafaa4ae2c778b9383059fa06726 (diff) | |
| download | qmail-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.qregex | 203 |
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 @@ | |||
| 1 | QREGEX (v2) 20060423 - README April 23, 2006 | ||
| 2 | A Regular Expression matching patch for qmail 1.03 and netqmail | ||
| 3 | |||
| 4 | |||
| 5 | OVERVIEW: | ||
| 6 | |||
| 7 | qregex adds the ability to match address evelopes via Regular Expressions (REs) | ||
| 8 | in 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. | ||
| 10 | It follows all the base rules that are set out with qmail (ie using control | ||
| 11 | files) so it makes for easy integretion into an existing setup (see the | ||
| 12 | install instructions for more info). The v2 is specified because qregex was | ||
| 13 | re-written to better conform to the security guarantee set forth by the author | ||
| 14 | of qmail. The original version used stdio.h and stdlib.h for reading the | ||
| 15 | control files whereas v2 now uses all stralloc functions which are much more | ||
| 16 | regulated against buffer overruns and the like. | ||
| 17 | See: http://cr.yp.to/qmail/guarantee.html | ||
| 18 | |||
| 19 | |||
| 20 | FEATURES: | ||
| 21 | |||
| 22 | Features of qregex include: | ||
| 23 | |||
| 24 | 1. 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 | |||
| 30 | 2. 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 | |||
| 34 | 3. Matches to patterns are logged. Setting the LOGREGEX environment | ||
| 35 | variable causes the matched regex pattern to be included in the log. | ||
| 36 | |||
| 37 | 4. Matching is case insensitive. | ||
| 38 | |||
| 39 | 5. 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 | |||
| 44 | PLATFORMS: | ||
| 45 | |||
| 46 | qregex has been built and tested on the following platforms. I'm sure it won't | ||
| 47 | have any problems on any platform that qmail will run on (providing they have | ||
| 48 | a 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 | |||
| 57 | INSTALLATION INSTRUCTIONS: | ||
| 58 | |||
| 59 | Installation is very simple, there is only one requirement. You need to use the | ||
| 60 | GNU 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. | ||
| 64 | Unpack 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 | ||
| 66 | included qmail INSTALL file. Once you are done come back to this file and read | ||
| 67 | the section on the control files. | ||
| 68 | |||
| 69 | If you are using netqmail, then unpack the netqmail archive. Run the collate.sh | ||
| 70 | script and cd into the resulting netqmail-<version> directory. From there, run | ||
| 71 | "patch < /path/to/qregex-<version>.patch". Complete the netqmail installation | ||
| 72 | normally. Once you are done, come back to this file and read the section on the | ||
| 73 | control files. | ||
| 74 | |||
| 75 | - If this is an existing setup. | ||
| 76 | FIRST: create your control files (see below). | ||
| 77 | cd 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 | |||
| 81 | Install the new binary by cd'ing to /var/qmail/bin and as root (in one command) | ||
| 82 | copy the existing binary to 'qmail-smtpd.old' and copy the new binary from the | ||
| 83 | source directory to 'qmail-smtpd'. | ||
| 84 | (ex. cp qmail-smtpd qmail-smtpd.old && cp ~/qmail-1.03/qmail-smtpd qmail-smtpd) | ||
| 85 | |||
| 86 | You can also optionally just run "make setup check" as it will install the | ||
| 87 | updated documentation and man pages provided with this patch. Stopping qmail | ||
| 88 | before doing the "make setup check" is always a good idea. | ||
| 89 | |||
| 90 | |||
| 91 | LOGGING: | ||
| 92 | |||
| 93 | qregex will log matches to the patterns in the various control files. Log | ||
| 94 | messages will take these three forms depending on which control file was | ||
| 95 | matched: | ||
| 96 | |||
| 97 | badhelo | ||
| 98 | qmail-smtpd: badhelo: <host> at <remote IP> | ||
| 99 | |||
| 100 | badmailfrom and badmailfromnorelay | ||
| 101 | qmail-smtpd: badmailfrom: <sender address> at <remote IP> | ||
| 102 | |||
| 103 | badmailto and badmailtonorelay | ||
| 104 | qmail-smtpd: badmailto: <rcpt address> at <remote IP> | ||
| 105 | |||
| 106 | When the LOGREGEX environment variable is set, the matched pattern will | ||
| 107 | be included in the log. Log messages will have the regex pattern appended | ||
| 108 | to them. For example, a badhelo log message will look like this: | ||
| 109 | |||
| 110 | qmail-smtpd: badhelo: <host> at <remote IP> matches pattern: <regex> | ||
| 111 | |||
| 112 | |||
| 113 | CONTROL FILES: | ||
| 114 | |||
| 115 | qregex provides you with five control files. None of these control files | ||
| 116 | is mandatory and you can use them in any combination you choose in your setup. | ||
| 117 | |||
| 118 | The "control/badmailfrom" and "control/badmailto" files contain your REs for | ||
| 119 | matching against the 'mail from' (envelope sender) and 'rcpt to' (envelope | ||
| 120 | recipient) smtp commands respectively. | ||
| 121 | The "control/badmailfromnorelay" and "control/badmailtonorelay" match against | ||
| 122 | the same commands but are read only when the RELAYCLIENT environment variable | ||
| 123 | is not set. | ||
| 124 | The "control/badhelo" file matches against the 'helo/ehlo' smtp command. | ||
| 125 | |||
| 126 | If you prefer you can symlink the badmailfrom and badmailto control files | ||
| 127 | (ln -s badmailfrom badmailto) and maintain fewer sets of rules. Beware | ||
| 128 | this 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 | |||
| 153 | You can use the non-RE character '!' to start an RE as a signal to qregex to | ||
| 154 | negate the action. As used above in the badmailfrom file, by negating the '@' | ||
| 155 | symbol qregex will signal qmail-smtpd to deny the 'mail from' command whenever | ||
| 156 | the address doesn't contain an @ symbol. When used inside a bracket expression, | ||
| 157 | the '!' character looses this special meaning. This is shown in the badmailto | ||
| 158 | example. | ||
| 159 | |||
| 160 | The norelay control files follow the same rules as the other control files but | ||
| 161 | are intended to address two specific scenarios. | ||
| 162 | The badmailfromnorelay file can be used to block mail trying to spoof a domain | ||
| 163 | hosted on your mail server. It prevents a mail client that is not allowed to | ||
| 164 | relay email through your server from using one of your hosted domains as its | ||
| 165 | envelope sender. | ||
| 166 | The badmailtonorelay file can be used to create email addresses that cannot | ||
| 167 | receive mail from any source not allowed to relay email through your server. | ||
| 168 | This is handy for creating email addresses for use only within your own | ||
| 169 | domain(s) that can't receive spam from the world at large. | ||
| 170 | |||
| 171 | |||
| 172 | INTERNALS: | ||
| 173 | |||
| 174 | qregex (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". | ||
| 176 | When called, it will read the proper control file then one by one compile and | ||
| 177 | execute the regex on the string passed into qmail-smtpd. If the regex matches | ||
| 178 | it returns TRUE (1) and the qmail-smtpd process will deny the user the ability | ||
| 179 | to continue. If you change anything and think it betters this patch please | ||
| 180 | send me a new diff file so I can take a peek. | ||
| 181 | |||
| 182 | |||
| 183 | CONTACT: | ||
| 184 | qregex is maintained by: | ||
| 185 | Andrew St. Jean | ||
| 186 | andrew@arda.homeunix.net | ||
| 187 | www.arda.homeunix.net/store/qmail/ | ||
| 188 | |||
| 189 | Contributers 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 | |||
| 201 | Original qregex patch written by: | ||
| 202 | Evan Borgstrom | ||
| 203 | evan at unixpimps dot org | ||
