qregex-20060423-qmail.patch
author "Tomas Zeman <tzeman@volny.cz>"
Thu, 01 Nov 2007 16:46:23 +0100
changeset 2 1073d8be4215
parent 1 b375914441b2
permissions -rw-r--r--
qmail-dietlibc: compile qmail w/ dietlibc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     1
Fixed qregex-20060423 (pristine is against netqmail)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     2
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     3
diff -r 1510847ae5bf Makefile
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     4
--- a/Makefile	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     5
+++ b/Makefile	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     6
@@ -1534,16 +1534,16 @@ auto_split.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     7
 	./compile qmail-showctl.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     8
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     9
 qmail-smtpd: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    10
-load qmail-smtpd.o rcpthosts.o commands.o timeoutread.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    11
+load qmail-smtpd.o rcpthosts.o qregex.o commands.o timeoutread.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    12
 timeoutwrite.o ip.o ipme.o ipalloc.o control.o constmap.o received.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    13
 date822fmt.o now.o qmail.o cdb.a fd.a wait.a datetime.a getln.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    14
-open.a sig.a case.a env.a stralloc.a alloc.a substdio.a error.a str.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    15
+open.a sig.a case.a env.a stralloc.a alloc.a strerr.a substdio.a error.a str.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    16
 fs.a auto_qmail.o socket.lib
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    17
-	./load qmail-smtpd rcpthosts.o commands.o timeoutread.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    18
+	./load qmail-smtpd qregex.o rcpthosts.o commands.o timeoutread.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    19
 	timeoutwrite.o ip.o ipme.o ipalloc.o control.o constmap.o \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    20
 	received.o date822fmt.o now.o qmail.o cdb.a fd.a wait.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    21
 	datetime.a getln.a open.a sig.a case.a env.a stralloc.a \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    22
