diff options
Diffstat (limited to 'files/arts/software/Code/elektropost/validrcptto.cdb.patch.new')
| -rw-r--r-- | files/arts/software/Code/elektropost/validrcptto.cdb.patch.new | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/files/arts/software/Code/elektropost/validrcptto.cdb.patch.new b/files/arts/software/Code/elektropost/validrcptto.cdb.patch.new new file mode 100644 index 0000000..bbd1eb4 --- /dev/null +++ b/files/arts/software/Code/elektropost/validrcptto.cdb.patch.new | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | --- Makefile.old Mon Dec 4 03:33:09 2006 | ||
| 2 | +++ Makefile Mon Dec 4 03:35:01 2006 | ||
| 3 | @@ -1558,15 +1558,15 @@ | ||
| 4 | |||
| 5 | qmail-smtpd: \ | ||
| 6 | load qmail-smtpd.o rcpthosts.o commands.o timeoutread.o \ | ||
| 7 | -timeoutwrite.o ip.o ipme.o ipalloc.o strsalloc.o control.o constmap.o \ | ||
| 8 | +timeoutwrite.o ip.o ipme.o ipalloc.o subfderr.o strsalloc.o control.o constmap.o \ | ||
| 9 | received.o date822fmt.o now.o qmail.o spf.o dns.o cdb.a fd.a wait.a \ | ||
| 10 | -datetime.a getln.a open.a sig.a case.a env.a stralloc.a alloc.a substdio.a \ | ||
| 11 | +datetime.a getln.a open.a sig.a case.a env.a strerr.a stralloc.a alloc.a substdio.a \ | ||
| 12 | error.a str.a fs.a auto_qmail.o base64.o socket.lib dns.lib | ||
| 13 | ./load qmail-smtpd rcpthosts.o commands.o timeoutread.o \ | ||
| 14 | - timeoutwrite.o ip.o ipme.o ipalloc.o strsalloc.o control.o \ | ||
| 15 | + timeoutwrite.o ip.o ipme.o ipalloc.o subfderr.o strsalloc.o control.o \ | ||
| 16 | tls.o ssl_timeoutio.o ndelay.a -L/usr/lib -lssl -lcrypto \ | ||
| 17 | constmap.o received.o date822fmt.o now.o qmail.o spf.o dns.o cdb.a \ | ||
| 18 | - fd.a wait.a datetime.a getln.a open.a sig.a case.a env.a stralloc.a \ | ||
| 19 | + fd.a wait.a datetime.a getln.a open.a sig.a case.a env.a strerr.a stralloc.a \ | ||
| 20 | alloc.a substdio.a error.a fs.a auto_qmail.o base64.o \ | ||
| 21 | str.a `cat socket.lib` `cat dns.lib` | ||
| 22 | |||
| 23 | @@ -1579,7 +1579,7 @@ | ||
| 24 | substdio.h alloc.h auto_qmail.h control.h received.h constmap.h \ | ||
| 25 | error.h ipme.h ip.h ipalloc.h strsalloc.h ip.h gen_alloc.h ip.h qmail.h \ | ||
| 26 | substdio.h str.h fmt.h scan.h byte.h case.h env.h now.h datetime.h \ | ||
| 27 | -exit.h rcpthosts.h timeoutread.h timeoutwrite.h commands.h wait.h spf.h \ | ||
| 28 | +exit.h rcpthosts.h timeoutread.h timeoutwrite.h commands.h wait.h spf.h cdb.h uint32.h \ | ||
| 29 | fd.h base64.h | ||
| 30 | ./compile qmail-smtpd.c | ||
| 31 | |||
| 32 | --- qmail-smtpd.c.old Mon Dec 4 03:36:22 2006 | ||
| 33 | +++ qmail-smtpd.c Mon Dec 4 03:44:49 2006 | ||
| 34 | @@ -26,6 +26,8 @@ | ||
| 35 | #include "wait.h" | ||
| 36 | #include "fd.h" | ||
| 37 | #include "spf.h" | ||
| 38 | +#include "strerr.h" | ||
| 39 | +#include "cdb.h" | ||
| 40 | |||
| 41 | #define AUTHCRAM | ||
| 42 | #define MAXHOPS 100 | ||
| 43 | @@ -99,6 +101,7 @@ | ||
| 44 | int err_noauth() { out("504 auth type unimplemented (#5.5.1)\r\n"); return -1; } | ||
| 45 | int err_authabrt() { out("501 auth exchange cancelled (#5.0.0)\r\n"); return -1; } | ||
| 46 | int err_input() { out("501 malformed auth input (#5.5.4)\r\n"); return -1; } | ||
| 47 | +void err_vrt() { out("553 sorry, this recipient is not in my validrcptto list (#5.7.1)\r\n"); } | ||
| 48 | |||
| 49 | stralloc greeting = {0}; | ||
| 50 | stralloc spflocal = {0}; | ||
| 51 | @@ -139,6 +142,7 @@ | ||
| 52 | int bmfok = 0; | ||
| 53 | stralloc bmf = {0}; | ||
| 54 | struct constmap mapbmf; | ||
| 55 | +int vrtfd = -1; | ||
| 56 | |||
| 57 | void setup() | ||
| 58 | { | ||
| 59 | @@ -155,6 +159,9 @@ | ||
| 60 | |||
| 61 | if (rcpthosts_init() == -1) die_control(); | ||
| 62 | |||
| 63 | + vrtfd = open_read("control/validrcptto.cdb"); | ||
| 64 | + if (-1 == vrtfd) if (errno != error_noent) die_control(); | ||
| 65 | + | ||
| 66 | bmfok = control_readfile(&bmf,"control/badmailfrom",0); | ||
| 67 | if (bmfok == -1) die_control(); | ||
| 68 | if (bmfok) | ||
| 69 | @@ -269,6 +276,60 @@ | ||
| 70 | return 0; | ||
| 71 | } | ||
| 72 | |||
| 73 | +int vrtcheck() | ||
| 74 | +{ | ||
| 75 | + int j,k,r; | ||
| 76 | + uint32 dlen; | ||
| 77 | + stralloc laddr = {0}; | ||
| 78 | + | ||
| 79 | + stralloc user = {0}; | ||
| 80 | + stralloc adom = {0}; | ||
| 81 | + stralloc utry = {0}; | ||
| 82 | + | ||
| 83 | + if (-1 == vrtfd) return 1; | ||
| 84 | + | ||
| 85 | + /* lowercase whatever we were sent */ | ||
| 86 | + if (!stralloc_copy(&laddr,&addr)) die_nomem() ; | ||
| 87 | + case_lowerb(laddr.s,laddr.len); | ||
| 88 | + | ||
| 89 | + /* exact match? */ | ||
| 90 | + r = cdb_seek(vrtfd,laddr.s,laddr.len-1,&dlen) ; | ||
| 91 | + if (r>0) return r; | ||
| 92 | + | ||
| 93 | + j = byte_rchr(laddr.s,laddr.len,'@'); | ||
| 94 | + if (j < laddr.len) | ||
| 95 | + { | ||
| 96 | + /* start "-default" search loop */ | ||
| 97 | + stralloc_copyb(&user,laddr.s,j) ; | ||
| 98 | + stralloc_copyb(&adom,laddr.s+j,laddr.len-j-1); | ||
| 99 | + | ||
| 100 | + while(1) | ||
| 101 | + { | ||
| 102 | + k = byte_rchr(user.s,user.len,'-'); | ||
| 103 | + if (k >= user.len) break ; | ||
| 104 | + | ||
| 105 | + user.len = k+1; | ||
| 106 | + stralloc_cats(&user,"default"); | ||
| 107 | + | ||
| 108 | + stralloc_copy(&utry,&user); | ||
| 109 | + stralloc_cat (&utry,&adom); | ||
| 110 | + stralloc_0(&utry); | ||
| 111 | + | ||
| 112 | + r = cdb_seek(vrtfd,utry.s,utry.len-1,&dlen); | ||
| 113 | + if (r>0) return r; | ||
| 114 | + | ||
| 115 | + user.len = k ; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /* try "@domain" */ | ||
| 119 | + r = cdb_seek(vrtfd,laddr.s+j,laddr.len-j-1,&dlen) ; | ||
| 120 | + if (r>0) return r; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + return 0; | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | + | ||
| 127 | int addrallowed() | ||
| 128 | { | ||
| 129 | int r; | ||
| 130 | @@ -280,7 +341,6 @@ | ||
| 131 | return r; | ||
| 132 | } | ||
| 133 | |||
| 134 | - | ||
| 135 | int seenmail = 0; | ||
| 136 | int flagbarf; /* defined if seenmail */ | ||
| 137 | int flagbarfspf; | ||
| 138 | @@ -402,8 +462,14 @@ | ||
| 139 | if (!stralloc_cats(&addr,relayclient)) die_nomem(); | ||
| 140 | if (!stralloc_0(&addr)) die_nomem(); | ||
| 141 | } | ||
| 142 | - else | ||
| 143 | + else { | ||
| 144 | if (!addrallowed()) { err_nogateway(); return; } | ||
| 145 | + if (!vrtcheck()) { | ||
| 146 | + strerr_warn4("qmail-smtpd: not in validrcptto: ",addr.s, | ||
| 147 | + " at ",remoteip,0); | ||
| 148 | + err_vrt(); return; | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | if (!stralloc_cats(&rcptto,"T")) die_nomem(); | ||
| 152 | if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); | ||
| 153 | if (!stralloc_0(&rcptto)) die_nomem(); | ||