-	alloc.a substdio.a error.a str.a fs.a auto_qmail.o  `cat \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    23
+	alloc.a strerr.a substdio.a error.a str.a fs.a auto_qmail.o  `cat \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    24
 	socket.lib`
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    25
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    26
 qmail-smtpd.0: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    27
@@ -1696,6 +1696,10 @@ compile rcpthosts.c cdb.h uint32.h byte.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    28
 compile rcpthosts.c cdb.h uint32.h byte.h open.h error.h control.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    29
 constmap.h stralloc.h gen_alloc.h rcpthosts.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    30
 	./compile rcpthosts.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    31
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    32
+qregex.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    33
+compile qregex.c qregex.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    34
+	./compile qregex.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    35
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    36
 readsubdir.o: \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    37
 compile readsubdir.c readsubdir.h direntry.h fmt.h scan.h str.h \
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    38
diff -r 1510847ae5bf README.qregex
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    39
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    40
+++ b/README.qregex	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    41
@@ -0,0 +1,203 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    42
+QREGEX (v2) 20060423 - README April 23, 2006
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    43
+A Regular Expression matching patch for qmail 1.03 and netqmail
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    44
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    45
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    46
+OVERVIEW:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    47
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    48
+qregex adds the ability to match address evelopes via Regular Expressions (REs)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    49
+in the qmail-smtpd process. It has the abiltiy to match `helo/ehlo` (host name),
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    50
+`mail from` (envelope sender), and `rcpt to` (envelope recipient) commands.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    51
+It follows all the base rules that are set out with qmail (ie using control
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    52
+files) so it makes for easy integretion into an existing setup (see the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    53
+install instructions for more info). The v2 is specified because qregex was
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    54
+re-written to better conform to the security guarantee set forth by the author
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    55
+of qmail. The original version used stdio.h and stdlib.h for reading the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    56
+control files whereas v2 now uses all stralloc functions which are much more
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    57
+regulated against buffer overruns and the like.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    58
+See: http://cr.yp.to/qmail/guarantee.html
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    59
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    60
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    61
+FEATURES:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    62
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    63
+Features of qregex include:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    64
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    65
+1. Performs pattern matching on envelope senders and envelope
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    66
+   recipients against REs in the badmailfrom and badmailto control
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    67
+   files. Two additional control files, badmailfromnorelay and
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    68
+   badmailtonorelay, are used for pattern matching when the 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    69
+   RELAYCLIENT environment variable is not set.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    70
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    71
+2. Performs pattern matching on the helo/ehlo host name. Setting the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    72
+   NOBADHELO environment variable prevents the host name from being
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    73
+   compared to the patterns in the badhelo control file.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    74
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    75
+3. Matches to patterns are logged. Setting the LOGREGEX environment
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    76
+   variable causes the matched regex pattern to be included in the log. 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    77
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    78
+4. Matching is case insensitive.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    79
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    80
+5. qregex ignores empty envelope senders. An empty envelope sender is not
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    81
+   compared to the patterns in the badmailfrom and badmailfromnorelay
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    82
+   control files and is always accepted.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    83
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    84
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    85
+PLATFORMS:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    86
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    87
+qregex has been built and tested on the following platforms. I'm sure it won't
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    88
+have any problems on any platform that qmail will run on (providing they have
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    89
+a regex interface) but if you run into problems let me know.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    90
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    91
+	- OpenBSD 3.x
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    92
+	- FreeBSD 4.x, 5.x
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    93
+	- Mandrake Linux 9.x
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    94
+	- SuSE Linux 8.x
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    95
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    96
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    97
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    98
+INSTALLATION INSTRUCTIONS:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    99
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   100
+Installation is very simple, there is only one requirement. You need to use the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   101
+GNU version of the patch utility (http://www.gnu.org/software/patch/patch.html).
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   102
+(For Solaris 8 users it is installed as 'gpatch')
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   103
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   104
+- If this is a new setup.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   105
+Unpack the qmail archive, cd into the qmail-1.03 directory and run
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   106
+"patch < /path/to/qregex-<version>.patch". Follow the instructions as per the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   107
+included qmail INSTALL file. Once you are done come back to this file and read
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   108
+the section on the control files.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   109
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   110
+If you are using netqmail, then unpack the netqmail archive. Run the collate.sh
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   111
+script and cd into the resulting netqmail-<version> directory. From there, run
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   112
+"patch < /path/to/qregex-<version>.patch". Complete the netqmail installation
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   113
+normally. Once you are done, come back to this file and read the section on the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   114
+control files.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   115
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   116
+- If this is an existing setup.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   117
+FIRST: create your control files (see below).
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   118
+cd into your existing qmail or netqmail source directory. Run
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   119
+"patch < /path/to/qregex-<version>.patch" then "make qmail-smtpd". Now run
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   120
+./qmail-smtpd and test your new rules to make sure they work as expected.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   121
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   122
+Install the new binary by cd'ing to /var/qmail/bin and as root (in one command)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   123
+copy the existing binary to 'qmail-smtpd.old' and copy the new binary from the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   124
+source directory to 'qmail-smtpd'.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   125
+(ex. cp qmail-smtpd qmail-smtpd.old && cp ~/qmail-1.03/qmail-smtpd qmail-smtpd)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   126
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   127
+You can also optionally just run "make setup check" as it will install the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   128
+updated documentation and man pages provided with this patch. Stopping qmail
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   129
+before doing the "make setup check" is always a good idea.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   130
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   131
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   132
+LOGGING:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   133
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   134
+qregex will log matches to the patterns in the various control files. Log
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   135
+messages will take these three forms depending on which control file was
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   136
+matched:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   137
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   138
+badhelo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   139
+qmail-smtpd: badhelo: <host> at <remote IP>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   140
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   141
+badmailfrom and badmailfromnorelay
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   142
+qmail-smtpd: badmailfrom: <sender address> at <remote IP>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   143
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   144
+badmailto and badmailtonorelay
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   145
+qmail-smtpd: badmailto: <rcpt address> at <remote IP>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   146
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   147
+When the LOGREGEX environment variable is set, the matched pattern will
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   148
+be included in the log. Log messages will have the regex pattern appended
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   149
+to them. For example, a badhelo log message will look like this:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   150
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   151
+qmail-smtpd: badhelo: <host> at <remote IP> matches pattern: <regex>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   152
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   153
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   154
+CONTROL FILES:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   155
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   156
+qregex provides you with five control files. None of these control files
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   157
+is mandatory and you can use them in any combination you choose in your setup.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   158
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   159
+The "control/badmailfrom" and "control/badmailto" files contain your REs for
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   160
+matching against the 'mail from' (envelope sender) and 'rcpt to' (envelope
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   161
+recipient) smtp commands respectively.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   162
+The "control/badmailfromnorelay" and "control/badmailtonorelay" match against
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   163
+the same commands but are read only when the RELAYCLIENT environment variable
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   164
+is not set.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   165
+The "control/badhelo" file matches against the 'helo/ehlo' smtp command.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   166
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   167
+If you prefer you can symlink the badmailfrom and badmailto control files
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   168
+(ln -s badmailfrom badmailto) and maintain fewer sets of rules. Beware
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   169
+this might cause problems in certain setups.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   170
+        
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   171
+	Here's an example "badhelo" file.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   172
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   173
+	# block host strings with no dot (not a FQDN)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   174
+	!\.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   175
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   176
+	
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   177
+	An example "badmailfrom" file.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   178
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   179
+	# this will drop everything containing the string
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   180
+	# bad.domain.com or Bad.Domain.Com or BAD.domain.COM
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   181
+	bad\.domain\.com
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   182
+	# force users to fully qualify themselves
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   183
+	# (i.e. deny "user", accept "user@domain")
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   184
+	!@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   185
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   186
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   187
+	And "badmailto" (a little more interesting)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   188
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   189
+	# must not contain invalid characters, brakets or multiple @'s
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   190
+	[!%#:*^(){}]
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   191
+	@.*@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   192
+	-----------------------------------
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   193
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   194
+You can use the non-RE character '!' to start an RE as a signal to qregex to
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   195
+negate the action. As used above in the badmailfrom file, by negating the '@'
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   196
+symbol qregex will signal qmail-smtpd to deny the 'mail from' command whenever
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   197
+the address doesn't contain an @ symbol. When used inside a bracket expression,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   198
+the '!' character looses this special meaning. This is shown in the badmailto
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   199
+example.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   200
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   201
+The norelay control files follow the same rules as the other control files but
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   202
+are intended to address two specific scenarios.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   203
+The badmailfromnorelay file can be used to block mail trying to spoof a domain
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   204
+hosted on your mail server. It prevents a mail client that is not allowed to
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   205
+relay email through your server from using one of your hosted domains as its
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   206
+envelope sender.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   207
+The badmailtonorelay file can be used to create email addresses that cannot
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   208
+receive mail from any source not allowed to relay email through your server.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   209
+This is handy for creating email addresses for use only within your own 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   210
+domain(s) that can't receive spam from the world at large.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   211
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   212
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   213
+INTERNALS:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   214
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   215
+qregex (or regexmatch as the function is called) will be called during the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   216
+`helo/ehlo`, `rcpt to` and `mail from` handling routines in "qmail-smtpd.c".
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   217
+When called, it will read the proper control file then one by one compile and
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   218
+execute the regex on the string passed into qmail-smtpd. If the regex matches
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   219
+it returns TRUE (1) and the qmail-smtpd process will deny the user the ability
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   220
+to continue. If you change anything and think it betters this patch please
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   221
+send me a new diff file so I can take a peek.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   222
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   223
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   224
+CONTACT:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   225
+qregex is maintained by:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   226
+	Andrew St. Jean
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   227
+	andrew@arda.homeunix.net
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   228
+	www.arda.homeunix.net/store/qmail/
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   229
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   230
+Contributers to qregex:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   231
+	Jeremy Kitchen	
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   232
+	kitchen at scriptkitchen dot com
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   233
+	http://www.scriptkitchen.com/qmail
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   234
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   235
+	Alex Pleiner
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   236
+	alex@zeitform.de
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   237
+	zeitform Internet Dienste
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   238
+	http://www.zeitform.de/
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   239
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   240
+	Thanos Massias
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   241
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   242
+Original qregex patch written by:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   243
+	Evan Borgstrom
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   244
+	evan at unixpimps dot org
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   245
diff -r 1510847ae5bf TARGETS
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   246
--- a/TARGETS	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   247
+++ b/TARGETS	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   248
@@ -252,6 +252,7 @@ qmail-qmtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   249
 qmail-qmtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   250
 qmail-smtpd.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   251
 qmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   252
+qregex.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   253
 sendmail.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   254
 sendmail
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   255
 tcp-env.o
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   256
diff -r 1510847ae5bf hier.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   257
--- a/hier.c	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   258
+++ b/hier.c	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   259
@@ -76,6 +76,7 @@ void hier()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   260
   c(auto_qmail,"boot","binm3+df",auto_uido,auto_gidq,0755);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   261
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   262
   c(auto_qmail,"doc","FAQ",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   263
+  c(auto_qmail,"doc","README.qregex",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   264
   c(auto_qmail,"doc","UPGRADE",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   265
   c(auto_qmail,"doc","SENDMAIL",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   266
   c(auto_qmail,"doc","INSTALL",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   267
diff -r 1510847ae5bf install-big.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   268
--- a/install-big.c	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   269
+++ b/install-big.c	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   270
@@ -76,6 +76,7 @@ void hier()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   271
   c(auto_qmail,"boot","binm3+df",auto_uido,auto_gidq,0755);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   272
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   273
   c(auto_qmail,"doc","FAQ",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   274
+  c(auto_qmail,"doc","README.qregex",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   275
   c(auto_qmail,"doc","UPGRADE",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   276
   c(auto_qmail,"doc","SENDMAIL",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   277
   c(auto_qmail,"doc","INSTALL",auto_uido,auto_gidq,0644);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   278
diff -r 1510847ae5bf qmail-control.9
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   279
--- a/qmail-control.9	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   280
+++ b/qmail-control.9	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   281
@@ -20,7 +20,11 @@ other hostname-related control files.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   282
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   283
 Comments are allowed
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   284
 in
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   285
+.IR badhelo ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   286
 .IR badmailfrom ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   287
+.IR badmailfromnorelay ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   288
+.IR badmailto ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   289
+.IR badmailtonorelay ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   290
 .IR locals ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   291
 .IR percenthack ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   292
 .IR qmqpservers ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   293
@@ -40,7 +44,11 @@ See the corresponding man pages for furt
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   294
 .ta 5c 10c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   295
 control	default	used by
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   296
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   297
+.I badhelo	\fR(none)	\fRqmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   298
 .I badmailfrom	\fR(none)	\fRqmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   299
+.I badmailfromnorelay	\fR(none)	\fRqmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   300
+.I badmailto	\fR(none)	\fRqmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   301
+.I badmailtonorelay	\fR(none)	\fRqmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   302
 .I bouncefrom	\fRMAILER-DAEMON	\fRqmail-send
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   303
 .I bouncehost	\fIme	\fRqmail-send
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   304
 .I concurrencylocal	\fR10	\fRqmail-send
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   305
diff -r 1510847ae5bf qmail-showctl.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   306
--- a/qmail-showctl.c	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   307
+++ b/qmail-showctl.c	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   308
@@ -214,7 +214,11 @@ void main()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   309
     _exit(111);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   310
   }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   311
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   312
-  do_lst("badmailfrom","Any MAIL FROM is allowed.",""," not accepted in MAIL FROM.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   313
+  do_lst("badhelo","Any HELO host name is allowed.",""," HELO host name denied if it matches this pattern.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   314
+  do_lst("badmailfrom","Any MAIL FROM is allowed.",""," MAIL FROM denied if it matches this pattern.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   315
+  do_lst("badmailfromnorelay","Any MAIL FROM is allowed.",""," MAIL FROM denied if it matches this pattern and RELAYCLIENT is not set.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   316
+  do_lst("badmailto","No RCPT TO are specifically denied.",""," RCPT TO denied if it matches this pattern.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   317
+  do_lst("badmailtonorelay","No RCPT TO are specifically denied.",""," RCPT TO denied if it matches this pattern and RELAYCLIENT is not set.");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   318
   do_str("bouncefrom",0,"MAILER-DAEMON","Bounce user name is ");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   319
   do_str("bouncehost",1,"bouncehost","Bounce host name is ");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   320
   do_int("concurrencylocal","10","Local concurrency is ","");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   321
@@ -267,7 +271,11 @@ void main()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   322
     if (str_equal(d->d_name,"..")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   323
     if (str_equal(d->d_name,"bouncefrom")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   324
     if (str_equal(d->d_name,"bouncehost")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   325
+    if (str_equal(d->d_name,"badhelo")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   326
     if (str_equal(d->d_name,"badmailfrom")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   327
+    if (str_equal(d->d_name,"badmailfromnorelay")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   328
+    if (str_equal(d->d_name,"badmailto")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   329
+    if (str_equal(d->d_name,"badmailtonorelay")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   330
     if (str_equal(d->d_name,"bouncefrom")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   331
     if (str_equal(d->d_name,"bouncehost")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   332
     if (str_equal(d->d_name,"concurrencylocal")) continue;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   333
diff -r 1510847ae5bf qmail-smtpd.8
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   334
--- a/qmail-smtpd.8	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   335
+++ b/qmail-smtpd.8	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   336
@@ -37,11 +37,26 @@ even though such messages violate the SM
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   337
 even though such messages violate the SMTP protocol.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   338
 .SH "CONTROL FILES"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   339
 .TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   340
+.I badhelo
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   341
+Unacceptable HELO/EHLO host names.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   342
+.B qmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   343
+will reject every recipient address for a message if
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   344
+the host name is listed in, 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   345
+or matches a POSIX regular expression pattern listed in,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   346
+.IR badhelo .
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   347
+If the 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   348
+.B NOBADHELO 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   349
+environment variable is set, then the contents of 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   350
+.IR badhelo 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   351
+will be ignored.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   352
+For more information, please have a look at doc/README.qregex.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   353
+.TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   354
 .I badmailfrom
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   355
 Unacceptable envelope sender addresses.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   356
 .B qmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   357
 will reject every recipient address for a message
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   358
-if the envelope sender address is listed in
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   359
+if the envelope sender address is listed in, or matches a POSIX regular expression
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   360
+pattern listed in,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   361
 .IR badmailfrom .
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   362
 A line in
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   363
 .I badmailfrom
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   364
@@ -49,6 +64,32 @@ may be of the form
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   365
 .BR @\fIhost ,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   366
 meaning every address at
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   367
 .IR host .
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   368
+For more information, please have a look at doc/README.qregex.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   369
+.TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   370
+.I badmailfromnorelay
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   371
+Functions the same as the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   372
+.IR badmailfrom
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   373
+control file but is read only if the 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   374
+.B RELAYCLIENT 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   375
+environment variable is not set.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   376
+For more information, please have a look at doc/README.qregex.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   377
+.TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   378
+.I badmailto
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   379
+Unacceptable envelope recipient addresses.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   380
+.B qmail-smtpd
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   381
+will reject every recipient address for a message if the recipient address
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   382
+is listed in,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   383
+or matches a POSIX regular expression pattern listed in,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   384
+.IR badmailto .
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   385
+For more information, please have a look at doc/README.qregex.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   386
+.TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   387
+.I badmailtonorelay
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   388
+Functions the same as the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   389
+.IR badmailto
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   390
+control file but is read only if the
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   391
+.B RELAYCLIENT
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   392
+environment variable is not set.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   393
+For more information, please have a look at doc/README.qregex.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   394
 .TP 5
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   395
 .I databytes
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   396
 Maximum number of bytes allowed in a message,
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   397
diff -r 1510847ae5bf qmail-smtpd.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   398
--- a/qmail-smtpd.c	Thu Nov 01 16:23:16 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   399
+++ b/qmail-smtpd.c	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   400
@@ -23,6 +23,15 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   401
 #include "timeoutread.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   402
 #include "timeoutwrite.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   403
 #include "commands.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   404
+#include "qregex.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   405
+#include "strerr.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   406
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   407
+#define BMCHECK_BMF 0
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   408
+#define BMCHECK_BMFNR 1
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   409
+#define BMCHECK_BMT 2
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   410
+#define BMCHECK_BMTNR 3
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   411
+#define BMCHECK_BHELO 4
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   412
+    
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   413
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   414
 #define MAXHOPS 100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   415
 unsigned int databytes = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   416
@@ -49,7 +58,9 @@ void die_ipme() { out("421 unable to fig
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   417
 void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   418
 void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   419
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   420
-void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   421
+void err_bmf() { out("553 sorry, your envelope sender has been denied (#5.7.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   422
+void err_bmt() { out("553 sorry, your envelope recipient has been denied (#5.7.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   423
+void err_bhelo() { out("553 sorry, your HELO host name has been denied (#5.7.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   424
 void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   425
 void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   426
 void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   427
@@ -93,9 +104,24 @@ void dohelo(arg) char *arg; {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   428
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   429
 int liphostok = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   430
 stralloc liphost = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   431
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   432
 int bmfok = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   433
 stralloc bmf = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   434
-struct constmap mapbmf;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   435
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   436
+int bmfnrok = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   437
+stralloc bmfnr = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   438
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   439
+int bmtok = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   440
+stralloc bmt = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   441
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   442
+int bmtnrok = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   443
+stralloc bmtnr = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   444
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   445
+int bhelook = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   446
+stralloc bhelo = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   447
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   448
+int logregex = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   449
+stralloc matchedregex = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   450
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   451
 void setup()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   452
 {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   453
@@ -114,8 +140,21 @@ void setup()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   454
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   455
   bmfok = control_readfile(&bmf,"control/badmailfrom",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   456
   if (bmfok == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   457
-  if (bmfok)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   458
-    if (!constmap_init(&mapbmf,bmf.s,bmf.len,0)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   459
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   460
+  bmfnrok = control_readfile(&bmfnr,"control/badmailfromnorelay",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   461
+  if (bmfnrok == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   462
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   463
+  bmtok = control_readfile(&bmt,"control/badmailto",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   464
+  if (bmtok == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   465
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   466
+  bmtnrok = control_readfile(&bmtnr,"control/badmailtonorelay",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   467
+  if (bmtnrok == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   468
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   469
+  bhelook = control_readfile(&bhelo, "control/badhelo",0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   470
+  if (bhelook == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   471
+  if (env_get("NOBADHELO")) bhelook = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   472
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   473
+  if (env_get("LOGREGEX")) logregex = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   474
  
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   475
   if (control_readint(&databytes,"control/databytes") == -1) die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   476
   x = env_get("DATABYTES");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   477
@@ -197,14 +236,56 @@ char *arg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   478
   return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   479
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   480
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   481
-int bmfcheck()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   482
-{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   483
-  int j;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   484
-  if (!bmfok) return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   485
-  if (constmap(&mapbmf,addr.s,addr.len - 1)) return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   486
-  j = byte_rchr(addr.s,addr.len,'@');
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   487
-  if (j < addr.len)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   488
-    if (constmap(&mapbmf,addr.s + j,addr.len - j - 1)) return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   489
+int bmcheck(which) int which;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   490
+{
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   491
+  int i = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   492
+  int j = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   493
+  int x = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   494
+  int negate = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   495
+  static stralloc bmb = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   496
+  static stralloc curregex = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   497
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   498
+  if (which == BMCHECK_BMF) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   499
+    if (!stralloc_copy(&bmb,&bmf)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   500
+  } else if (which == BMCHECK_BMFNR) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   501
+    if (!stralloc_copy(&bmb,&bmfnr)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   502
+  } else if (which == BMCHECK_BMT) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   503
+    if (!stralloc_copy(&bmb,&bmt)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   504
+  } else if (which == BMCHECK_BMTNR) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   505
+    if (!stralloc_copy(&bmb,&bmtnr)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   506
+  } else if (which == BMCHECK_BHELO) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   507
+    if (!stralloc_copy(&bmb,&bhelo)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   508
+  } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   509
+    die_control();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   510
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   511
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   512
+  while (j < bmb.len) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   513
+    i = j;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   514
+    while ((bmb.s[i] != '\0') && (i < bmb.len)) i++;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   515
+    if (bmb.s[j] == '!') {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   516
+      negate = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   517
+      j++;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   518
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   519
+    if (!stralloc_copyb(&curregex,bmb.s + j,(i - j))) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   520
+    if (!stralloc_0(&curregex)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   521
+    if (which == BMCHECK_BHELO) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   522
+      x = matchregex(helohost.s, curregex.s);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   523
+    } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   524
+      x = matchregex(addr.s, curregex.s);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   525
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   526
+    if ((negate) && (x == 0)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   527
+      if (!stralloc_copyb(&matchedregex,bmb.s + j - 1,(i - j + 1))) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   528
+      if (!stralloc_0(&matchedregex)) die_nomem();      
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   529
+      return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   530
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   531
+    if (!(negate) && (x > 0)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   532
+      if (!stralloc_copyb(&matchedregex,bmb.s + j,(i - j))) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   533
+      if (!stralloc_0(&matchedregex)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   534
+      return 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   535
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   536
+    j = i + 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   537
+    negate = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   538
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   539
   return 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   540
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   541
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   542
@@ -218,7 +299,9 @@ int addrallowed()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   543
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   544
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   545
 int seenmail = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   546
-int flagbarf; /* defined if seenmail */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   547
+int flagbarfbmf; /* defined if seenmail */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   548
+int flagbarfbmt;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   549
+int flagbarfbhelo;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   550
 stralloc mailfrom = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   551
 stralloc rcptto = {0};
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   552
 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   553
@@ -226,11 +309,13 @@ void smtp_helo(arg) char *arg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   554
 {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   555
   smtp_greet("250 "); out("\r\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   556
   seenmail = 0; dohelo(arg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   557
+  if (bhelook) flagbarfbhelo = bmcheck(BMCHECK_BHELO);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   558
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   559
 void smtp_ehlo(arg) char *arg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   560
 {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   561
   smtp_greet("250-"); out("\r\n250-PIPELINING\r\n250 8BITMIME\r\n");
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   562
   seenmail = 0; dohelo(arg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   563
+  if (bhelook) flagbarfbhelo = bmcheck(BMCHECK_BHELO);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   564
 }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   565
 void smtp_rset()
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   566
 {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   567
@@ -240,7 +325,11 @@ void smtp_mail(arg) char *arg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   568
 void smtp_mail(arg) char *arg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   569
 {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   570
   if (!addrparse(arg)) { err_syntax(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   571
-  flagbarf = bmfcheck();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   572
+  flagbarfbmf = 0; /* bmcheck is skipped for empty envelope senders */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   573
+  if ((bmfok) && (addr.len != 1)) flagbarfbmf = bmcheck(BMCHECK_BMF);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   574
+  if ((!flagbarfbmf) && (bmfnrok) && (addr.len != 1) && (!relayclient)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   575
+    flagbarfbmf = bmcheck(BMCHECK_BMFNR);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   576
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   577
   seenmail = 1;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   578
   if (!stralloc_copys(&rcptto,"")) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   579
   if (!stralloc_copys(&mailfrom,addr.s)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   580
@@ -250,7 +339,37 @@ void smtp_rcpt(arg) char *arg; {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   581
 void smtp_rcpt(arg) char *arg; {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   582
   if (!seenmail) { err_wantmail(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   583
   if (!addrparse(arg)) { err_syntax(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   584
-  if (flagbarf) { err_bmf(); return; }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   585
+  if (flagbarfbhelo) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   586
+    if (logregex) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   587
+      strerr_warn6("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   588
+    } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   589
+      strerr_warn4("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   590
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   591
+    err_bhelo();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   592
+    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   593
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   594
+  if (flagbarfbmf) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   595
+    if (logregex) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   596
+      strerr_warn6("qmail-smtpd: badmailfrom: <",mailfrom.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   597
+    } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   598
+      strerr_warn4("qmail-smtpd: badmailfrom: <",mailfrom.s,"> at ",remoteip,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   599
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   600
+    err_bmf();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   601
+    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   602
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   603
+  if (bmtok) flagbarfbmt = bmcheck(BMCHECK_BMT);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   604
+  if ((!flagbarfbmt) && (bmtnrok) && (!relayclient)) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   605
+    flagbarfbmt = bmcheck(BMCHECK_BMTNR);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   606
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   607
+  if (flagbarfbmt) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   608
+    if (logregex) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   609
+      strerr_warn6("qmail-smtpd: badmailto: <",addr.s,"> at ",remoteip," matches pattern: ",matchedregex.s,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   610
+    } else {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   611
+      strerr_warn4("qmail-smtpd: badmailto: <",addr.s,"> at ",remoteip,0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   612
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   613
+    err_bmt();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   614
+    return;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   615
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   616
   if (relayclient) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   617
     --addr.len;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   618
     if (!stralloc_cats(&addr,relayclient)) die_nomem();
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   619
diff -r 1510847ae5bf qregex.c
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   620
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   621
+++ b/qregex.c	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   622
@@ -0,0 +1,57 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   623
+/*
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   624
+ * qregex (v2)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   625
+ * $Id: qregex.c,v 2.1 2001/12/28 07:05:21 evan Exp $
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   626
+ *
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   627
+ * Author  : Evan Borgstrom (evan at unixpimps dot org)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   628
+ * Created : 2001/12/14 23:08:16
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   629
+ * Modified: $Date: 2001/12/28 07:05:21 $
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   630
+ * Revision: $Revision: 2.1 $
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   631
+ *
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   632
+ * Do POSIX regex matching on addresses for anti-relay / spam control.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   633
+ * It logs to the maillog
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   634
+ * See the qregex-readme file included with this tarball.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   635
+ * If you didn't get this file in a tarball please see the following URL:
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   636
+ *  http://www.unixpimps.org/software/qregex
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   637
+ *
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   638
+ * qregex.c is released under a BSD style copyright.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   639
+ * See http://www.unixpimps.org/software/qregex/copyright.html
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   640
+ *
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   641
+ * Note: this revision follows the coding guidelines set forth by the rest of
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   642
+ *       the qmail code and that described at the following URL.
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   643
+ *       http://cr.yp.to/qmail/guarantee.html
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   644
+ * 
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   645
+ */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   646
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   647
+#include <sys/types.h>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   648
+#include <regex.h>
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   649
+#include "qregex.h"
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   650
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   651
+#define REGCOMP(X,Y)    regcomp(&X, Y, REG_EXTENDED|REG_ICASE)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   652
+#define REGEXEC(X,Y)    regexec(&X, Y, (size_t)0, (regmatch_t *)0, (int)0)
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   653
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   654
+int matchregex(char *text, char *regex) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   655
+  regex_t qreg;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   656
+  int retval = 0;
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   657
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   658
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   659
+  /* build the regex */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   660
+  if ((retval = REGCOMP(qreg, regex)) != 0) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   661
+    regfree(&qreg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   662
+    return(-retval);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   663
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   664
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   665
+  /* execute the regex */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   666
+  if ((retval = REGEXEC(qreg, text)) != 0) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   667
+    /* did we just not match anything? */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   668
+    if (retval == REG_NOMATCH) {
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   669
+      regfree(&qreg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   670
+      return(0);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   671
+    }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   672
+    regfree(&qreg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   673
+    return(-retval);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   674
+  }
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   675
+
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   676
+  /* signal the match */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   677
+  regfree(&qreg);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   678
+  return(1);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   679
+}
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   680
diff -r 1510847ae5bf qregex.h
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   681
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   682
+++ b/qregex.h	Thu Nov 01 16:24:02 2007 +0100
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   683
@@ -0,0 +1,5 @@
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   684
+/* simple header file for the matchregex prototype */
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   685
+#ifndef _QREGEX_H_
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   686
+#define _QREGEX_H_
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   687
+int matchregex(char *text, char *regex);
b375914441b2 mq init; added pristine patches + fix for qregex
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
   688
+#endif