- Timestamp:
- 12/14/20 16:48:13 (4 years ago)
- Branches:
- master
- Children:
- 31fd825
- Parents:
- 6e9c61f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
npl/mailserver/netqmail/roberto-netqmail-1.06.patch-latest
r6e9c61f ra051af0 1 v. 2018.04.03 2 Combined patch for netqmail-1.06 by Roberto Puzzanghera [roberto dot puzzanghera at sagredo dot eu] 3 More info at http://notes.sagredo.eu/node/82 4 ========================================================================================================== 5 6 = This patch puts together 7 * Erwin Hoffmann's qmail-authentication patch v. 0.8.3 (23.08.2015), which updates the patches provided by 8 Krysztof Dabrowski and Bjoern Kalkbrenner. 9 It provides cram-md5, login, plain authentication support for qmail-smtpd and qmail-remote. 10 http://www.fehcom.de/qmail/smtpauth.html##PATCHES 11 * Frederik Vermeulen's qmail-tls patch v. 20160908 12 implements SSL or TLS encrypted and authenticated SMTP. 13 http://inoa.net/qmail-tls/ 14 The file update_tmprsadh was modified to chown all .pem files to vpopmail. 15 * Marcel Telka's force-tls patch v. 2016.05.15 16 optionally gets qmail to require TLS before authentication to improve security. 17 You have to declare FORCETLS=0 if you want to allow the auth without TLS 18 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/roberto-netqmail-1.06_force-tls.patch-2012.10.28 19 * Antonio Nati's chkuser patch v. 2.0.9 20 performs, among the other things, a check for the existence of recipients during the SMTP conversation, 21 bouncing emails of fake senders. 22 http://www.interazioni.it/opensource/chkuser/ 23 * Flavio Curti's qmail-queue-custom-error patch 24 enables simscan and qmail-dkim to return the appropriate message for each e-mail it refuses to deliver. 25 https://no-way.org/uploads/qmail-error/ 26 * Christophe Saout's qmail-SPF rc5 patch 27 Modified by Manvendra Bhangui to make it IPv4-mapped IPv6 addresses compliant. 28 checks incoming mails inside the SMTP daemon, add Received-SPF lines and optionally block undesired transfers. 29 http://www.saout.de/misc/spf/ 30 * Marcelo Coelho's qmail-SRS patch 31 implements Sender Rewriting Scheme fixing SPF break upon email forwarding. 32 http://www.mco2.com.br/opensource/qmail/srs/ 33 * Christopher K. Davis' oversize dns patch 34 enables qmail to handle large DNS packets. 35 http://www.ckdhr.com/ckd/qmail-103.patch 36 * Jul's reread-concurrency v.2 patch 37 rereads control/concurrencylocal and control/concurrencyremote files when qmail-send receives a HUP signal. 38 http://js.hu/package/qmail/index.html 39 * Johannes Erdfelt's Big Concurrency patch 40 sets the spawn limit above 255 41 http://qmail.org/big-concurrency.patch 42 * Mihai Secasiu's Big Concurrency fix v.1.0 patch 43 fixes a compiler error if you set concurrency higher than 509 in conf-spawn. 44 http://patchlog.com/linux/qmail-big-concurrency/ 45 * Bill Shupp's netqmail-maildir++.patch 46 adds maildirquota support to qmail-pop3d and qmail-local. 47 Fixed a bug where the filesize part of the S=<filesize> component of the Maildir++ compatible filename is wrong (tx MG). 48 More info here: http://notes.sagredo.eu/en/qmail-notes-185/installing-dovecot-and-sieve-on-a-vpopmail-qmail-server-28.html#comment995 49 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/netqmail-maildir.patch 50 * Kyle B. Wheeler's "Better qmail-smtpd Logging" v.4 (05 Jan 2010) patch 51 facilitates diagnostics of qmail-smtpd logging its actions and decisions (search for a line with qmail-smtp:) 52 http://www.memoryhole.net/qmail/#logging 53 * John Simpson's (?) Greeting delay patch 54 adds a user-definable delay after SMTP clients have initiated SMTP sessions, prior to qmail-smtpd responding 55 with "220 ESMTP". It can reject connections from clients which tried to send commands before greeting. 56 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-greetdelay.patch 57 * Manvendra Bhangui's DKIM and SURBL filter v.1.22 patch 58 adds DKIM signing & verification and SURBL filtering support to qmail. 59 qmail-dk is based on Russ Nelson's patch: http//:www.qmail.org/qmail-1.03-dk-0.54.patch 60 qmail-dkim uses hacked libdkim libraries from libdkim project at http://libdkim.sourceforge.net/ 61 surbfilter is built on djb functions and some functions have been ruthlessly borrowed from qmail surbl 62 interface by Pieter Droogendijk and the surblhost program at http://surblhost.sourceforge.net/ 63 (file hier.c modified to chown /var/qmail/control/cache and subdirs to vpopmail) 64 http://sourceforge.net/projects/indimail/files/netqmail-addons/qmail-dkim-1.0/ 65 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/ANNOUNCE.surblfilter 66 * Claudio Jeker and Andre Oppermann's EXTTODO patch (release 5. Jan. 2003) 67 addresses a problem known as the silly qmail (queue) problem 68 http://www.nrg4u.com/qmail/ext_todo-20030105.patch 69 * Russell Nelson's big-todo patch 70 makes qmail use a hashing mechanism in the todo folder similar to that used in the rest of the queue 71 http://www.qmail.org/big-todo.103.patch 72 * Stephane Cottin's qmail-inject-null-sender patch (let's call it in this way) 73 prevents qmail-inject from rewriting the null sender, fixing an issue with sieve vacation/reject messages. 74 More info here: http://www.dovecot.org/list/dovecot/2009-June/040811.html 75 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-inject-null-sender.patch 76 * Russell Nelson's (modified by Charles Cazabon) doublebounce-trim patch, which updates the original 77 version by Russel Nelson 78 prevents double bounces from hitting your queue a second time provided that you delete the first line 79 from /var/qmail/control/doublebounceto 80 http://qmail.org/doublebounce-trim.patch 81 * Will Harris' esmtp-size patch 82 enables qmail-smtpd to reject messages if they're larger than the maximum number of bytes allowed 83 according to the /var/qmail/control/databytes control file. 84 http://will.harris.ch/qmail-smtpd.c.diff 85 * Inter7's qmail-taps-extended patch 86 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-tap.diff 87 Extended by Michai Secasiu (http://patchlog.com/patches/qmail-taps-extended/) 88 Provides the ability to archive each email that flows through the system. 89 Archiving only messages from or to certain email addresses is possible as well. 90 * Rolf Eike Beer's qmail-remote CRLF patch 91 enables qmail-remote to handle CR properly, always sending the line breaks as CRLF and avoiding to 92 double the CR (like qmail-remote normally does) 93 http://opensource.sf-tec.de/qmail/ 94 * Andy Repton's outgoingip patch (adjusted by Sergio Gelato) 95 by default all outgoing emails are sent through the first IP address on the interface. In case of a multiple 96 IP server this patch makes qmail send outgoing emails with the IP eventually stored in control/outgoingip. 97 The ehlo domain is NOT modified by this patch. 98 http://www.qmail.org/outgoingip.patch 99 Robbie Walker provided a patch to correct qmail-qmqpc.c's call to timeoutconn(), because the function 100 signature was modified by the original outgoingip patch 101 http://notes.sagredo.eu/node/82#comment-373 102 * Iain Patterson's qmail-smtpd pid, qp log patch 103 makes qmail-smtpd log a line similar to the following: 104 @4000000039b89c95026a89b4 mail recv: pid 8155 from <name@domain.xy> qp 8157 105 The pid allows you to match the message up with a given tcpserver process and the qp lets you find a 106 particular delivery. 107 http://iain.cx/qmail/patches.html#smtpd_pidqp 108 * Jonathan de Boyne Pollard's any-to-cname patch 109 avoids qmail getting large amounts of DNS data we have no interest in and that may overflow our response 110 buffer. 111 http://www.memoryhole.net/qmail/#any-to-cname 112 * Matthias Andree's qmail-rfc2821 patch 113 makes qmail rfc2821 compliant 114 http://www-dt.e-technik.uni-dortmund.de/~ma/qmail/patch-qmail-1.03-rfc2821.diff 115 * Jonathan de Boyne Pollard's smtpd-502-to-500 patch 116 makes qmail rfc2821 compliant 117 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/smtpd-502-to-500.patch 118 * Fabio Busatto's qmail-dnsbl patch 119 allows you to reject spam and virus looking at the sender's ip address. 120 Modified by Luca Franceschini to add support for whitelists, TXT and A queries, configurable return codes 121 451 or 553 with custom messages 122 http://qmail-dnsbl.sourceforge.net/ 123 * Scott Gifford's qmail-moreipme patch v. 0.6 124 prevents a problem caused by an MX or other mail routing directive instructing qmail to connect to 125 itself without realizing it's connecting to itself, saving CPU time. 126 http://www.suspectclass.com/sgifford/qmail/qmail-1.03-moreipme.README 127 http://www.suspectclass.com/sgifford/qmail/qmail-1.03-moreipme-0.6.patch 128 * Alex Nee's qmail-hide-ip-headers patch 129 It will hide your Private or Public IP in the email Headers when you are sending Mail as a Relay Client. 130 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-hide-ip-headers.patch 131 * John Saunders' qmail-date-localtime patch 132 causes the various qmail programs to generate date stamps in the local timezone. 133 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-date-localtime.patch 134 * Dean Gaudet's qmail-liberal-lf patch v. 0.95 135 allow qmail-smtpd to accept messages that are terminated with a single \n instead of the required \r\n 136 sequence. 137 http://www.arctic.org/~dean/patches/qmail-0.95-liberal-lf.patch 138 * Michael Samuel's maxrcpt patch 139 allows you to set a limit on how many recipients are specified for any one email message by setting 140 control/maxrcpt. RFC 2821 section 4.5.3.1 says that an MTA MUST allow at least 100 recipients for each 141 message, since this is one of the favourite tricks of the spammer. 142 http://copilotco.com/mail-archives/qmail.1997/msg03066.html 143 * Inter7's qmail-eMPF patch 144 More info: http://www.qmailwiki.org/EMPF 145 eMPF follows a set of administrator-defined rules describing who can message whom. With this, companies can segregate 146 various parts of their organizations email activities, as well as provide a variety of security-enhancing services. 147 * qregex (by Andrew St. Jean http://www.arda.homeunix.net/downloads-qmail/, contributors: Jeremy Kitchen, Alex Pleiner, 148 Thanos Massias. Original patch by Evan Borgstrom) 149 adds the ability to match address evelopes via Regular Expressions (REs) in the qmail-smtpd process. 150 Added new control file 'badhelonorelay', control/badmailto renamed control/badrcptto (Tx Luca Franceschini). 151 * brtlimit 152 Luca Franceschini derived this patch from http://netdevice.com/qmail/patch/goodrcptto-12.patch 153 added control/brtlimit and BRTLIMIT variable to limit max invalid recipient errors before closing the connection (man qmail-control) 154 * validrcptto 155 http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/validrcptto.README 156 Luca Franceschini grabbed the code from several patches with additional features: http://qmail.jms1.net/patches/validrcptto cdb.shtml, 157 http://netdevice.com/qmail/patch/goodrcptto-ms-12.patch, http://patch.be/qmail/badrcptto.html 158 It works in conjunction with chkuser with both cdb and mysql accounts. 159 * reject-relay-test by Russell Nelson 160 http://qmail.org/qmail-smtpd-relay-reject 161 It gets qmail to reject relay probes generated by so-called anti-spammers. These relay probes have '!', '%' and '@' 162 in the local (username) part of the address. 163 * Luca Franceschini 164 added DISABLETLS environment variable, useful if you want to disable TLS on a desired port 165 added FORCEAUTHMAILFROM environment variable to REQUIRE that authenticated user and 'mail from' are identical 166 added SMTPAUTHMETHOD, SMTPAUTHUSER and SMTP_AUTH_USER env variables for external plugins (see http://qmail-spp.sourceforge.net/doc/) 167 * fixed little bug in 'mail from' address handling 168 patch by Andre Opperman at http://qmail.cr.yp.narkive.com/kBry6GJl/bug-in-qmail-smtpd-c-addrparse-function 169 * Luca Franceschini's qlog patch 170 smtpd logging with fixed format. An entry 'qlogenvelope' is generated after accepting or rejecting every recipients in the envelope phase. 171 * Luca Franceschini's reject null senders patch 172 useful in special cases if you temporarily need to reject the null sender (although breaks RFC compatibility). 173 You just need to put 1 (actually any number different from 0) in your control/rejectnullsenders to reject the null sender with 421 error message. 174 * dnscname patch 175 Removes CNAME check in order to avoid getting large amounts of data of no interest in and that may overflow the response buffer. 176 https://lists.gt.net/qmail/users/138190 177 * Luca Franceschini's rcptcheck patch 178 (based on original patch from Jay Soffian (http://www.soffian.org/downloads/qmail/qmail-smtpd-doc.html) 179 Originally designed for the purpose of receipt validation, it can also be used to limit the numbr of email a given IP and/or auth-user and/or domain che send 180 in a given time interval. It has to be used in conjuction with the rcptcheck-overlimit.sh LF's script http://notes.sagredo.eu/files/qmail/rcptcheck-overlimit.sh 181 http://notes.sagredo.eu/files/qmail/patches/rcptcheck.patch 182 183 = Disclaimer 184 This patch comes with the usual warranty: it works for me, it may not work for you, 185 use at your own risk etc. etc. :) 186 Comments, suggestions, criticisms are always welcome! 187 188 = Usage 189 190 * Install libdomainkeys 191 wget http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/tar/libdomainkeys-0.69.tar.gz 192 tar xzf libdomainkeys-0.69.tar.gz 193 wget http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/libdomainkeys-0.69.diff 194 cd libdomainkeys-0.69 195 chown -R root.root . 196 patch < ../libdomainkeys-0.69.diff 197 make 198 cp libdomainkeys.a /usr/lib 199 200 * Install libsrs2 201 wget http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/tar/libsrs2-1.0.18.tar.gz 202 tar xzf libsrs2-1.0.18.tar.gz 203 cd libsrs2-1.0.18 204 ./configure 205 make 206 make install 207 ldconfig 208 cd ../ 209 210 * Apply the patch and compile 211 wget http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/roberto-netqmail-1.06.patch-latest.gz 212 wget http://qmail.org/netqmail-1.06.tar.gz 213 tar xzf netqmail-1.06.tar.gz 214 cd netqmail-1.06 215 chown -R root.root . 216 gunzip -c ../roberto-netqmail-1.06.patch-latest.gz | patch 217 make 218 make setup check 219 220 * You have to export SMTPAUTH in your run file if you want to do the auth 221 222 * You have to export SURBL=1 in your run file if you want to enable SURBL 223 224 * /var/qmail/control/cache must be owned by the user who runs qmail-smtpd, vpopmail.vchkpwd in my case. 225 Change the permissions according to your qmail configuration. 226 227 ================================================================================================================= 228 229 = Changelog 230 231 2018.04.03 232 -DKIM patch updated to v. 1.22 233 * openssl 1.1.0 port 234 * various improvements, bug fixes 235 236 2018.01.10 237 -maildir++ 238 * fixed a bug where the filesize part of the S=<filesize> component of the Maildir++ compatible filename 239 is wrong (tx MG). More info here: http://notes.sagredo.eu/en/qmail-notes-185/installing-dovecot-and-sieve-on-a-vpopmail-qmail-server-28.html#comment995 240 -qmail-queue-extra 241 * removed, because it was causing more problems than advantages, as the domain of the log@yourdomain.tld 242 had to match the system domain inside control/me and shouldn't be a virtual domain as well. 243 244 2017.10.11 (tx Luca Franceschini) 245 -qlogfix 246 * log strings should terminate with \n to avoid trailing ^M using splogger 247 * bug reporting custom errors from qmail-queue in qlog 248 -added dnscname patch 249 -added rcptcheck patch 250 251 2017.08.18 252 -qmail-smtpd now retains authentication upon rset 253 (tx to Andreas http://notes.sagredo.eu/qmail-notes-185/smtp-auth-qmail-tls-forcetls-patch-for-qmail-84.html#comment750) 254 255 2017-05-14 256 -DKIM patch updated to v. 1.20 257 It now manages long TXT records, avoiding the rejection of some hotmail.com messages. 258 259 2016-12-19 260 -Several new patches and improvements added (thanks to Luca Franceschini) 261 More info here http://notes.sagredo.eu/node/178 262 -qregex patch 263 -brtlimit patch 264 -validrcptto patch 265 -rbl patch (updates qmail-dnsbl patch) 266 -reject-relay-test patch 267 -added DISABLETLS environment variable, useful if you want to disable TLS on a desired port 268 -added FORCEAUTHMAILFROM environment variable to REQUIRE that authenticated user and 'mail from' are identical 269 -fixed little bug in 'mail from' address handling (patch by Andre Opperman at http://qmail.cr.yp.narkive.com/kBry6GJl/bug-in-qmail-smtpd-c-addrparse-function) 270 -added SMTPAUTHMETHOD, SMTPAUTHUSER and SMTP_AUTH_USER env variables for external plugins 271 -qlog patch 272 -reject null senders patch 273 -bouncecontrolmime patch 274 -qmail-taps-extended (updates qmail-tap) 275 276 2016-12-02 277 -fixed BUG in qmail-remote.c: in case of remote server who doesn't allow EHLO the response for an alternative 278 HELO was checked twice, making the connection to die. (Thanks to Luca Franceschini) 279 Patch applied: http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/fix_sagredo_remotehelo.patch 280 281 2016-09-19 282 -qmail-tls patch updated to v. 20160918 283 * bug: qmail-remote accepting any dNSName, without checking that is matches (E. Surovegin) 284 * bug: documentation regarding RSA and DH keys (K. Peter, G. A. Bofill) 285 286 2016-05-15 287 -force-tls patch improved (a big thanks to Marcel Telka). Now qmail-smtpd avoids to write the auth verb if the 288 the STARTTLS command was not sent by the client 289 290 2016-03-09 291 -DKIM patch upgraded to v. 1.19 292 * verification will not fail when a dkim signature does not include the subject provided that the 293 UNSIGNED_SUBJECT environment variable is declared. 294 295 2015-12-26 296 -qmail-tls patch updated to v. 20151215 297 * typo in #if OPENSSL_VERSION_NUMBER for 2015-12-08 patch release (V. Smith) 298 * add ECDH to qmail-smtpd 299 * increase size of RSA and DH pregenerated keys to 2048 bits 300 * qmail-smtpd sets RELAYCLIENT if relaying allowed by cert 301 more info at http://inoa.net/qmail-tls/ 302 303 2015-12-15 304 -DKIM patch by Manvendra Bhangui updated to v. 1.18 305 306 2015-10-03 307 -qmail-authentication: updated to v. 0.8.3 308 309 2015-08-08 310 -fixed a bug on qmail-remote.c that was causing the sending of an additionale ehlo greeting (thanks to Cristoph Grover) 311 312 2015-04-11 313 -qmail-authentication: updated to v. 0.8.2 314 -qmail-tls: upgraded to v. 20141216 (POODLE vulnerability fixed) 315 316 2015-03-28 317 -added qmail-eMPF patch 318 319 2014-11-19 320 -security fix: the SSLv3 connection is now switched off 321 322 2014-11-15 323 -modified the QUEUE_EXTRA variable in extra.h to improve the qmail-send's log 324 325 2014-04-14 326 -added maxrcpt patch 327 328 2014-03-10 329 -added qmail-0.95-liberal-lf patch 330 331 2013-12-30 332 -added qmail-srs 333 -the character "=" is now considered valid in the sender address by chkuser in order to accept SRS 334 335 2013-12-18 336 -added qmail-date-localtime patch 337 338 2013-12-14 339 -added qmail-hide-ip patch 340 341 2013-12-10 342 -the original greetdelay by e.h. has been replaced with the improved patch by John Simpson. Now 343 communications trying to send commands before the greeting will be closed. Premature disconnections will be 344 logged as well. 345 -CHKUSER_SENDER_FORMAT enabled to reject fake senders without any domain declared (like <foo>) 346 -chkuser logging: I slightly modified the log line adding the variables' name just to facilitate its interpretation 347 -added qmail-moreipme patch 348 349 2013-12-07 350 -added qmail-dnsbl patch 351 352 2013-12-05 353 -added two patches to make qmail rfc2821 compliant 354 355 2013-11-23 356 -added any-to-cname patch 357 358 2013-09-27 359 -DKIM patch upgraded to v. 1.17. Defined -DHAVE_SHA_256 while compiling dkimverify.cpp in the Makefile. 360 This solved an issue while verifying signatures using sha256. 361 362 2013-09-16 363 -Minor fixes to the DKIM patch. 364 365 2013-09-13 366 -DKIM patch upgraded to v. 1.16. The signing at qmail-remote level has been revised by its author. 367 368 2013-08-25 369 -qmail-qmqpc.c call to timeoutconn() needed a correction because the function signature was modified by the 370 outgoingip patch. Thanks to Robbie Walker (diff here http://notes.sagredo.eu/node/82#comment-373) 371 372 2013-08-21 373 -fixed a bug in hier.c which caused the installation not to build properly the queue/todo dir structure (thanks to 374 Scott Ramshaw) 375 376 2013-08-18 377 -DKIM-SURBL patch by Manvendra Bhangui updated to v. 1.14 378 379 2013-08-12 380 -DKIM patch upgraded to v. 1.12. The new patch adds surblfilter functionality. 381 -added qmail-smtpd pid, qp log patch 382 383 2013-08-08 384 -qmail-SPF modified by Manvendra Bhangui to make it IPv6-mapped IPv4 addresses compliant. In order to have it 385 working with such addresses you have to patch tcpserver.c accordingly. You can use a patch fot ucspi-tcp6-0.98 386 by Manvendra Bhangui at http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/tcpserver-ipv6mapped_ipv4.patch 387 or wait for v. 0.99 relase of ucspi-tcp6 388 -added outgoingip patch 389 -added qmail-bounce patch 390 391 2013-03-31 392 qmail-auth updated to latest v. 0.8.1 Added authentication by recipient domain for qmail-remote. 393 Look at README.auth for further details 394 395 2013-02-11 396 some code adjustments in qmail-smtpd.c smtpd_ehlo() to restore total compatibility with esmtp-size patch 397 398 2013-02-08 399 qmail-auth updated to latest v. 0.7.6. Look at README.auth for further details 400 401 2013-01-28 402 fixed an issue on qmail-pop3d which was causing a double +OK after the pass command (thanks to Rakesh, Orbit 403 and Simplex for helping in testing and troubleshooting) 404 405 2013-01-06 406 environment variable GREETDELAY renamed to SMTPD_GREETDELAY 407 408 2012-10-31 409 qmail-auth updated to latest v. 0.7.5. Look at README.auth for further details 410 The qmail-forcetls patch was simplyfied accordingly. 411 You MUST export SMTPAUTH="" in your run file now. 412 413 2012-04-25 414 -added qmail-remote CRLF (thanks to Pierre Lauriente for the help on testing and troubleshooting) 415 The qmail-remote CRLF patch solved a problem of broken headers after sieve forwarding that was 416 caused by a bad handling of the CR (carriage return) by qmail-remote. 417 The issue is also reported here http://www.dt.e-technik.uni-dortmund.de/~ma/qmail-bugs.html 418 419 2012.04.16 420 -added qmail-tap 421 422 2012.02.08 423 -added smtp-size patch 424 425 2012.01.29 426 -added doublebounce-trim patch 427 428 2011.12.12 429 -file update_tmprsadh modified to chown the .pem files to vpopmail to avoid hang-ups during the smtp 430 conversation on port 587 caused by permission problems. 431 432 2011.10.06 433 -qmail-remote.c: fixed. It was not going into tls on authentication (thanks to Krzysztof Gajdemski) 434 -force-tls now quits if the starttls command is not provided when required (thanks to Jacekalex) 435 436 ================================================================================================================= 437 1 diff -ruN ../netqmail-1.06-original/CHANNELS netqmail-1.06/CHANNELS 2 --- ../netqmail-1.06-original/CHANNELS 1970-01-01 01:00:00.000000000 +0100 3 +++ netqmail-1.06/CHANNELS 2019-06-26 16:39:31.572826981 +0200 4 @@ -0,0 +1,100 @@ 5 +CHANNELS by Reed Sandberg 6 +Copyright (c) 2007-2008 The SMB Exchange, INC 7 + 8 +This patch is free software; you can redistribute it and/or modify 9 +it under the Artistic License. 10 + 11 +This patch for (net)qmail comes with NO WARRANTY. 12 + 13 +RELEASE: November 15, 2008 14 + 15 + 16 +qmail manages two different queues 17 +with different configurable concurrency settings (rates) based on a set 18 +of domains - those delivered locally (control files: locals, 19 +virtualdomains, concurrencylocal) and those delivered remotely (domains 20 +not listed in above control files and concurrencyremote). Luckily, 21 +qmail's author (DJB) spent some time abstracting the implementation of 22 +these channels and this patch advances the abstraction to add an 23 +arbitrary number of channels - each with a distinct set of domains and 24 +throttling capabilities. 25 + 26 +BIG PICTURE 27 +With ext_todo patch. Adapted from: 28 +EXTTODO by Claudio Jeker <jeker@n-r-g.com> and 29 +Andre Oppermann <opi@nrg4u.com> 30 +(c) 1998,1999,2000,2001,2002 Internet Business Solutions Ltd. 31 + 32 + 33 + +-------+ +-------+ +-------+ 34 + | clean | | clean | | logger| 35 + +--0-1--+ +--0-1--+ +---0---+ +-----------+ 36 + trigger ^ | ^ | | +->0,1 lspawn | 37 + | | v | v v / +-----------+ 38 + +-------+ v +--2-3--+ +--5-6--------------0-------+ / 39 + | | | | 0<--7 1,2<-+ 40 + | queue |--+--| todo | | send | 41 + | | | | 1-->8 3,4<-+ 42 + +-------+ +-------+ +--11,12---...-------X,Y----+ \ 43 + | | \ +-----------+ 44 + v v +->0,1 rspwan | 45 + +--0,1-+ +--0,1-+ +-----------+ 46 + |rspawn| ... |rspawn| 47 + +------+ +------+ 48 + 49 +Communication between qmail-send and qmail-todo 50 + 51 +todo -> send: 52 + D[01]{n}<mesgid>\0 53 + Start delivery for a new message with id <mesgid>. 54 + the character '0' or '1' indicates whether this message 55 + will go through the corresponding channel (false/true) 56 + by position where n is the number of channels. E.g. D1011<msgid>\0: 57 + means there are four channels, the first 2 are always 58 + the local and default remote channels, and the rest are 59 + an optional number of supplemental channels (defined 60 + at compile-time by conf-channels). So this message 61 + has a local recipient, and a recipient on the first and 62 + second supplemental channels. 63 + L<string>\0 64 + Dump string to the logger without adding additional \n or similar. 65 +send -> todo: 66 + H Got a SIGHUP, reread ~/control/locals, ~/control/virtualdomains, 67 + ~/control/concurrencyremote, ~/control/concurrencylocal, 68 + ~/control/concurrencysupplX, ~/control/supplsX 69 + X Quit ASAP. 70 + 71 +qmail-todo sends "\0" terminated messages whereas qmail-send just send one 72 +character to qmail-todo. 73 + 74 + 75 +CAVEATS 76 +qmail-qread ignores all supplemental channels - contributions are welcome! 77 + 78 +Supplemental channels use qmail-rspawn for remote recipients only. 79 + 80 +Dynamic throttling and resource limits 81 +File descriptor limits are imposed on a per-process basis (FD_SET), on a 82 +per-account basis (ulimit -n, /etc/security/limits.conf on Linux, pam limits, etc.) 83 +and then on a system-wide basis by the OS (/proc/sys/fs/file-max on Linux, etc). 84 +concurrencyremote, concurrencysupplX, etc are each subject to the hard limit in 85 +conf-spawn, which in turn is bounded by per-process limits. Note that this limit 86 +applies separately to each queue, not to all queues in total. The sum of all 87 +concurrency limits for each queue in total is bounded on a per-account basis 88 +(ulimit -n). These limits can easily be approached if you are running many 89 +supplemental channels. 90 + 91 +qmail double checks the concurrency limits on startup for each channel (using FD_SET) 92 +and silently curbs them if needed because bad things happen if this limit is breached. 93 +If you're sending qmail-send a HUP signal after editing concurrency limits (dynamic 94 +throttling) be aware that qmail's builtin checks can be circumvented, here's what 95 +qmail's author has to say on the subject (from chkspawn.c): 96 +This means that the qmail daemons could crash if you set the run-time concurrency higher 97 +than [the per-process limit]. 98 + 99 +Even if the per-process limits are in check, per-account and system-wide file descriptor 100 +limits may still cause bad things to happen if you're not careful (you've been warned!). 101 + 102 +Enjoy! 103 +Reed Sandberg 104 + 438 105 diff -ruN ../netqmail-1.06-original/CHKUSER.automatic_patching netqmail-1.06/CHKUSER.automatic_patching 439 106 --- ../netqmail-1.06-original/CHKUSER.automatic_patching 1970-01-01 01:00:00.000000000 +0100 440 +++ netqmail-1.06/CHKUSER.automatic_patching 201 6-11-22 21:04:38.804137924 +0100107 +++ netqmail-1.06/CHKUSER.automatic_patching 2019-02-27 20:57:13.376025224 +0100 441 108 @@ -0,0 +1,94 @@ 442 109 +Chkuser 2.0.9 automatic patching … … 536 203 diff -ruN ../netqmail-1.06-original/CHKUSER.changelog netqmail-1.06/CHKUSER.changelog 537 204 --- ../netqmail-1.06-original/CHKUSER.changelog 1970-01-01 01:00:00.000000000 +0100 538 +++ netqmail-1.06/CHKUSER.changelog 201 6-11-22 21:04:38.804137924 +0100205 +++ netqmail-1.06/CHKUSER.changelog 2019-02-27 20:57:13.376025224 +0100 539 206 @@ -0,0 +1,183 @@ 540 207 + … … 723 390 diff -ruN ../netqmail-1.06-original/CHKUSER.copyright netqmail-1.06/CHKUSER.copyright 724 391 --- ../netqmail-1.06-original/CHKUSER.copyright 1970-01-01 01:00:00.000000000 +0100 725 +++ netqmail-1.06/CHKUSER.copyright 201 6-11-22 21:04:38.804137924 +0100392 +++ netqmail-1.06/CHKUSER.copyright 2019-02-27 20:57:13.376025224 +0100 726 393 @@ -0,0 +1,15 @@ 727 394 + … … 742 409 diff -ruN ../netqmail-1.06-original/CHKUSER.log_format netqmail-1.06/CHKUSER.log_format 743 410 --- ../netqmail-1.06-original/CHKUSER.log_format 1970-01-01 01:00:00.000000000 +0100 744 +++ netqmail-1.06/CHKUSER.log_format 201 6-11-22 21:04:38.804137924 +0100411 +++ netqmail-1.06/CHKUSER.log_format 2019-02-27 20:57:13.376025224 +0100 745 412 @@ -0,0 +1,69 @@ 746 413 + … … 815 482 diff -ruN ../netqmail-1.06-original/CHKUSER.manual_patching netqmail-1.06/CHKUSER.manual_patching 816 483 --- ../netqmail-1.06-original/CHKUSER.manual_patching 1970-01-01 01:00:00.000000000 +0100 817 +++ netqmail-1.06/CHKUSER.manual_patching 201 6-11-22 21:04:38.804137924+0100484 +++ netqmail-1.06/CHKUSER.manual_patching 2019-02-27 20:57:13.377025213 +0100 818 485 @@ -0,0 +1,182 @@ 819 486 +Chkuser 2.0 manual editing … … 1001 668 diff -ruN ../netqmail-1.06-original/CHKUSER.readme netqmail-1.06/CHKUSER.readme 1002 669 --- ../netqmail-1.06-original/CHKUSER.readme 1970-01-01 01:00:00.000000000 +0100 1003 +++ netqmail-1.06/CHKUSER.readme 201 6-11-22 21:04:38.804137924+0100670 +++ netqmail-1.06/CHKUSER.readme 2019-02-27 20:57:13.377025213 +0100 1004 671 @@ -0,0 +1,54 @@ 1005 672 +chkuser 2.0 - README … … 1059 726 diff -ruN ../netqmail-1.06-original/CHKUSER.running netqmail-1.06/CHKUSER.running 1060 727 --- ../netqmail-1.06-original/CHKUSER.running 1970-01-01 01:00:00.000000000 +0100 1061 +++ netqmail-1.06/CHKUSER.running 201 6-11-22 21:04:38.804137924+0100728 +++ netqmail-1.06/CHKUSER.running 2019-02-27 20:57:13.377025213 +0100 1062 729 @@ -0,0 +1,103 @@ 1063 730 + … … 1166 833 diff -ruN ../netqmail-1.06-original/FILES netqmail-1.06/FILES 1167 834 --- ../netqmail-1.06-original/FILES 2007-11-30 21:22:54.000000000 +0100 1168 +++ netqmail-1.06/FILES 201 6-11-22 21:03:57.061529799 +0100835 +++ netqmail-1.06/FILES 2019-06-26 16:39:31.573826970 +0200 1169 836 @@ -136,6 +136,8 @@ 1170 837 dnsip.c … … 1202 869 tryrsolv.c 1203 870 ip.h 1204 @@ -432,3 +439, 4@@871 @@ -432,3 +439,7 @@ 1205 872 tcp-environ.5 1206 873 constmap.h 1207 874 constmap.c 1208 875 +qmail-todo.c 876 +channels.g 877 +conf-channels 878 +CHANNELS 1209 879 diff -ruN ../netqmail-1.06-original/LICENSE.authentication netqmail-1.06/LICENSE.authentication 1210 880 --- ../netqmail-1.06-original/LICENSE.authentication 1970-01-01 01:00:00.000000000 +0100 1211 +++ netqmail-1.06/LICENSE.authentication 201 6-11-22 21:03:57.102528432+0100881 +++ netqmail-1.06/LICENSE.authentication 2019-02-27 20:57:13.377025213 +0100 1212 882 @@ -0,0 +1,43 @@ 1213 883 +AUTHOR … … 1256 926 diff -ruN ../netqmail-1.06-original/MakeArgs.c netqmail-1.06/MakeArgs.c 1257 927 --- ../netqmail-1.06-original/MakeArgs.c 1970-01-01 01:00:00.000000000 +0100 1258 +++ netqmail-1.06/MakeArgs.c 201 6-11-22 21:03:57.102528432+0100928 +++ netqmail-1.06/MakeArgs.c 2019-02-27 20:57:13.377025213 +0100 1259 929 @@ -0,0 +1,144 @@ 1260 930 +/* … … 1404 1074 diff -ruN ../netqmail-1.06-original/Makefile netqmail-1.06/Makefile 1405 1075 --- ../netqmail-1.06-original/Makefile 2007-11-30 21:22:54.000000000 +0100 1406 +++ netqmail-1.06/Makefile 201 8-04-03 15:05:13.390470191+02001076 +++ netqmail-1.06/Makefile 2019-06-26 16:48:00.745225709 +0200 1407 1077 @@ -1,5 +1,14 @@ 1408 1078 # Don't edit Makefile! Use conf-* for configuration. … … 1648 1318 1649 1319 fs.a: \ 1650 @@ -703,7 +754,7 @@ 1320 @@ -702,8 +753,15 @@ 1321 ./compile hfield.c 1651 1322 1652 1323 hier.o: \ 1653 1324 -compile hier.c auto_qmail.h auto_split.h auto_uids.h fmt.h fifo.h 1654 1325 - ./compile hier.c 1326 +compile hier.c auto_qmail.h auto_split.h auto_uids.h fmt.h fifo.h channels.h 1655 1327 + ./compile $(DEFINES) hier.c 1328 + 1329 +channels.h: \ 1330 +conf-channels channels.g 1331 + cat channels.g \ 1332 + | sed s}NUMCHANNELS}"`head -1 conf-channels`"}g \ 1333 + > channels.h 1334 + chmod 644 channels.h 1656 1335 1657 1336 home: \ 1658 1337 home.sh conf-qmail 1659 @@ -755,7 +806,7 @@ 1338 @@ -754,8 +812,8 @@ 1339 1660 1340 install-big.o: \ 1661 1341 compile install-big.c auto_qmail.h auto_split.h auto_uids.h fmt.h \ 1662 1342 -fifo.h 1663 1343 - ./compile install-big.c 1344 +fifo.h channels.h 1664 1345 + ./compile $(DEFINES) install-big.c 1665 1346 1666 1347 install.o: \ 1667 1348 compile install.c substdio.h strerr.h error.h open.h readwrite.h \ 1668 @@ -777,38 +8 28,52 @@1349 @@ -777,38 +835,52 @@ 1669 1350 ./compile ip.c 1670 1351 … … 1729 1410 load: \ 1730 1411 make-load warn-auto.sh systype 1731 @@ -890,6 +9 55,38 @@1412 @@ -890,6 +962,38 @@ 1732 1413 readwrite.h open.h headerbody.h maildir.h strerr.h 1733 1414 ./compile maildirwatch.c … … 1768 1449 warn-auto.sh mailsubj.sh conf-qmail conf-break conf-split 1769 1450 cat warn-auto.sh mailsubj.sh \ 1770 @@ -934,8 +103 1,9 @@1451 @@ -934,8 +1038,9 @@ 1771 1452 preline.0 condredirect.0 bouncesaying.0 except.0 maildirmake.0 \ 1772 1453 maildir2mbox.0 maildirwatch.0 qmail.0 qmail-limits.0 qmail-log.0 \ … … 1780 1461 mbox.0: \ 1781 1462 mbox.5 1782 @@ -1107,11 +12 05,80 @@1463 @@ -1107,11 +1212,80 @@ 1783 1464 | sed s}SPAWN}"`head -1 conf-spawn`"}g \ 1784 1465 > qmail-control.5 … … 1862 1543 qmail-getpw.0: \ 1863 1544 qmail-getpw.8 1864 @@ -1125,6 +129 2,28 @@1545 @@ -1125,6 +1299,28 @@ 1865 1546 | sed s}SPAWN}"`head -1 conf-spawn`"}g \ 1866 1547 > qmail-getpw.8 … … 1891 1572 compile qmail-getpw.c readwrite.h substdio.h subfd.h substdio.h \ 1892 1573 error.h exit.h byte.h str.h case.h fmt.h auto_usera.h auto_break.h \ 1893 @@ -1136,15 +13 25,16 @@1574 @@ -1136,15 +1332,16 @@ 1894 1575 nroff -man qmail-header.5 > qmail-header.0 1895 1576 … … 1911 1592 qmail-inject.0: \ 1912 1593 qmail-inject.8 1913 @@ -1171,15 +136 1,20 @@1594 @@ -1171,15 +1368,20 @@ 1914 1595 > qmail-limits.7 1915 1596 … … 1936 1617 qmail-local.0: \ 1937 1618 qmail-local.8 1938 @@ -1200,11 +1 395,11 @@1619 @@ -1200,11 +1402,11 @@ 1939 1620 qmail-lspawn: \ 1940 1621 load qmail-lspawn.o spawn.o prot.o slurpclose.o coe.o sig.a wait.a \ … … 1950 1631 qmail-lspawn.0: \ 1951 1632 qmail-lspawn.8 1952 @@ -1213,9 +14 08,22 @@1633 @@ -1213,9 +1415,22 @@ 1953 1634 qmail-lspawn.o: \ 1954 1635 compile qmail-lspawn.c fd.h wait.h prot.h substdio.h stralloc.h \ … … 1974 1655 load qmail-newmrh.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \ 1975 1656 stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o 1976 @@ -1269,11 +14 77,13 @@1657 @@ -1269,11 +1484,13 @@ 1977 1658 qmail-pop3d: \ 1978 1659 load qmail-pop3d.o commands.o case.a timeoutread.o timeoutwrite.o \ … … 1990 1671 qmail-pop3d.0: \ 1991 1672 qmail-pop3d.8 1992 @@ -1419,13 +16 29,13 @@1673 @@ -1419,13 +1636,13 @@ 1993 1674 nroff -man qmail-qstat.8 > qmail-qstat.0 1994 1675 … … 2010 1691 qmail-queue.0: \ 2011 1692 qmail-queue.8 2012 @@ -1439,14 +16 49,18 @@1693 @@ -1439,14 +1656,18 @@ 2013 1694 2014 1695 qmail-remote: \ … … 2033 1714 qmail-remote.0: \ 2034 1715 qmail-remote.8 2035 @@ -1455,7 +16 69,7 @@1716 @@ -1455,7 +1676,7 @@ 2036 1717 qmail-remote.o: \ 2037 1718 compile qmail-remote.c sig.h stralloc.h gen_alloc.h substdio.h \ … … 2042 1723 tcpto.h readwrite.h timeoutconn.h timeoutread.h timeoutwrite.h 2043 1724 ./compile qmail-remote.c 2044 @@ -1463,11 +16 77,11 @@1725 @@ -1463,11 +1684,11 @@ 2045 1726 qmail-rspawn: \ 2046 1727 load qmail-rspawn.o spawn.o tcpto_clean.o now.o coe.o sig.a open.a \ … … 2056 1737 qmail-rspawn.0: \ 2057 1738 qmail-rspawn.8 2058 @@ -1475, 20 +1689,21@@1739 @@ -1475,31 +1696,33 @@ 2059 1740 2060 1741 qmail-rspawn.o: \ … … 2070 1751 datetime.a case.a ndelay.a getln.a wait.a seek.a fd.a sig.a open.a \ 2071 1752 lock.a stralloc.a alloc.a substdio.a error.a str.a fs.a auto_qmail.o \ 2072 1753 -auto_split.o env.a 2073 1754 - ./load qmail-send qsutil.o control.o constmap.o newfield.o \ 1755 +auto_split.o env.a auto_spawn.o 2074 1756 + ./load qmail-send rcpthosts.o cdb.a srs.o qsutil.o control.o constmap.o newfield.o \ 2075 1757 prioq.o trigger.o fmtqfn.o quote.o now.o readsubdir.o \ … … 2077 1759 wait.a seek.a fd.a sig.a open.a lock.a stralloc.a alloc.a \ 2078 1760 - substdio.a error.a str.a fs.a auto_qmail.o auto_split.o env.a 2079 + substdio.a error.a str.a fs.a auto_qmail.o auto_split.o env.a \1761 + substdio.a error.a str.a fs.a auto_qmail.o auto_split.o env.a auto_spawn.o \ 2080 1762 + -I/usr/local/include -L/usr/local/lib -lsrs2 2081 1763 2082 1764 qmail-send.0: \ 2083 1765 qmail-send.8 2084 @@ -1509,7 +1724,7 @@ 1766 nroff -man qmail-send.8 > qmail-send.0 1767 1768 qmail-send.8: \ 1769 -qmail-send.9 conf-break conf-spawn 1770 +qmail-send.9 conf-break conf-spawn conf-channels 1771 cat qmail-send.9 \ 1772 | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \ 1773 | sed s}BREAK}"`head -1 conf-break`"}g \ 1774 | sed s}SPAWN}"`head -1 conf-spawn`"}g \ 1775 + | sed s}CHANNELS}"`head -1 conf-channels`"}g \ 1776 > qmail-send.8 1777 1778 qmail-send.o: \ 1779 @@ -1508,8 +1731,8 @@ 1780 substdio.h alloc.h error.h stralloc.h gen_alloc.h str.h byte.h fmt.h \ 2085 1781 scan.h case.h auto_qmail.h trigger.h newfield.h stralloc.h quote.h \ 2086 1782 qmail.h substdio.h qsutil.h prioq.h datetime.h gen_alloc.h constmap.h \ 2087 1783 -fmtqfn.h readsubdir.h direntry.h 2088 1784 - ./compile qmail-send.c 1785 +fmtqfn.h readsubdir.h direntry.h channels.h auto_qmail.h 2089 1786 + ./compile $(DEFINES) qmail-send.c 2090 1787 2091 1788 qmail-showctl: \ 2092 1789 load qmail-showctl.o auto_uids.o control.o open.a getln.a stralloc.a \ 2093 @@ -1528,21 +17 43,26 @@1790 @@ -1528,21 +1751,26 @@ 2094 1791 compile qmail-showctl.c substdio.h subfd.h substdio.h exit.h fmt.h \ 2095 1792 str.h control.h constmap.h stralloc.h gen_alloc.h direntry.h \ … … 2129 1826 qmail-smtpd.0: \ 2130 1827 qmail-smtpd.8 2131 @@ -1551,9 +177 1,10 @@1828 @@ -1551,9 +1779,10 @@ 2132 1829 qmail-smtpd.o: \ 2133 1830 compile qmail-smtpd.c sig.h readwrite.h stralloc.h gen_alloc.h \ … … 2143 1840 2144 1841 qmail-start: \ 2145 @@ -1574,7 +1795,7 @@ 1842 @@ -1573,8 +1802,8 @@ 1843 > qmail-start.8 2146 1844 2147 1845 qmail-start.o: \ 2148 1846 -compile qmail-start.c fd.h prot.h exit.h fork.h auto_uids.h 2149 1847 - ./compile qmail-start.c 1848 +compile qmail-start.c fd.h prot.h exit.h fork.h auto_uids.h channels.h 2150 1849 + ./compile $(DEFINES) qmail-start.c 2151 1850 2152 1851 qmail-tcpok: \ 2153 1852 load qmail-tcpok.o open.a lock.a strerr.a substdio.a error.a str.a \ 2154 @@ -1606,6 +18 27,20 @@1853 @@ -1606,6 +1835,20 @@ 2155 1854 fmt.h ip.h lock.h error.h exit.h datetime.h now.h datetime.h 2156 1855 ./compile qmail-tcpto.c … … 2167 1866 +compile alloc.h auto_qmail.h byte.h constmap.h control.h direntry.h error.h \ 2168 1867 +exit.h fmt.h fmtqfn.h getln.h open.h ndelay.h now.h readsubdir.h readwrite.h \ 2169 +scan.h select.h str.h stralloc.h substdio.h trigger.h 1868 +scan.h select.h str.h stralloc.h substdio.h trigger.h channels.h 2170 1869 + ./compile $(DEFINES) qmail-todo.c 2171 1870 + … … 2173 1872 warn-auto.sh qmail-upq.sh conf-qmail conf-break conf-split 2174 1873 cat warn-auto.sh qmail-upq.sh \ 2175 @@ -1639,10 +18 74,10 @@1874 @@ -1639,10 +1882,10 @@ 2176 1875 qreceipt: \ 2177 1876 load qreceipt.o headerbody.o hfield.o quote.o token822.o qmail.o \ … … 2186 1885 qreceipt.0: \ 2187 1886 qreceipt.1 2188 @@ -1779,7 +20 14,7 @@1887 @@ -1779,7 +2022,7 @@ 2189 1888 qmail-qread.c qmail-qstat.sh qmail-queue.c qmail-remote.c \ 2190 1889 qmail-rspawn.c qmail-send.c qmail-showctl.c qmail-smtpd.c \ … … 2195 1894 except.c bouncesaying.c condredirect.c maildirmake.c maildir2mbox.c \ 2196 1895 maildirwatch.c splogger.c qail.sh elq.sh pinq.sh qmail-upq.sh \ 2197 @@ -1813,8 +20 48,9 @@1896 @@ -1813,8 +2056,9 @@ 2198 1897 trywaitp.c sig.h sig_alarm.c sig_block.c sig_catch.c sig_pause.c \ 2199 1898 sig_pipe.c sig_child.c sig_term.c sig_hup.c sig_misc.c sig_bug.c \ … … 2207 1906 getln.h getln.c getln2.3 getln2.c sgetopt.3 sgetopt.h sgetopt.c \ 2208 1907 subgetopt.3 subgetopt.h subgetopt.c error.3 error_str.3 error_temp.3 \ 2209 @@ -1824,10 +206 0,11 @@1908 @@ -1824,10 +2068,11 @@ 2210 1909 headerbody.h headerbody.c token822.h token822.c control.h control.c \ 2211 1910 datetime.3 datetime.h datetime.c datetime_un.c prioq.h prioq.c \ … … 2221 1920 chmod 400 shar 2222 1921 2223 @@ -1897,6 +21 34,23 @@1922 @@ -1897,6 +2142,23 @@ 2224 1923 ./chkspawn 2225 1924 ./compile spawn.c … … 2245 1944 load splogger.o substdio.a error.a str.a fs.a syslog.lib socket.lib 2246 1945 ./load splogger substdio.a error.a str.a fs.a `cat \ 2247 @@ -1911,13 +21 65,33 @@1946 @@ -1911,13 +2173,33 @@ 2248 1947 scan.h fmt.h 2249 1948 ./compile splogger.c … … 2285 1984 str_chr.o: \ 2286 1985 compile str_chr.c str.h 2287 @@ -1927,6 +220 1,10 @@1986 @@ -1927,6 +2209,10 @@ 2288 1987 compile str_cpy.c str.h 2289 1988 ./compile str_cpy.c … … 2296 1995 compile str_diff.c str.h 2297 1996 ./compile str_diff.c 2298 @@ -2006,6 +22 84,11 @@1997 @@ -2006,6 +2292,11 @@ 2299 1998 compile strerr_sys.c error.h strerr.h 2300 1999 ./compile strerr_sys.c … … 2308 2007 compile subfderr.c readwrite.h substdio.h subfd.h substdio.h 2309 2008 ./compile subfderr.c 2310 @@ -2066,11 +23 49,11 @@2009 @@ -2066,11 +2357,11 @@ 2311 2010 2312 2011 tcp-env: \ … … 2324 2023 2325 2024 tcp-env.0: \ 2326 @@ -2108,6 +239 1,19 @@2025 @@ -2108,6 +2399,19 @@ 2327 2026 compile timeoutwrite.c timeoutwrite.h select.h error.h readwrite.h 2328 2027 ./compile timeoutwrite.c … … 2344 2043 compile token822.c stralloc.h gen_alloc.h alloc.h str.h token822.h \ 2345 2044 gen_alloc.h gen_allocdefs.h 2346 @@ -2139,3 +24 35,165@@2045 @@ -2139,3 +2443,173 @@ 2347 2046 wait_pid.o: \ 2348 2047 compile wait_pid.c error.h haswaitp.h … … 2464 2163 + > dk-filter 2465 2164 + 2466 +DKIMHDRS = dkim.h dkimdns.h dkimbase.h dkimsign.h dkimverify.h 2165 +DKIMHDRS = dkim.h dkimdns.h dkimbase.h dkimsign.h dkimverify.h time_t_size.h 2467 2166 +DKIMSRCS = dkimfuncs.cpp dkimbase.cpp 2468 2167 +DKIMOBJS = $(DKIMSRCS:.cpp=.o) 2469 +dkim 2168 +dkim: libdkim.a dkim.o dkimdns.o 2470 2169 + g++ -o dkim $(LFLAGS) -L. dkim.o dkimdns.o libdkim.a `cat dns.lib` -lcrypto 2471 2170 + 2472 +dkimverify.o: dkim.h dkimdns.h dkimverify.h dkimverify.cpp 2473 + g++ -DHAVE_CONFIG_H -c dkimverify.cpp 2171 +time_t_size.h: time_t_size.c compile load 2172 + (./compile time_t_size.c && ./load time_t_size && \ 2173 + ./time_t_size) > time_t_size.h 2174 + rm -f time_t_size.o time_t_size 2175 + 2176 +dkimfuncs.o: dkimfuncs.cpp time_t_size.h 2177 + g++ -DHAVE_EVP_SHA256 -c dkimfuncs.cpp 2178 + 2179 +dkimverify.o: dkim.h dkimdns.h dkimverify.h dkimverify.cpp time_t_size.h 2180 + g++ -DHAVE_EVP_SHA256 -c dkimverify.cpp 2474 2181 + 2475 2182 +dkimsign.o: dkim.h dkimsign.h dkimsign.cpp 2476 + g++ -DHAVE_ CONFIG_H-c dkimsign.cpp2183 + g++ -DHAVE_EVP_SHA256 -c dkimsign.cpp 2477 2184 + 2478 2185 +dkim.o: dkim.c $(DKIMHDRS) 2479 + g++ -DHAVE_ CONFIG_H-I. -DHAVE_EVP_SHA256 -c dkim.c2480 + 2481 +libdkim.a: $(DKIMOBJS) dkimverify.o dkimsign.o makelib 2186 + g++ -DHAVE_EVP_SHA256 -I. -DHAVE_EVP_SHA256 -c dkim.c 2187 + 2188 +libdkim.a: $(DKIMOBJS) dkimverify.o dkimsign.o makelib time_t_size.h 2482 2189 + rm -f libdkim.a 2483 2190 + ./makelib libdkim.a $(DKIMOBJS) dkimsign.o dkimverify.o 2484 2191 +.cpp.o: 2485 + g++ -I. -DHAVE_ CONFIG_H$(CFLAGS) $(INCL) -c $<2192 + g++ -I. -DHAVE_EVP_SHA256 $(CFLAGS) $(INCL) -c $< 2486 2193 + 2487 2194 +cert cert-req: \ … … 2512 2219 diff -ruN ../netqmail-1.06-original/Makefile-cert.mk netqmail-1.06/Makefile-cert.mk 2513 2220 --- ../netqmail-1.06-original/Makefile-cert.mk 1970-01-01 01:00:00.000000000 +0100 2514 +++ netqmail-1.06/Makefile-cert.mk 201 6-11-22 21:03:57.103528399+01002221 +++ netqmail-1.06/Makefile-cert.mk 2019-02-27 20:57:13.379025191 +0100 2515 2222 @@ -0,0 +1,21 @@ 2516 2223 +cert-req: req.pem … … 2535 2242 + @echo "Send req.pem to your CA to obtain signed_req.pem, and do:" 2536 2243 + @echo "cat signed_req.pem >> QMAIL/control/servercert.pem" 2244 diff -ruN ../netqmail-1.06-original/README.PATCH netqmail-1.06/README.PATCH 2245 --- ../netqmail-1.06-original/README.PATCH 1970-01-01 01:00:00.000000000 +0100 2246 +++ netqmail-1.06/README.PATCH 2020-07-29 21:22:44.084295087 +0200 2247 @@ -0,0 +1,547 @@ 2248 +v. 2020.07.29 2249 +Combined patch for netqmail-1.06 by Roberto Puzzanghera [roberto dot puzzanghera at sagredo dot eu] 2250 +More info at https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html 2251 +========================================================================================================== 2252 + 2253 += This patch puts together 2254 +* Erwin Hoffmann's qmail-authentication patch v. 0.8.3, which updates the patches provided by 2255 + Krysztof Dabrowski and Bjoern Kalkbrenner. 2256 + It provides cram-md5, login, plain authentication support for qmail-smtpd and qmail-remote. 2257 + http://www.fehcom.de/qmail/smtpauth.html##PATCHES 2258 +* Frederik Vermeulen's qmail-tls patch v. 20200107 2259 + implements SSL or TLS encrypted and authenticated SMTP. 2260 + http://inoa.net/qmail-tls/ 2261 + The file update_tmprsadh was modified to chown all .pem files to vpopmail. 2262 +* Marcel Telka's force-tls patch v. 2016.05.15 2263 + optionally gets qmail to require TLS before authentication to improve security. 2264 + You have to declare FORCETLS=0 if you want to allow the auth without TLS 2265 + https://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/roberto-netqmail-1.06_force-tls.patch-2012.10.28 2266 +* Antonio Nati's chkuser patch v. 2.0.9 2267 + performs, among the other things, a check for the existence of recipients during the SMTP conversation, 2268 + bouncing emails of fake senders. 2269 + http://www.interazioni.it/opensource/chkuser/ 2270 +* Flavio Curti's qmail-queue-custom-error patch 2271 + enables simscan and qmail-dkim to return the appropriate message for each e-mail it refuses to deliver. 2272 + https://no-way.org/uploads/qmail-error/ 2273 +* Christophe Saout's qmail-SPF rc5 patch 2274 + Modified by Manvendra Bhangui to make it IPv4-mapped IPv6 addresses compliant. 2275 + checks incoming mails inside the SMTP daemon, add Received-SPF lines and optionally block undesired transfers. 2276 + http://www.saout.de/misc/spf/ 2277 +* Marcelo Coelho's qmail-SRS patch 2278 + implements Sender Rewriting Scheme fixing SPF break upon email forwarding. 2279 + http://www.mco2.com.br/opensource/qmail/srs/ 2280 +* Christopher K. Davis' oversize dns patch 2281 + enables qmail to handle large DNS packets. 2282 + http://www.ckdhr.com/ckd/qmail-103.patch 2283 +* Jul's reread-concurrency v.2 patch 2284 + rereads control/concurrencylocal and control/concurrencyremote files when qmail-send receives a HUP signal. 2285 + http://js.hu/package/qmail/index.html 2286 +* Johannes Erdfelt's Big Concurrency patch 2287 + sets the spawn limit above 255 2288 + http://qmail.org/big-concurrency.patch 2289 +* Mihai Secasiu's Big Concurrency fix v.1.0 patch 2290 + fixes a compiler error if you set concurrency higher than 509 in conf-spawn. 2291 + http://patchlog.com/linux/qmail-big-concurrency/ 2292 +* Bill Shupp's netqmail-maildir++.patch 2293 + adds maildirquota support to qmail-pop3d and qmail-local. 2294 + Fixed a bug where the filesize part of the S=<filesize> component of the Maildir++ compatible filename 2295 + is wrong (tx MG). More info here: 2296 + https://notes.sagredo.eu/en/qmail-notes-185/installing-dovecot-and-sieve-on-a-vpopmail-qmail-server-28.html#comment995 2297 + https://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/netqmail-maildir.patch 2298 +* Kyle B. Wheeler's "Better qmail-smtpd Logging" v.5 patch 2299 + facilitates diagnostics of qmail-smtpd logging its actions and decisions (search for a line with qmail-smtp:) 2300 + http://www.memoryhole.net/qmail/#logging 2301 +* John Simpson's (?) Greeting delay patch 2302 + adds a user-definable delay after SMTP clients have initiated SMTP sessions, prior to qmail-smtpd responding 2303 + with "220 ESMTP". It can reject connections from clients which tried to send commands before greeting. 2304 + https://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/qmail-greetdelay.patch 2305 +* Manvendra Bhangui's DKIM and SURBL filter v.1.28 patch 2306 + adds DKIM signing & verification and SURBL filtering support to qmail. 2307 + qmail-dk is based on Russ Nelson's patch: http//:www.qmail.org/qmail-1.03-dk-0.54.patch 2308 + qmail-dkim uses hacked libdkim libraries from libdkim project at http://libdkim.sourceforge.net/ 2309 + surbfilter is built on djb functions and some functions have been ruthlessly borrowed from qmail surbl 2310 + interface by Pieter Droogendijk and the surblhost program at http://surblhost.sourceforge.net/ 2311 + (file hier.c modified to chown /var/qmail/control/cache and subdirs to vpopmail) 2312 + http://sourceforge.net/projects/indimail/files/netqmail-addons/qmail-dkim-1.0/ 2313 + http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/ANNOUNCE.surblfilter 2314 +* Claudio Jeker and Andre Oppermann's EXTTODO patch (release 5. Jan. 2003) 2315 + addresses a problem known as the silly qmail (queue) problem 2316 + http://www.nrg4u.com/qmail/ext_todo-20030105.patch 2317 +* Russell Nelson's big-todo patch 2318 + makes qmail use a hashing mechanism in the todo folder similar to that used in the rest of the queue 2319 + http://www.qmail.org/big-todo.103.patch 2320 +* Stephane Cottin's qmail-inject-null-sender patch (let's call it in this way) 2321 + prevents qmail-inject from rewriting the null sender, fixing an issue with sieve vacation/reject messages. 2322 + More info here: http://www.dovecot.org/list/dovecot/2009-June/040811.html 2323 + https://notes.sagredo.eu/files/qmail/patches/qmail-inject-null-sender.patch 2324 +* Russell Nelson's (modified by Charles Cazabon) doublebounce-trim patch, which updates the original 2325 + version by Russel Nelson 2326 + prevents double bounces from hitting your queue a second time provided that you delete the first line 2327 + from /var/qmail/control/doublebounceto 2328 + http://qmail.org/doublebounce-trim.patch 2329 +* Will Harris' esmtp-size patch 2330 + enables qmail-smtpd to reject messages if they're larger than the maximum number of bytes allowed 2331 + according to the /var/qmail/control/databytes control file. 2332 + http://will.harris.ch/qmail-smtpd.c.diff 2333 +* Inter7's qmail-taps-extended patch 2334 + http://notes.sagredo.eu/files/qmail/patches/qmail-tap.diff 2335 + Extended by Michai Secasiu (http://patchlog.com/patches/qmail-taps-extended/) 2336 + Provides the ability to archive each email that flows through the system. 2337 + Archiving only messages from or to certain email addresses is possible as well. 2338 +* Rolf Eike Beer's qmail-remote CRLF patch 2339 + enables qmail-remote to handle CR properly, always sending the line breaks as CRLF and avoiding to 2340 + double the CR (like qmail-remote normally does) 2341 + http://opensource.sf-tec.de/qmail/ 2342 +* Andy Repton's outgoingip patch (adjusted by Sergio Gelato) 2343 + by default all outgoing emails are sent through the first IP address on the interface. In case of a multiple 2344 + IP server this patch makes qmail send outgoing emails with the IP eventually stored in control/outgoingip. 2345 + The ehlo domain is NOT modified by this patch. 2346 + http://www.qmail.org/outgoingip.patch 2347 + Robbie Walker provided a patch to correct qmail-qmqpc.c's call to timeoutconn(), because the function 2348 + signature was modified by the original outgoingip patch 2349 + https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html#comment373 2350 +* Iain Patterson's qmail-smtpd pid, qp log patch 2351 + makes qmail-smtpd log a line similar to the following: 2352 + @4000000039b89c95026a89b4 mail recv: pid 8155 from <name@domain.xy> qp 8157 2353 + The pid allows you to match the message up with a given tcpserver process and the qp lets you find a 2354 + particular delivery. 2355 + http://iain.cx/qmail/patches.html#smtpd_pidqp 2356 +* Jonathan de Boyne Pollard's any-to-cname patch 2357 + avoids qmail getting large amounts of DNS data we have no interest in and that may overflow our response 2358 + buffer. 2359 + http://www.memoryhole.net/qmail/#any-to-cname 2360 +* Matthias Andree's qmail-rfc2821 patch 2361 + makes qmail rfc2821 compliant 2362 + http://www-dt.e-technik.uni-dortmund.de/~ma/qmail/patch-qmail-1.03-rfc2821.diff 2363 +* Jonathan de Boyne Pollard's smtpd-502-to-500 patch 2364 + makes qmail rfc2821 compliant 2365 + https://notes.sagredo.eu/files/qmail/patches/smtpd-502-to-500.patch 2366 +* Fabio Busatto's qmail-dnsbl patch 2367 + allows you to reject spam and virus looking at the sender's ip address. 2368 + Modified by Luca Franceschini to add support for whitelists, TXT and A queries, configurable return codes 2369 + 451 or 553 with custom messages 2370 + http://qmail-dnsbl.sourceforge.net/ 2371 +* Scott Gifford's qmail-moreipme patch v. 0.6 2372 + prevents a problem caused by an MX or other mail routing directive instructing qmail to connect to 2373 + itself without realizing it's connecting to itself, saving CPU time. 2374 + http://www.suspectclass.com/sgifford/qmail/qmail-1.03-moreipme.README 2375 + http://www.suspectclass.com/sgifford/qmail/qmail-1.03-moreipme-0.6.patch 2376 +* Alex Nee's qmail-hide-ip-headers patch 2377 + It will hide your Private or Public IP in the email Headers when you are sending Mail as a Relay Client. 2378 + https://notes.sagredo.eu/files/qmail/patches/qmail-hide-ip-headers.patch 2379 +* John Saunders' qmail-date-localtime patch 2380 + causes the various qmail programs to generate date stamps in the local timezone. 2381 + https://notes.sagredo.eu/files/qmail/patches/qmail-date-localtime.patch 2382 +* Dean Gaudet's qmail-liberal-lf patch v. 0.95 2383 + allow qmail-smtpd to accept messages that are terminated with a single \n instead of the required \r\n 2384 + sequence. 2385 + http://www.arctic.org/~dean/patches/qmail-0.95-liberal-lf.patch 2386 +* Michael Samuel's maxrcpt patch 2387 + allows you to set a limit on how many recipients are specified for any one email message by setting 2388 + control/maxrcpt. RFC 2821 section 4.5.3.1 says that an MTA MUST allow at least 100 recipients for each 2389 + message, since this is one of the favourite tricks of the spammer. 2390 + http://copilotco.com/mail-archives/qmail.1997/msg03066.html 2391 +* Inter7's qmail-eMPF patch 2392 + More info: http://www.qmailwiki.org/EMPF 2393 + eMPF follows a set of administrator-defined rules describing who can message whom. With this, 2394 + companies can segregate various parts of their organizations email activities, as well as provide a 2395 + variety of security-enhancing services. 2396 +* qregex (by Andrew St. Jean http://www.arda.homeunix.net/downloads-qmail/, contributors: Jeremy Kitchen, 2397 + Alex Pleiner, 2398 + Thanos Massias. Original patch by Evan Borgstrom) 2399 + adds the ability to match address evelopes via Regular Expressions (REs) in the qmail-smtpd process. 2400 + Added new control file 'badhelonorelay', control/badmailto renamed control/badrcptto (Tx Luca Franceschini). 2401 +* brtlimit 2402 + Luca Franceschini derived this patch from http://netdevice.com/qmail/patch/goodrcptto-12.patch 2403 + added control/brtlimit and BRTLIMIT variable to limit max invalid recipient errors before closing 2404 + the connection (man qmail-control) 2405 +* validrcptto 2406 + https://notes.sagredo.eu/files/qmail/patches/validrcptto.README 2407 + Luca Franceschini grabbed the code from several patches with additional features: 2408 + http://qmail.jms1.net/patches/validrcptto cdb.shtml, 2409 + http://netdevice.com/qmail/patch/goodrcptto-ms-12.patch, http://patch.be/qmail/badrcptto.html 2410 + It works in conjunction with chkuser with both cdb and mysql accounts. 2411 +* reject-relay-test by Russell Nelson 2412 + http://qmail.org/qmail-smtpd-relay-reject 2413 + It gets qmail to reject relay probes generated by so-called anti-spammers. These relay probes have 2414 + '!', '%' and '@' in the local (username) part of the address. 2415 +* Luca Franceschini 2416 + added DISABLETLS environment variable, useful if you want to disable TLS on a desired port 2417 + added FORCEAUTHMAILFROM environment variable to REQUIRE that authenticated user and 'mail from' are identical 2418 + added SMTPAUTHMETHOD, SMTPAUTHUSER and SMTP_AUTH_USER env variables for external plugins (see 2419 + http://qmail-spp.sourceforge.net/doc/) 2420 +* fixed little bug in 'mail from' address handling 2421 + patch by Andre Opperman at http://qmail.cr.yp.narkive.com/kBry6GJl/bug-in-qmail-smtpd-c-addrparse-function 2422 +* Luca Franceschini's qlog patch 2423 + smtpd logging with fixed format. An entry 'qlogenvelope' is generated after accepting or rejecting 2424 + every recipients in the envelope phase. 2425 +* Luca Franceschini's reject null senders patch 2426 + useful in special cases if you temporarily need to reject the null sender (although breaks RFC compatibility). 2427 + You just need to put 1 (actually any number different from 0) in your control/rejectnullsenders to reject 2428 + the null sender with 421 error message. 2429 +* dnscname patch 2430 + Removes CNAME check in order to avoid getting large amounts of data of no interest in and that may 2431 + overflow the response buffer. 2432 + https://lists.gt.net/qmail/users/138190 2433 +* Luca Franceschini's rcptcheck patch 2434 + (based on original patch from Jay Soffian (http://www.soffian.org/downloads/qmail/qmail-smtpd-doc.html) 2435 + Originally designed for the purpose of receipt validation, it can also be used to limit the numbr of 2436 + email a given IP and/or auth-user and/or domain can send in a given time interval. It has to be used 2437 + in conjuction with the rcptcheck-overlimit.sh LF's script 2438 + https://notes.sagredo.eu/files/qmail/rcptcheck-overlimit.sh 2439 + https://notes.sagredo.eu/files/qmail/patches/rcptcheck.patch 2440 +* Reed Sandberg's qmail-channels patch 2441 + Allows you to add an arbitrary number of supplemental remote queues, each distinguished by a list of 2442 + recipient domains and separate throttling (concurrency) capabilities. This patch also allows dynamic 2443 + throttling of the concurrency control files so you can just send qmail-send a HUP signal instead of 2444 + restarting the service every time. 2445 + This patch is useful when some email providers complain of too many emails receveid at the same time 2446 + (in case of news letters for instance). Look here for more info 2447 + https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html#comment1328 2448 + Edit conf-channels before compiling: Total number of channels (queues) available for delivery. Must be at 2449 + least 2, and anything above 2 are considered supplemental channels. 2450 + http://www.thesmbexchange.com/eng/qmail-channels_patch.html 2451 +* Endersys R&D team's qmail-remote-logging patch 2452 + gets qmail-remote to log sender, recipient and IP adddress all together in the "Delivery success/failure" line 2453 + https://web.archive.org/web/20120530051612/http://blog.endersys.com/2009/12/qmail-canonicalised-recipient-logging-and-more-patch/ 2454 +* notqmail.org's cve-2005-1513 patch 2455 + addresses a vulnerability issue spotted by Georgi Guninski in 2005 2456 + https://www.qualys.com/2020/05/19/cve-2005-1513/remote-code-execution-qmail.txt 2457 + 2458 += Disclaimer 2459 +This patch comes with the usual warranty: it works for me, it may not work for you, 2460 +use at your own risk etc. etc. :) 2461 +Comments, suggestions, criticisms are always welcome! 2462 + 2463 += Usage 2464 + 2465 +* Install libdomainkeys 2466 +wget https://notes.sagredo.eu/files/qmail/tar/libdomainkeys-0.69.tar.gz 2467 +tar xzf libdomainkeys-0.69.tar.gz 2468 +wget https://notes.sagredo.eu/files/qmail/patches/libdomainkeys/libdomainkeys-openssl-1.1.patch 2469 +wget https://notes.sagredo.eu/files/qmail/patches/libdomainkeys-0.69.diff 2470 +cd libdomainkeys-0.69 2471 +chown -R root.root . 2472 +patch -p1 < ../libdomainkeys-openssl-1.1.patch 2473 +patch < ../libdomainkeys-0.69.diff 2474 +make 2475 +cp libdomainkeys.a /usr/lib 2476 + 2477 +* Install libsrs2 2478 +wget https://notes.sagredo.eu/files/qmail/tar/libsrs2-1.0.18.tar.gz 2479 +tar xzf libsrs2-1.0.18.tar.gz 2480 +cd libsrs2-1.0.18 2481 +./configure 2482 +make 2483 +make install 2484 +ldconfig 2485 +cd ../ 2486 + 2487 +* Apply the patch and compile 2488 +wget https://notes.sagredo.eu/files/qmail/patches/roberto-netqmail-1.06.patch-latest.gz 2489 +wget http://qmail.org/netqmail-1.06.tar.gz 2490 +tar xzf netqmail-1.06.tar.gz 2491 +cd netqmail-1.06 2492 +chown -R root.root . 2493 +gunzip -c ../roberto-netqmail-1.06.patch-latest.gz | patch 2494 +make 2495 +make setup check 2496 + 2497 +* You have to export SMTPAUTH in your run file if you want to do the auth 2498 + 2499 +* You have to export SURBL=1 in your run file if you want to enable SURBL 2500 + 2501 +* /var/qmail/control/cache must be owned by the user who runs qmail-smtpd, vpopmail.vchkpwd in my case. 2502 + Change the permissions according to your qmail configuration. 2503 + 2504 +================================================================================================================= 2505 + 2506 += Changelog 2507 + 2508 +2020.07.29 2509 +-dk-filter: corrected a bug where dk-filter was using DKIMDOMAIN unconditionally. Now it uses DKIMDOMAIN 2510 + only if _SENDER is null (tx Manvendra Bhangui). 2511 + 2512 +2020.07.27 2513 +-added cve-2005-1513 patch 2514 + 2515 +2020.04.25 2516 +-qmail-smtpd.c: added rcptcount = 0; in smtp_rset function to prevent the maxrcpto error if control/maxrcpt limit 2517 + has been exceeded in multiple messages sent sequentially rather than in a single mail (tx Alexandre Fonceca). 2518 + More info here: https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html#comment1594 2519 + 2520 +2020.04.16 2521 +-qmail-remote-logging patch added 2522 + 2523 +2020.04.10 2524 +-DKIM patch updated to v. 1.28 2525 + * outgoing messages from null sender ("<>") will be signed as well with the domain in env variable DKIMDOMAIN 2526 + * declaring NODK env variable disables old domainkeys signature, while defining NODKIM disables DKIM. 2527 + 2528 +2020.01.11 2529 +-qmail-tls patch updated to v. 20200107 2530 + * working client cert authentication with TLSv1.3 (Rolf Eike Beer) 2531 + 2532 +2019.12.08 2533 +-BUG qmail-smtpd.c: now TLS is defined before chkuser.h call, to avoid errors on closing the db connection 2534 + (tx ChangHo.Na https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html#comment1469) 2535 + 2536 +2019.07.12 2537 +-qmail-channels patch added 2538 + more info here http://www.thesmbexchange.com/eng/qmail-channels_patch.html 2539 +-improved verbosity of die_read function in qmail-smtpd.c (qmail-smtpd: read failure) 2540 + more info here https://notes.sagredo.eu/files/qmail/patches/roberto-netqmail-1.06/die_read.patch 2541 + 2542 +2019.06.19 2543 +-DKIM patch updated to v. 1.26 2544 + * BUG - honor body length tag in verification 2545 + 2546 +2019.05.24 2547 +-qmail-tls updated to v. 20190517 2548 + * bug: qmail-smtpd ssl_free before tls_out error string (K. Wheeler) 2549 + 2550 +2019.05.23 2551 +-DKIM patch updated to v. 1.25 2552 + * SIGSEGV - when the txt data for domainkeys is very large exposed a bug in the way realloc() was used incorrectly. 2553 + * On 32 bit systems, variable defined as time_t overflows. Now qmail-dkim will skip expiry check in such conditions. 2554 + 2555 +2019.04.25 2556 +-bug fixed on qmail-smtpd.c: it was selecting the wrong openssl version on line 2331 (tx ChangHo.Na) 2557 + 2558 +2019.04.09 2559 +-qmail-tls updated to v. 20190408 2560 + * make compatible with openssl 1.1.0 (Rolf Eike Beer, Dirk Engling, Alexander Hof) 2561 + * compiler warnings on char * casts (Kai Peter) 2562 + 2563 +2019.03.22 2564 +-fixed a bug causing crashes with qmail-remote when using openssl-1.1 (tx Luca Franceschini) 2565 +(https://notes.sagredo.eu/files/qmail//patches//roberto-netqmail-1.06/2019.03.22-fix.patch) 2566 + 2567 +2019.02.13 2568 +-Port to openssl-1.1 2569 +-DKIM patch updated to v. 1.24 2570 + * bug fix: restored signaturedomains/nosignaturedomains functionalities. 2571 + 2572 +2018.08.25 2573 +-DKIM patch updated to v. 1.23 2574 + * fixed a bug where including round brackets in the From: field ouside the double quotes, i.e. 2575 + From: "Name Surname (My Company)" <name.surname@company.com>, results in a DKIMContext structure invalid 2576 + error (tx Mirko Buffoni). 2577 + * qmail-dkim and dkim were issuing a failure for emails which had multiple signature with at least one good 2578 + signature. Now qmail-dkim and dkim will issue a success if at least one good signature is found. 2579 + 2580 +2018.08.23 2581 +-logging patch 2582 + * fixed a bug in logit and logit2 functions where after a RSET command and a subsequent brutal quit 2583 + of the smtp conversation '^]' by the client cause a segfault (tx Mirko Buffoni, more info here 2584 + https://notes.sagredo.eu/en/qmail-notes-185/patching-qmail-82.html#comment1132) 2585 +-patch info moved to 'README.PATCH' file 2586 + 2587 +2018.04.03 2588 +-DKIM patch updated to v. 1.22 2589 + * openssl 1.1.0 port 2590 + * various improvements, bug fixes 2591 + 2592 +2018.01.10 2593 +-maildir++ 2594 + * fixed a bug where the filesize part of the S=<filesize> component of the Maildir++ compatible filename 2595 + is wrong (tx MG). More info here: http://notes.sagredo.eu/en/qmail-notes-185/installing-dovecot-and-sieve-on-a- 2596 +vpopmail-qmail-server-28.html#comment995 2597 +-qmail-queue-extra 2598 + * removed, because it was causing more problems than advantages, as the domain of the log@yourdomain.tld 2599 + had to match the system domain inside control/me and shouldn't be a virtual domain as well. 2600 + 2601 +2017.10.11 (tx Luca Franceschini) 2602 +-qlogfix 2603 + * log strings should terminate with \n to avoid trailing ^M using splogger 2604 + * bug reporting custom errors from qmail-queue in qlog 2605 +-added dnscname patch 2606 +-added rcptcheck patch 2607 + 2608 +2017.08.18 2609 +-qmail-smtpd now retains authentication upon rset 2610 + (tx to Andreas http://notes.sagredo.eu/qmail-notes-185/smtp-auth-qmail-tls-forcetls-patch-for-qmail-84.html#comme 2611 +nt750) 2612 + 2613 +2017-05-14 2614 +-DKIM patch updated to v. 1.20 2615 + It now manages long TXT records, avoiding the rejection of some hotmail.com messages. 2616 + 2617 +2016-12-19 2618 +-Several new patches and improvements added (thanks to Luca Franceschini) 2619 +More info here http://notes.sagredo.eu/node/178 2620 + -qregex patch 2621 + -brtlimit patch 2622 + -validrcptto patch 2623 + -rbl patch (updates qmail-dnsbl patch) 2624 + -reject-relay-test patch 2625 + -added DISABLETLS environment variable, useful if you want to disable TLS on a desired port 2626 + -added FORCEAUTHMAILFROM environment variable to REQUIRE that authenticated user and 'mail from' are identical 2627 + -fixed little bug in 'mail from' address handling (patch by Andre Opperman at http://qmail.cr.yp.narkive.com/kBry 2628 + 6GJl/bug-in-qmail-smtpd-c-addrparse-function) 2629 + -added SMTPAUTHMETHOD, SMTPAUTHUSER and SMTP_AUTH_USER env variables for external plugins 2630 + -qlog patch 2631 + -reject null senders patch 2632 + -bouncecontrolmime patch 2633 + -qmail-taps-extended (updates qmail-tap) 2634 + 2635 +2016-12-02 2636 +-fixed BUG in qmail-remote.c: in case of remote server who doesn't allow EHLO the response for an alternative 2637 + HELO was checked twice, making the connection to die. (Thanks to Luca Franceschini) 2638 + Patch applied: http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/fix_sagredo_remotehelo.patch 2639 + 2640 +2016-09-19 2641 +-qmail-tls patch updated to v. 20160918 2642 + * bug: qmail-remote accepting any dNSName, without checking that is matches (E. Surovegin) 2643 + * bug: documentation regarding RSA and DH keys (K. Peter, G. A. Bofill) 2644 + 2645 +2016-05-15 2646 +-force-tls patch improved (a big thanks to Marcel Telka). Now qmail-smtpd avoids to write the auth verb if the 2647 + the STARTTLS command was not sent by the client 2648 + 2649 +2016-03-09 2650 +-DKIM patch upgraded to v. 1.19 2651 + * verification will not fail when a dkim signature does not include the subject provided that the 2652 + UNSIGNED_SUBJECT environment variable is declared. 2653 + 2654 +2015-12-26 2655 +-qmail-tls patch updated to v. 20151215 2656 + * typo in #if OPENSSL_VERSION_NUMBER for 2015-12-08 patch release (V. Smith) 2657 + * add ECDH to qmail-smtpd 2658 + * increase size of RSA and DH pregenerated keys to 2048 bits 2659 + * qmail-smtpd sets RELAYCLIENT if relaying allowed by cert 2660 + more info at http://inoa.net/qmail-tls/ 2661 + 2662 +2015-12-15 2663 +-DKIM patch by Manvendra Bhangui updated to v. 1.18 2664 + 2665 +2015-10-03 2666 +-qmail-authentication: updated to v. 0.8.3 2667 + 2668 +2015-08-08 2669 +-fixed a bug on qmail-remote.c that was causing the sending of an additionale ehlo greeting (thanks to Cristoph Gr 2670 +over) 2671 + 2672 +2015-04-11 2673 +-qmail-authentication: updated to v. 0.8.2 2674 +-qmail-tls: upgraded to v. 20141216 (POODLE vulnerability fixed) 2675 + 2676 +2015-03-28 2677 +-added qmail-eMPF patch 2678 + 2679 +2014-11-19 2680 +-security fix: the SSLv3 connection is now switched off 2681 + 2682 +2014-11-15 2683 +-modified the QUEUE_EXTRA variable in extra.h to improve the qmail-send's log 2684 + 2685 +2014-04-14 2686 +-added maxrcpt patch 2687 + 2688 +2014-03-10 2689 +-added qmail-0.95-liberal-lf patch 2690 + 2691 +2013-12-30 2692 +-added qmail-srs 2693 +-the character "=" is now considered valid in the sender address by chkuser in order to accept SRS 2694 + 2695 +2013-12-18 2696 +-added qmail-date-localtime patch 2697 + 2698 +2013-12-14 2699 +-added qmail-hide-ip patch 2700 + 2701 +2013-12-10 2702 +-the original greetdelay by e.h. has been replaced with the improved patch by John Simpson. Now 2703 + communications trying to send commands before the greeting will be closed. Premature disconnections will be 2704 + logged as well. 2705 +-CHKUSER_SENDER_FORMAT enabled to reject fake senders without any domain declared (like <foo>) 2706 +-chkuser logging: I slightly modified the log line adding the variables' name just to facilitate its interpretation 2707 +-added qmail-moreipme patch 2708 + 2709 +2013-12-07 2710 +-added qmail-dnsbl patch 2711 + 2712 +2013-12-05 2713 +-added two patches to make qmail rfc2821 compliant 2714 + 2715 +2013-11-23 2716 +-added any-to-cname patch 2717 + 2718 +2013-09-27 2719 +-DKIM patch upgraded to v. 1.17. Defined -DHAVE_SHA_256 while compiling dkimverify.cpp in the Makefile. 2720 + This solved an issue while verifying signatures using sha256. 2721 + 2722 +2013-09-16 2723 +-Minor fixes to the DKIM patch. 2724 + 2725 +2013-09-13 2726 +-DKIM patch upgraded to v. 1.16. The signing at qmail-remote level has been revised by its author. 2727 + 2728 +2013-08-25 2729 +-qmail-qmqpc.c call to timeoutconn() needed a correction because the function signature was modified by the 2730 + outgoingip patch. Thanks to Robbie Walker (diff here http://notes.sagredo.eu/node/82#comment-373) 2731 + 2732 +2013-08-21 2733 +-fixed a bug in hier.c which caused the installation not to build properly the queue/todo dir structure (thanks to 2734 + Scott Ramshaw) 2735 + 2736 +2013-08-18 2737 +-DKIM-SURBL patch by Manvendra Bhangui updated to v. 1.14 2738 + 2739 +2013-08-12 2740 +-DKIM patch upgraded to v. 1.12. The new patch adds surblfilter functionality. 2741 +-added qmail-smtpd pid, qp log patch 2742 + 2743 +2013-08-08 2744 +-qmail-SPF modified by Manvendra Bhangui to make it IPv6-mapped IPv4 addresses compliant. In order to have it 2745 + working with such addresses you have to patch tcpserver.c accordingly. You can use a patch fot ucspi-tcp6-0.98 2746 + by Manvendra Bhangui at http://notes.sagredo.eu/sites/notes.sagredo.eu/files/qmail/patches/tcpserver-ipv6mapped_ip 2747 + v4.patch or wait for v. 0.99 relase of ucspi-tcp6 2748 +-added outgoingip patch 2749 +-added qmail-bounce patch 2750 + 2751 +2013-03-31 2752 +qmail-auth updated to latest v. 0.8.1 Added authentication by recipient domain for qmail-remote. 2753 +Look at README.auth for further details 2754 + 2755 +2013-02-11 2756 +some code adjustments in qmail-smtpd.c smtpd_ehlo() to restore total compatibility with esmtp-size patch 2757 + 2758 +2013-02-08 2759 +qmail-auth updated to latest v. 0.7.6. Look at README.auth for further details 2760 + 2761 +2013-01-28 2762 +fixed an issue on qmail-pop3d which was causing a double +OK after the pass command (thanks to Rakesh, Orbit 2763 +and Simplex for helping in testing and troubleshooting) 2764 + 2765 +2013-01-06 2766 +environment variable GREETDELAY renamed to SMTPD_GREETDELAY 2767 + 2768 +2012-10-31 2769 +qmail-auth updated to latest v. 0.7.5. Look at README.auth for further details 2770 +The qmail-forcetls patch was simplyfied accordingly. 2771 +You MUST export SMTPAUTH="" in your run file now. 2772 + 2773 +2012-04-25 2774 +-added qmail-remote CRLF (thanks to Pierre Lauriente for the help on testing and troubleshooting) 2775 +The qmail-remote CRLF patch solved a problem of broken headers after sieve forwarding that was 2776 +caused by a bad handling of the CR (carriage return) by qmail-remote. 2777 +The issue is also reported here http://www.dt.e-technik.uni-dortmund.de/~ma/qmail-bugs.html 2778 + 2779 +2012.04.16 2780 +-added qmail-tap 2781 + 2782 +2012.02.08 2783 +-added smtp-size patch 2784 + 2785 +2012.01.29 2786 +-added doublebounce-trim patch 2787 + 2788 +2011.12.12 2789 +-file update_tmprsadh modified to chown the .pem files to vpopmail to avoid hang-ups during the smtp 2790 +conversation on port 587 caused by permission problems. 2791 + 2792 +2011.10.06 2793 +-qmail-remote.c: fixed. It was not going into tls on authentication (thanks to Krzysztof Gajdemski) 2794 +-force-tls now quits if the starttls command is not provided when required (thanks to Jacekalex) 2537 2795 diff -ruN ../netqmail-1.06-original/README.auth netqmail-1.06/README.auth 2538 2796 --- ../netqmail-1.06-original/README.auth 1970-01-01 01:00:00.000000000 +0100 2539 +++ netqmail-1.06/README.auth 201 6-11-22 21:03:57.103528399+01002797 +++ netqmail-1.06/README.auth 2019-02-27 20:57:13.379025191 +0100 2540 2798 @@ -0,0 +1,154 @@ 2541 2799 +README qmail SMTP Authentication … … 2695 2953 diff -ruN ../netqmail-1.06-original/README.dnsbl netqmail-1.06/README.dnsbl 2696 2954 --- ../netqmail-1.06-original/README.dnsbl 1970-01-01 01:00:00.000000000 +0100 2697 +++ netqmail-1.06/README.dnsbl 201 6-11-30 21:50:01.459033083+01002955 +++ netqmail-1.06/README.dnsbl 2019-02-27 20:57:13.379025191 +0100 2698 2956 @@ -0,0 +1,18 @@ 2699 2957 +Code and logic from rblsmtpd and qmail-dnsbl patch http://qmail-dnsbl.sourceforge.net/ … … 2717 2975 diff -ruN ../netqmail-1.06-original/README.empf netqmail-1.06/README.empf 2718 2976 --- ../netqmail-1.06-original/README.empf 1970-01-01 01:00:00.000000000 +0100 2719 +++ netqmail-1.06/README.empf 201 6-11-22 21:03:57.103528399+01002977 +++ netqmail-1.06/README.empf 2019-02-27 20:57:13.380025180 +0100 2720 2978 @@ -0,0 +1,106 @@ 2721 2979 +config file is: /var/qmail/control/policy … … 2827 3085 diff -ruN ../netqmail-1.06-original/README.exttodo netqmail-1.06/README.exttodo 2828 3086 --- ../netqmail-1.06-original/README.exttodo 1970-01-01 01:00:00.000000000 +0100 2829 +++ netqmail-1.06/README.exttodo 201 6-11-22 21:03:57.103528399+01003087 +++ netqmail-1.06/README.exttodo 2019-02-27 20:57:13.380025180 +0100 2830 3088 @@ -0,0 +1,114 @@ 2831 3089 +EXTTODO by Claudio Jeker <jeker@n-r-g.com> and … … 2945 3203 diff -ruN ../netqmail-1.06-original/README.liberal-lf netqmail-1.06/README.liberal-lf 2946 3204 --- ../netqmail-1.06-original/README.liberal-lf 1970-01-01 01:00:00.000000000 +0100 2947 +++ netqmail-1.06/README.liberal-lf 201 6-11-22 21:03:57.103528399+01003205 +++ netqmail-1.06/README.liberal-lf 2019-02-27 20:57:13.380025180 +0100 2948 3206 @@ -0,0 +1,39 @@ 2949 3207 +From dgaudet-list-qmail@arctic.org Fri Jan 17 17:50:19 1997 … … 2988 3246 diff -ruN ../netqmail-1.06-original/README.maxrcpt netqmail-1.06/README.maxrcpt 2989 3247 --- ../netqmail-1.06-original/README.maxrcpt 1970-01-01 01:00:00.000000000 +0100 2990 +++ netqmail-1.06/README.maxrcpt 201 6-11-22 21:03:57.104528366+01003248 +++ netqmail-1.06/README.maxrcpt 2019-02-27 20:57:13.380025180 +0100 2991 3249 @@ -0,0 +1,60 @@ 2992 3250 +maxrcpt patch for qmail-smtpd … … 3052 3310 diff -ruN ../netqmail-1.06-original/README.moreipme netqmail-1.06/README.moreipme 3053 3311 --- ../netqmail-1.06-original/README.moreipme 1970-01-01 01:00:00.000000000 +0100 3054 +++ netqmail-1.06/README.moreipme 201 6-11-22 21:03:57.104528366+01003312 +++ netqmail-1.06/README.moreipme 2019-02-27 20:57:13.380025180 +0100 3055 3313 @@ -0,0 +1,154 @@ 3056 3314 +########### … … 3210 3468 diff -ruN ../netqmail-1.06-original/README.qregex netqmail-1.06/README.qregex 3211 3469 --- ../netqmail-1.06-original/README.qregex 1970-01-01 01:00:00.000000000 +0100 3212 +++ netqmail-1.06/README.qregex 201 6-11-22 21:04:38.822137319+01003470 +++ netqmail-1.06/README.qregex 2019-02-27 20:57:13.380025180 +0100 3213 3471 @@ -0,0 +1,203 @@ 3214 3472 +QREGEX (v2) 20060423 - README April 23, 2006 … … 3417 3675 diff -ruN ../netqmail-1.06-original/README.rfc2821 netqmail-1.06/README.rfc2821 3418 3676 --- ../netqmail-1.06-original/README.rfc2821 1970-01-01 01:00:00.000000000 +0100 3419 +++ netqmail-1.06/README.rfc2821 201 6-11-22 21:03:57.104528366+01003677 +++ netqmail-1.06/README.rfc2821 2019-02-27 20:57:13.380025180 +0100 3420 3678 @@ -0,0 +1,39 @@ 3421 3679 +This patch is Copyright (C) 2002 - 2003 by Matthias Andree. License below. … … 3460 3718 diff -ruN ../netqmail-1.06-original/README.srs netqmail-1.06/README.srs 3461 3719 --- ../netqmail-1.06-original/README.srs 1970-01-01 01:00:00.000000000 +0100 3462 +++ netqmail-1.06/README.srs 201 6-11-22 21:03:57.104528366+01003720 +++ netqmail-1.06/README.srs 2019-02-27 20:57:13.381025169 +0100 3463 3721 @@ -0,0 +1,93 @@ 3464 3722 +qmail SRS patch … … 3557 3815 diff -ruN ../netqmail-1.06-original/README.surbl netqmail-1.06/README.surbl 3558 3816 --- ../netqmail-1.06-original/README.surbl 1970-01-01 01:00:00.000000000 +0100 3559 +++ netqmail-1.06/README.surbl 201 6-11-22 21:03:57.104528366+01003817 +++ netqmail-1.06/README.surbl 2019-02-27 20:57:13.381025169 +0100 3560 3818 @@ -0,0 +1,34 @@ 3561 3819 +SURBL filter for netqmail … … 3595 3853 diff -ruN ../netqmail-1.06-original/README.tap netqmail-1.06/README.tap 3596 3854 --- ../netqmail-1.06-original/README.tap 1970-01-01 01:00:00.000000000 +0100 3597 +++ netqmail-1.06/README.tap 201 6-11-22 21:04:38.822137319 +01003855 +++ netqmail-1.06/README.tap 2019-02-27 20:57:13.381025169 +0100 3598 3856 @@ -0,0 +1,34 @@ 3599 3857 +qmail provides the ability to make a copy of each email that flows through the system. … … 3633 3891 diff -ruN ../netqmail-1.06-original/README.tls netqmail-1.06/README.tls 3634 3892 --- ../netqmail-1.06-original/README.tls 1970-01-01 01:00:00.000000000 +0100 3635 +++ netqmail-1.06/README.tls 20 16-11-22 21:03:57.104528366 +01003636 @@ -0,0 +1, 100@@3637 +Frederik Vermeulen <qmail-tls akrul inoa.net> 20 1609183893 +++ netqmail-1.06/README.tls 2020-01-10 21:46:22.909448586 +0100 3894 @@ -0,0 +1,98 @@ 3895 +Frederik Vermeulen <qmail-tls akrul inoa.net> 20200107 3638 3896 +http://inoa.net/qmail-tls/ 3639 3897 + 3640 +This patch implements RFC 3207 (was RFC 2487)in qmail.3898 +This patch implements RFC 3207 in qmail. 3641 3899 +This means you can get SSL or TLS encrypted and 3642 3900 +authenticated SMTP between the MTAs and from MUA to MTA. … … 3644 3902 +many since its first release on 1999-03-21). 3645 3903 + 3646 +Usage: - install OpenSSL-1. 0.2http://www.openssl.org/ or later3647 + (any version since 0.9. 6is presumed to work)3648 + - apply patch to netqmail-1.06 http:// qmail.org/netqmail3904 +Usage: - install OpenSSL-1.1.0 http://www.openssl.org/ or later 3905 + (any version since 0.9.8 is presumed to work) 3906 + - apply patch to netqmail-1.06 http://www.usenix.org.uk/mirrors/qmail/netqmail 3649 3907 + The patches to qmail-remote.c and qmail-smtpd.c can be applied 3650 3908 + separately. … … 3709 3967 + - this patch could conflict with other patches (notably those 3710 3968 + replacing \n with \r\n, which is a bad idea on encrypted links). 3711 + - some broken servers have a problem with TLSv1 compatibility.3712 + Uncomment the line where we set the SSL_OP_NO_TLSv1 option.3713 3969 + - needs working /dev/urandom (or EGD for openssl versions >0.9.7) 3714 3970 + for seeding random number generator. … … 3737 3993 diff -ruN ../netqmail-1.06-original/TARGETS netqmail-1.06/TARGETS 3738 3994 --- ../netqmail-1.06-original/TARGETS 1998-06-15 12:53:16.000000000 +0200 3739 +++ netqmail-1.06/TARGETS 201 6-11-22 21:04:20.043763470 +01003995 +++ netqmail-1.06/TARGETS 2019-06-26 16:45:45.017718421 +0200 3740 3996 @@ -1,3 +1,4 @@ 3741 3997 +dktest … … 3852 4108 qmail-local.0 3853 4109 qmail-lspawn.0 3854 @@ -382,6 +415,5 1@@4110 @@ -382,6 +415,54 @@ 3855 4111 addresses.0 3856 4112 envelopes.0 … … 3904 4160 +dknewkey 3905 4161 +dktest.8 4162 +time_t_size.h 4163 +channels.h 4164 + 3906 4165 diff -ruN ../netqmail-1.06-original/alloc.c netqmail-1.06/alloc.c 3907 4166 --- ../netqmail-1.06-original/alloc.c 1998-06-15 12:53:16.000000000 +0200 3908 +++ netqmail-1.06/alloc.c 2016-11-22 21:03:57.105528332 +0100 3909 @@ -1,6 +1,6 @@ 4167 +++ netqmail-1.06/alloc.c 2020-07-27 13:06:47.995674192 +0200 4168 @@ -1,6 +1,7 @@ 4169 +#include <limits.h> 3910 4170 #include "alloc.h" 3911 4171 #include "error.h" … … 3915 4175 3916 4176 #define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */ 4177 @@ -15,6 +16,10 @@ 4178 unsigned int n; 4179 { 4180 char *x; 4181 + if (n >= (INT_MAX >> 3)) { 4182 + errno = error_nomem; 4183 + return 0; 4184 + } 4185 n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */ 4186 if (n <= avail) { avail -= n; return space + avail; } 4187 x = malloc(n); 3917 4188 diff -ruN ../netqmail-1.06-original/base64.c netqmail-1.06/base64.c 3918 4189 --- ../netqmail-1.06-original/base64.c 1970-01-01 01:00:00.000000000 +0100 3919 +++ netqmail-1.06/base64.c 201 6-11-22 21:03:57.105528332+01004190 +++ netqmail-1.06/base64.c 2019-02-27 20:57:13.381025169 +0100 3920 4191 @@ -0,0 +1,124 @@ 3921 4192 +#include "base64.h" … … 4045 4316 diff -ruN ../netqmail-1.06-original/base64.h netqmail-1.06/base64.h 4046 4317 --- ../netqmail-1.06-original/base64.h 1970-01-01 01:00:00.000000000 +0100 4047 +++ netqmail-1.06/base64.h 201 6-11-22 21:03:57.105528332+01004318 +++ netqmail-1.06/base64.h 2019-02-27 20:57:13.381025169 +0100 4048 4319 @@ -0,0 +1,13 @@ 4049 4320 +#ifndef BASE64_H … … 4062 4333 diff -ruN ../netqmail-1.06-original/base64sub.c netqmail-1.06/base64sub.c 4063 4334 --- ../netqmail-1.06-original/base64sub.c 1970-01-01 01:00:00.000000000 +0100 4064 +++ netqmail-1.06/base64sub.c 201 6-11-22 21:03:57.105528332+01004335 +++ netqmail-1.06/base64sub.c 2019-02-27 20:57:13.382025158 +0100 4065 4336 @@ -0,0 +1,170 @@ 4066 4337 +/* … … 4236 4507 diff -ruN ../netqmail-1.06-original/byte.h netqmail-1.06/byte.h 4237 4508 --- ../netqmail-1.06-original/byte.h 1998-06-15 12:53:16.000000000 +0200 4238 +++ netqmail-1.06/byte.h 201 6-11-22 21:03:57.105528332+01004509 +++ netqmail-1.06/byte.h 2019-02-27 20:57:13.382025158 +0100 4239 4510 @@ -3,6 +3,8 @@ 4240 4511 … … 4248 4519 diff -ruN ../netqmail-1.06-original/byte_cspn.c netqmail-1.06/byte_cspn.c 4249 4520 --- ../netqmail-1.06-original/byte_cspn.c 1970-01-01 01:00:00.000000000 +0100 4250 +++ netqmail-1.06/byte_cspn.c 201 6-11-22 21:03:57.105528332+01004521 +++ netqmail-1.06/byte_cspn.c 2019-02-27 20:57:13.382025158 +0100 4251 4522 @@ -0,0 +1,11 @@ 4252 4523 +#include "byte.h" … … 4263 4534 diff -ruN ../netqmail-1.06-original/byte_rcspn.c netqmail-1.06/byte_rcspn.c 4264 4535 --- ../netqmail-1.06-original/byte_rcspn.c 1970-01-01 01:00:00.000000000 +0100 4265 +++ netqmail-1.06/byte_rcspn.c 201 6-11-22 21:03:57.105528332+01004536 +++ netqmail-1.06/byte_rcspn.c 2019-02-27 20:57:13.382025158 +0100 4266 4537 @@ -0,0 +1,17 @@ 4267 4538 +#include "byte.h" … … 4284 4555 diff -ruN ../netqmail-1.06-original/caldate.h netqmail-1.06/caldate.h 4285 4556 --- ../netqmail-1.06-original/caldate.h 1970-01-01 01:00:00.000000000 +0100 4286 +++ netqmail-1.06/caldate.h 201 6-11-22 21:03:57.105528332+01004557 +++ netqmail-1.06/caldate.h 2019-02-27 20:57:13.382025158 +0100 4287 4558 @@ -0,0 +1,24 @@ 4288 4559 +/* … … 4312 4583 diff -ruN ../netqmail-1.06-original/caltime.h netqmail-1.06/caltime.h 4313 4584 --- ../netqmail-1.06-original/caltime.h 1970-01-01 01:00:00.000000000 +0100 4314 +++ netqmail-1.06/caltime.h 201 6-11-22 21:03:57.105528332+01004585 +++ netqmail-1.06/caltime.h 2019-02-27 20:57:13.382025158 +0100 4315 4586 @@ -0,0 +1,30 @@ 4316 4587 +/* … … 4346 4617 diff -ruN ../netqmail-1.06-original/case_startb.c netqmail-1.06/case_startb.c 4347 4618 --- ../netqmail-1.06-original/case_startb.c 1970-01-01 01:00:00.000000000 +0100 4348 +++ netqmail-1.06/case_startb.c 201 6-11-22 21:03:57.106528299+01004619 +++ netqmail-1.06/case_startb.c 2019-02-27 20:57:13.382025158 +0100 4349 4620 @@ -0,0 +1,31 @@ 4350 4621 +#include "case.h" … … 4379 4650 +} 4380 4651 +/* end DKIM 1.10 */ 4652 diff -ruN ../netqmail-1.06-original/channels.g netqmail-1.06/channels.g 4653 --- ../netqmail-1.06-original/channels.g 1970-01-01 01:00:00.000000000 +0100 4654 +++ netqmail-1.06/channels.g 2019-06-26 16:39:31.572826981 +0200 4655 @@ -0,0 +1,18 @@ 4656 +#ifndef CHANNELS_H 4657 +#define CHANNELS_H 4658 + 4659 +/* total number of channels including canonical "local" and "remote" channels */ 4660 +#define CHANNELS NUMCHANNELS 4661 + 4662 +/* supplemental channels are all channels less the canonical "local" and "remote" channels */ 4663 +#define SUPPL_CHANNELS (CHANNELS - 2) 4664 + 4665 +/* Not longer than 80 bytes, must also change qmail-upq.sh */ 4666 +#define QDIR_BASENAME "suppl" 4667 + 4668 +/* start supplemental channel fd numbers here */ 4669 +#define CHANNEL_FD_OFFSET 10 4670 + 4671 + 4672 +#endif 4673 + 4381 4674 diff -ruN ../netqmail-1.06-original/chkspawn.c netqmail-1.06/chkspawn.c 4382 4675 --- ../netqmail-1.06-original/chkspawn.c 1998-06-15 12:53:16.000000000 +0200 4383 +++ netqmail-1.06/chkspawn.c 201 6-11-22 21:03:57.106528299+01004676 +++ netqmail-1.06/chkspawn.c 2019-02-27 20:57:13.382025158 +0100 4384 4677 @@ -22,8 +22,8 @@ 4385 4678 _exit(1); … … 4395 4688 diff -ruN ../netqmail-1.06-original/chkuser.c netqmail-1.06/chkuser.c 4396 4689 --- ../netqmail-1.06-original/chkuser.c 1970-01-01 01:00:00.000000000 +0100 4397 +++ netqmail-1.06/chkuser.c 201 6-11-22 21:04:19.987765257 +01004398 @@ -0,0 +1,12 58@@4690 +++ netqmail-1.06/chkuser.c 2019-08-05 19:11:16.583873852 +0200 4691 @@ -0,0 +1,1266 @@ 4399 4692 + 4400 4693 +/* … … 4878 5171 + } else if (strcasecmp(starting_string, "DOMAIN") == 0) { 4879 5172 + starting_value = 0; 4880 + } 5173 +/* 5174 + Edit by Roberto Puzzanghera 5175 + It seems like any other definition of starting_string ends up as "DOMAIN". 5176 + Instead, if starting_string is otherwise defined, we want to turn off chkuser, 5177 + just like if the starting_string is "NONE". 5178 + */ 5179 + } else { 5180 + starting_value = -1; 5181 + } 4881 5182 + } else { 4882 5183 + starting_string = ""; … … 5657 5958 diff -ruN ../netqmail-1.06-original/chkuser.h netqmail-1.06/chkuser.h 5658 5959 --- ../netqmail-1.06-original/chkuser.h 1970-01-01 01:00:00.000000000 +0100 5659 +++ netqmail-1.06/chkuser.h 201 6-11-22 21:03:57.106528299+01005960 +++ netqmail-1.06/chkuser.h 2019-02-27 20:57:13.383025147 +0100 5660 5961 @@ -0,0 +1,55 @@ 5661 5962 + … … 5716 6017 diff -ruN ../netqmail-1.06-original/chkuser_settings.h netqmail-1.06/chkuser_settings.h 5717 6018 --- ../netqmail-1.06-original/chkuser_settings.h 1970-01-01 01:00:00.000000000 +0100 5718 +++ netqmail-1.06/chkuser_settings.h 20 16-11-28 17:35:36.567382036 +01006019 +++ netqmail-1.06/chkuser_settings.h 2020-06-16 22:27:56.782600304 +0200 5719 6020 @@ -0,0 +1,468 @@ 5720 6021 +/* … … 5929 6230 + * aliases that have a -default extension 5930 6231 + */ 5931 + /* #define CHKUSER_ENABLE_ALIAS_DEFAULT */6232 +#define CHKUSER_ENABLE_ALIAS_DEFAULT 5932 6233 + 5933 6234 + … … 6080 6381 + 6081 6382 +/* #define CHKUSER_VAUTH_OPEN_CALL vauth_open */ 6082 + /* #define CHKUSER_VAUTH_OPEN_CALL vauth_open_update */6383 +#define CHKUSER_VAUTH_OPEN_CALL vauth_open_update 6083 6384 + 6084 6385 +/* … … 6100 6401 + * 6101 6402 + */ 6102 + /* #define CHKUSER_DISABLE_VARIABLE "RELAYCLIENT" */6403 +#define CHKUSER_DISABLE_VARIABLE "RELAYCLIENT" 6103 6404 + 6104 6405 + … … 6188 6489 diff -ruN ../netqmail-1.06-original/condredirect.c netqmail-1.06/condredirect.c 6189 6490 --- ../netqmail-1.06-original/condredirect.c 1998-06-15 12:53:16.000000000 +0200 6190 +++ netqmail-1.06/condredirect.c 201 6-11-22 21:03:57.107528266 +01006491 +++ netqmail-1.06/condredirect.c 2019-02-27 20:57:13.384025136 +0100 6191 6492 @@ -10,6 +10,8 @@ 6192 6493 #include "strerr.h" … … 6217 6518 diff -ruN ../netqmail-1.06-original/conf-cc netqmail-1.06/conf-cc 6218 6519 --- ../netqmail-1.06-original/conf-cc 1998-06-15 12:53:16.000000000 +0200 6219 +++ netqmail-1.06/conf-cc 20 16-11-22 21:03:57.107528266+01006520 +++ netqmail-1.06/conf-cc 2020-01-10 21:52:13.080721081 +0100 6220 6521 @@ -1,3 +1,3 @@ 6221 6522 -cc -O2 6222 +cc -O2 -g -DEXTERNAL_TODO -DTLS=20 160918-I/usr/local/ssl/include -I/home/vpopmail/include6523 +cc -O2 -g -DEXTERNAL_TODO -DTLS=20200107 -I/usr/local/ssl/include -I/home/vpopmail/include 6223 6524 6224 6525 This will be used to compile .c files. 6526 diff -ruN ../netqmail-1.06-original/conf-channels netqmail-1.06/conf-channels 6527 --- ../netqmail-1.06-original/conf-channels 1970-01-01 01:00:00.000000000 +0100 6528 +++ netqmail-1.06/conf-channels 2019-06-26 19:12:46.033685227 +0200 6529 @@ -0,0 +1,4 @@ 6530 +2 6531 + 6532 +Total number of channels (queues) available for delivery. Must be at 6533 +least 2, and anything above 2 are considered supplemental channels. 6225 6534 diff -ruN ../netqmail-1.06-original/conf-domainkeys netqmail-1.06/conf-domainkeys 6226 6535 --- ../netqmail-1.06-original/conf-domainkeys 1970-01-01 01:00:00.000000000 +0100 6227 +++ netqmail-1.06/conf-domainkeys 201 6-11-22 21:03:57.107528266 +01006536 +++ netqmail-1.06/conf-domainkeys 2019-02-27 20:57:13.384025136 +0100 6228 6537 @@ -0,0 +1 @@ 6229 6538 +-DDOMAIN_KEYS 6230 6539 diff -ruN ../netqmail-1.06-original/conf-ld netqmail-1.06/conf-ld 6231 6540 --- ../netqmail-1.06-original/conf-ld 1998-06-15 12:53:16.000000000 +0200 6232 +++ netqmail-1.06/conf-ld 201 6-11-22 21:03:57.107528266 +01006541 +++ netqmail-1.06/conf-ld 2019-02-27 20:57:13.384025136 +0100 6233 6542 @@ -1,3 +1,3 @@ 6234 6543 -cc -s … … 6238 6547 diff -ruN ../netqmail-1.06-original/conf-policy netqmail-1.06/conf-policy 6239 6548 --- ../netqmail-1.06-original/conf-policy 1970-01-01 01:00:00.000000000 +0100 6240 +++ netqmail-1.06/conf-policy 201 6-11-22 21:03:57.107528266 +01006549 +++ netqmail-1.06/conf-policy 2019-02-27 20:57:13.384025136 +0100 6241 6550 @@ -0,0 +1,17 @@ 6242 6551 +-DPOLICY_FILENAME="/var/qmail/control/policy" -DPOLICY_DEALLOCATE -DPOLICY_ENFORCE_AUTHENTICATION … … 6259 6568 diff -ruN ../netqmail-1.06-original/conf-spawn netqmail-1.06/conf-spawn 6260 6569 --- ../netqmail-1.06-original/conf-spawn 1998-06-15 12:53:16.000000000 +0200 6261 +++ netqmail-1.06/conf-spawn 201 6-11-22 21:03:57.108528232+01006570 +++ netqmail-1.06/conf-spawn 2019-02-27 20:57:13.384025136 +0100 6262 6571 @@ -1,4 +1,4 @@ 6263 6572 -120 … … 6268 6577 diff -ruN ../netqmail-1.06-original/config.h netqmail-1.06/config.h 6269 6578 --- ../netqmail-1.06-original/config.h 1970-01-01 01:00:00.000000000 +0100 6270 +++ netqmail-1.06/config.h 201 6-11-22 21:03:57.108528232+01006579 +++ netqmail-1.06/config.h 2019-02-27 20:57:13.384025136 +0100 6271 6580 @@ -0,0 +1,10 @@ 6272 6581 +/* config.h. Generated from config.h.in by configure. */ … … 6282 6591 diff -ruN ../netqmail-1.06-original/control.c netqmail-1.06/control.c 6283 6592 --- ../netqmail-1.06-original/control.c 1998-06-15 12:53:16.000000000 +0200 6284 +++ netqmail-1.06/control.c 201 6-11-22 21:03:57.108528232+01006593 +++ netqmail-1.06/control.c 2019-02-27 20:57:13.384025136 +0100 6285 6594 @@ -85,6 +85,82 @@ 6286 6595 return 1; … … 6368 6677 diff -ruN ../netqmail-1.06-original/control.h netqmail-1.06/control.h 6369 6678 --- ../netqmail-1.06-original/control.h 1998-06-15 12:53:16.000000000 +0200 6370 +++ netqmail-1.06/control.h 201 6-11-22 21:03:57.108528232+01006679 +++ netqmail-1.06/control.h 2019-02-27 20:57:13.384025136 +0100 6371 6680 @@ -3,8 +3,10 @@ 6372 6681 … … 6382 6691 diff -ruN ../netqmail-1.06-original/date822fmt.c netqmail-1.06/date822fmt.c 6383 6692 --- ../netqmail-1.06-original/date822fmt.c 1998-06-15 12:53:16.000000000 +0200 6384 +++ netqmail-1.06/date822fmt.c 201 6-11-22 21:03:57.108528232+01006693 +++ netqmail-1.06/date822fmt.c 2019-02-27 20:57:13.385025125 +0100 6385 6694 @@ -1,3 +1,4 @@ 6386 6695 +#include <time.h> … … 6449 6758 diff -ruN ../netqmail-1.06-original/dk-filter.9 netqmail-1.06/dk-filter.9 6450 6759 --- ../netqmail-1.06-original/dk-filter.9 1970-01-01 01:00:00.000000000 +0100 6451 +++ netqmail-1.06/dk-filter.9 20 16-11-22 21:03:57.108528232 +01006452 @@ -0,0 +1, 102@@6760 +++ netqmail-1.06/dk-filter.9 2020-04-10 11:08:43.313802048 +0200 6761 @@ -0,0 +1,98 @@ 6453 6762 +.TH dk-filter 8 6454 6763 +.SH NAME … … 6472 6781 +It uses the libdkim and OpenSSL libraries. To sign a message, set the 6473 6782 +.B DKIMSIGN 6474 + or6475 +.B DKSIG IN6476 +environment variable sto the pathname of the private key that will be6783 +environment variable (for DKIM signing) or 6784 +.B DKSIGN 6785 +environment variable (for DK signing) to the pathname of the private key that will be 6477 6786 +used to sign the message. If there is a % character in the environment 6478 6787 +variable, it is removed and replaced by the domain name in the From: header. … … 6482 6791 +After all substitutions, if the key file does not exist, the message will not be signed. 6483 6792 +If there is no % and the file does not exist, the message will be rejected with error 35. 6793 +The default private key QMAILHOME/control/domainkeys/default can be overriden by the 6794 +\fBDKIM_DEFAULT_KEY\fR environment variable. 6795 + 6484 6796 +The selector (s=) will be taken from the basename of the file. 6485 6797 +The private key should be created by … … 6519 6831 +.EE 6520 6832 + 6521 +.B dk-filter 6522 +uses the domain found in the Sender: header to set the domain tag. If not it uses the From: header. You can override this by 6523 +setting 6524 +.B DKIMDOMAIN 6525 +environment variable. 6526 +.B DKIMDOMAIN 6527 +can be set to an email address or a domain (without the at sign). 6528 +To verify a message, set the 6529 +.B DKIMVERIFY 6530 +or 6531 +.B DKVERIFY 6532 +environment variables 6533 +.B dk-filter 6534 +always inserts the 6535 +.B DKIM-Status 6536 +or 6537 +.B DomainKey-Status 6538 +header, so that messages can be 6539 +rejected later at delivery time, or in the mail reader. In that case you may set 6540 +.B DKIMVERIFY 6541 +or 6542 +.B DKVERIFY 6543 +to an empty string. 6544 +.B dk-filter 6545 +does not use any signing practice byd default. You can override this by setting the SIGN_PRACTICE to ssp or adsp (lowercase). 6833 +when signing \fBdk-filter\fR uses the domain found in the Return-Path, Sender, From headers to set 6834 +the domain tag. If not it uses the value of \fBDKIMDOMAIN\fR environment 6835 +variable. \fBDKIMDOMAIN\fR can be set to an email address or a domain (without the at sign). 6836 + 6837 +To verify a message, set the \fBDKIMVERIFY\fR or \fBDKVERIFY\fR environment variables. 6838 +\fBdk-filter\fR always inserts the \fBDKIM-Status\fR or \fBDomainKey-Status\fR header, so 6839 +that messages can be rejected later at delivery time, or in the mail reader. In that case 6840 +you may set \fBDKIMVERIFY\fR or \fBDKVERIFY\fR to an empty string. The exit code of \fBdk-filter\fR 6841 +can be fine tuned by setting \fBDKIMVERIFY\fR environment variable. See \fBdkim(8)\fR for a detailed 6842 +description on setting the \fBDKIMVERIFY\fR environment variable. 6843 + 6844 +\fBdk-filter\fR does not use any signing practice by default. You can override this by setting 6845 +the \fBSIGN_PRACTICE\fR to ssp or adsp (lowercase). 6846 + 6847 +If neither of these environment variables (\fBDKIMSIGN\fR, \fBDKSIGN\fR, \fBDKIMVERIFY\fR, \fBDKVERIFY\fR) are defined, \fBdk-filter\fR 6848 +will do signing by default. 6849 + 6850 +You can set environment variable \fBNODK\fR to disable domainkeys and \fBNODKIM\fR to disable \fBDKIM\fR. 6546 6851 + 6547 6852 +.SH "EXIT CODES" … … 6555 6860 diff -ruN ../netqmail-1.06-original/dk-filter.sh netqmail-1.06/dk-filter.sh 6556 6861 --- ../netqmail-1.06-original/dk-filter.sh 1970-01-01 01:00:00.000000000 +0100 6557 +++ netqmail-1.06/dk-filter.sh 20 16-11-22 21:03:57.109528199 +01006558 @@ -0,0 +1,3 15@@6862 +++ netqmail-1.06/dk-filter.sh 2020-07-29 15:59:13.351023490 +0200 6863 @@ -0,0 +1,367 @@ 6559 6864 +# 6560 6865 +# $Log: dk-filter.sh,v $ 6866 +# Revision 1.22 2019-06-24 23:19:57+05:30 Cprogrammer 6867 +# added code for -d option in DKIMSIGNOPTIONS 6868 +# 6869 +# Revision 1.21 2019-01-14 00:10:00+05:30 Cprogrammer 6870 +# added -S, -f option to verify signatures with unsigned subject, unsigned from 6871 +# 6872 +# Revision 1.20 2017-03-09 16:38:15+05:30 Cprogrammer 6873 +# FHS changes 6874 +# 6875 +# Revision 1.19 2016-05-17 23:11:42+05:30 Cprogrammer 6876 +# fix for configurable control directory 6877 +# 6878 +# Revision 1.18 2014-03-12 08:50:48+05:30 Cprogrammer 6879 +# bug - fixed signing when env variables DKSIGN or DKIMSIGN were set 6880 +# 6881 +# Revision 1.17 2013-09-03 23:04:30+05:30 Cprogrammer 6882 +# set signing as default if both DKSIGN and DKIMSIGN are not defined 6883 +# 6884 +# Revision 1.16 2013-08-17 15:59:21+05:30 Cprogrammer 6885 +# do not treat duplicate DomainKey-Signature as an error 6886 +# 6887 +# Revision 1.15 2013-08-17 15:02:06+05:30 Cprogrammer 6888 +# fixed syntax errors and private key lookup 6889 +# 6561 6890 +# Revision 1.14 2011-02-10 22:47:01+05:30 Cprogrammer 6562 6891 +# fixed exit code of dk-filter when doing verification … … 6604 6933 +# Initial revision 6605 6934 +# 6606 +# $Id: dk-filter.sh,v 1. 14 2011-02-10 22:47:01+05:30 Cprogrammer Stabmbhangui $6935 +# $Id: dk-filter.sh,v 1.22 2019-06-24 23:19:57+05:30 Cprogrammer Exp mbhangui $ 6607 6936 +# 6608 6937 +if [ -z "$QMAILREMOTE" -a -z "$QMAILLOCAL" ]; then … … 6614 6943 +dkverify=0 6615 6944 +dkimverify=0 6616 +if [ -z "$DKSIGN" -a -z "$DKVERIFY" ] ; then 6617 + DKSIGN=QMAILHOME/control/domainkeys/%/default 6618 + dksign=2 6945 +if [ -z "$DEFAULT_DKIM_KEY" ] ; then 6946 + default_key=QMAILHOME/control/domainkeys/default 6947 +else 6948 + default_key=$DEFAULT_DKIM_KEY 6619 6949 +fi 6620 +if [ -z "$DKIMSIGN" -a -z "$DKIMVERIFY" ] ; then 6621 + DKIMSIGN=QMAILHOME/control/domainkeys/%/default 6622 + dkimsign=2 6950 +if [ -z "$NODK" -a -x QMAILHOME/bin/dktest -a -z "$DKVERIFY" ] ; then 6951 + if [ -z "$DKSIGN" ] ; then 6952 + DKSIGN=QMAILHOME/control/domainkeys/%/default 6953 + dksign=2 6954 + elif [ " $DKSIGN" = " QMAILHOME/control/domainkeys/%/default" ] ; then 6955 + dksign=2 6956 + fi 6623 6957 +fi 6624 +if [ ! -z "$DKSIGN" ] ; then 6958 +if [ -z "$NODKIM" -a -x QMAILHOME/bin/dkim -a -z "$DKIMVERIFY" ] ; then 6959 + if [ -z "$DKIMSIGN" ] ; then 6960 + DKIMSIGN=QMAILHOME/control/domainkeys/%/default 6961 + dkimsign=2 6962 + elif [ " $DKIMSIGN" = " QMAILHOME/control/domainkeys/%/default" ] ; then 6963 + dkimsign=2 6964 + fi 6965 +fi 6966 +if [ -z "$NODK" -a -n "$DKSIGN" ] ; then 6625 6967 + if [ ! -f QMAILHOME/bin/dktest ] ; then 6626 6968 + echo "QMAILHOME/bin/dktest: No such file or directory" 1>&2 … … 6632 6974 + percent_found=1 6633 6975 + fi 6634 + if [ ! " $_SENDER" = " " ] ; then 6976 + if [ -n "$DKIMDOMAIN" ] && [ -z "$_SENDER" ] ; then 6977 + dkkeyfn=`echo $DKSIGN | sed s{%{$DKIMDOMAIN{g` 6978 + elif [ ! " $_SENDER" = " " ] ; then 6635 6979 + # replace '%' in filename with domain 6636 6980 + domain=`echo $_SENDER | cut -d@ -f2` … … 6640 6984 + fi 6641 6985 + if [ $dksign -eq 2 -a ! -f $dkkeyfn ] ; then 6642 + dkkeyfn= QMAILHOME/control/domainkeys/default6986 + dkkeyfn=$default_key 6643 6987 + fi 6644 6988 + if [ -f $dkkeyfn ] ; then … … 6652 6996 + dkselector=`basename $dkkeyfn` 6653 6997 +fi 6654 +if [ ! -z"$DKIMSIGN" ] ; then6998 +if [ -z "$NODKIM" -a -n "$DKIMSIGN" ] ; then 6655 6999 + if [ ! -f QMAILHOME/bin/dkim ] ; then 6656 7000 + echo "QMAILHOME/bin/dkim: No such file or directory" 1>&2 … … 6662 7006 + percent_found=1 6663 7007 + fi 6664 + if [ ! " $_SENDER" = " " ] ; then 7008 + if [ -n "$DKIMDOMAIN" ] && [ -z "$_SENDER" ] ; then 7009 + dkimkeyfn=`echo $DKIMSIGN | sed s{%{$DKIMDOMAIN{g` 7010 + elif [ ! " $_SENDER" = " " ] ; then 6665 7011 + # replace '%' in filename with domain 6666 7012 + domain=`echo $_SENDER | cut -d@ -f2` … … 6670 7016 + fi 6671 7017 + if [ $dkimsign -eq 2 -a ! -f $dkimkeyfn ] ; then 6672 + dkimkeyfn= QMAILHOME/control/domainkeys/default7018 + dkimkeyfn=$default_key 6673 7019 + fi 6674 7020 + if [ -f $dkimkeyfn ] ; then … … 6678 7024 + fi 6679 7025 + if [ $dkimsign -eq 0 -a $percent_found -ne 1 ] ; then 6680 + exit 32 7026 + exit 32 # private key does not exist 6681 7027 + fi 6682 7028 + dkimselector=`basename $dkimkeyfn` 6683 7029 +fi 6684 +if [ ! -z"$DKVERIFY" ] ; then7030 +if [ -z "$NODK" -a -n "$DKVERIFY" ] ; then 6685 7031 + if [ ! -f QMAILHOME/bin/dktest ] ; then 6686 7032 + echo "QMAILHOME/bin/dktest: No such file or directory" 1>&2 … … 6689 7035 + dkverify=1 6690 7036 +fi 6691 +if [ ! -z"$DKIMVERIFY" ] ; then7037 +if [ -z "$NODKIM" -a -n "$DKIMVERIFY" ] ; then 6692 7038 + if [ ! -f QMAILHOME/bin/dkim ] ; then 6693 7039 + echo "QMAILHOME/bin/dkim: No such file or directory" 1>&2 … … 6730 7076 + -c) 6731 7077 + dkimopts="$dkimopts -c $2" 7078 + shift 7079 + ;; 7080 + 7081 + -d) 7082 + dkimopts="$dkimopts -d $2" 6732 7083 + shift 6733 7084 + ;; … … 6824 7175 + fi 6825 7176 + exec 0</tmp/dk.$$ 6826 + #QMAILHOME/bin/dktest -h -s $dkkeyfn6827 7177 + eval $dkopts 6828 7178 + exit_val=$? 6829 7179 + # allow error due to duplicate DomainKey-Header 6830 + if [ $exit_val -ne 0 -a $exit_val -ne 6] ; then7180 + if [ $exit_val -ne 0 -a $exit_val -ne 12 ] ; then 6831 7181 + /bin/rm -f /tmp/dk.$$ 6832 7182 + exit $exit_val … … 6843 7193 + fi 6844 7194 + exec 0</tmp/dk.$$ 6845 + QMAILHOME/bin/dkim -p $practice -v 7195 + dkimvargs="-p $practice" 7196 + if [ -n "$UNSIGNED_SUBJECT" ] ; then 7197 + dkimvargs="$dkimvargs -S" 7198 + fi 7199 + if [ -n "$UNSIGNED_FROM" ] ; then 7200 + dkimvargs="$dkimvargs -f" 7201 + fi 7202 + QMAILHOME/bin/dkim $dkimvargs -v 6846 7203 + ret=$? 6847 7204 + case $ret in … … 6874 7231 diff -ruN ../netqmail-1.06-original/dkim.9 netqmail-1.06/dkim.9 6875 7232 --- ../netqmail-1.06-original/dkim.9 1970-01-01 01:00:00.000000000 +0100 6876 +++ netqmail-1.06/dkim.9 20 18-04-03 14:46:51.362411599+02006877 @@ -0,0 +1, 98 @@7233 +++ netqmail-1.06/dkim.9 2020-04-09 19:43:56.494473495 +0200 7234 @@ -0,0 +1,108 @@ 6878 7235 +.TH dkim 8 6879 7236 +.SH NAME … … 6892 7249 + 6893 7250 +.EX 6894 + (./dkim -s QMAILHOME/control/domainkeys/dog </tmp/testmsg; cat /tmp/testmsg)\7251 + (./dkim -s INDIMAIL/control/domainkeys/dog </tmp/testmsg; cat /tmp/testmsg)\ 6895 7252 + | ./dkim -v 6896 7253 +.EE … … 6924 7281 +.TP 6925 7282 +-l 6926 +include body length tag 7283 +include body length tag when signing. Honor body length tag when verifying 6927 7284 +.TP 6928 7285 +-q … … 6934 7291 +-f 6935 7292 +issue error if not all message's From headers are in signature 7293 +.TP 7294 +-S 7295 +Allow unsigned subject in signature 6936 7296 +.TP 6937 7297 +-h … … 6946 7306 +-c \fIcanonicalization\fR 6947 7307 +r for relaxed [DEFAULT], s - simple, t relaxed/simple, u - simple/relaxed 7308 + 7309 +.TP 6948 7310 +-d \fIdomain\fR 6949 +the domain tag, if not provided, determined from the sender/from header7311 +the domain tag, if not provided, determined from the return-path/sender/from header 6950 7312 +.TP 6951 7313 +-i \fIidentity\fR … … 6967 7329 +this help 6968 7330 + 7331 +.SH Return Value 7332 +When signing, \fBdkim\fR returns 0 on success and non-zero on any failure. For verification, you can set the 7333 +environment varable \fBDKIMVERIFY\fR. Refer to qmail-dkim(8) for a full description of the \fBDKIMVERIFY\fR 7334 +environment variable 7335 + 6969 7336 +.SH "SEE ALSO" 6970 7337 +dktest(8), … … 6976 7343 diff -ruN ../netqmail-1.06-original/dkim.c netqmail-1.06/dkim.c 6977 7344 --- ../netqmail-1.06-original/dkim.c 1970-01-01 01:00:00.000000000 +0100 6978 +++ netqmail-1.06/dkim.c 201 8-04-03 14:46:51.363411603+02006979 @@ -0,0 +1,8 99@@7345 +++ netqmail-1.06/dkim.c 2019-06-19 09:46:59.689809564 +0200 7346 @@ -0,0 +1,871 @@ 6980 7347 +/* 6981 7348 + * $Log: dkim.c,v $ 7349 + * Revision 1.23 2019-06-14 21:24:59+05:30 Cprogrammer 7350 + * BUG - honor body length tag in verification 7351 + * 7352 + * Revision 1.22 2019-01-13 10:10:27+05:30 Cprogrammer 7353 + * added missing usage string for allowing unsigned subject. 7354 + * 7355 + * Revision 1.21 2018-08-08 23:57:02+05:30 Cprogrammer 7356 + * issue success if at lease one one good signature is found 7357 + * 7358 + * Revision 1.20 2018-05-22 10:03:26+05:30 Cprogrammer 7359 + * changed return type of writeHeader() to void 7360 + * 6982 7361 + * Revision 1.19 2016-03-01 16:23:38+05:30 Cprogrammer 6983 7362 + * added -S option to allow email with unsigned subject … … 7109 7488 + fprintf(stderr, "t include a timestamp tag\n"); 7110 7489 + fprintf(stderr, "h include Copied Headers\n"); 7490 + fprintf(stderr, "f allow Unsigned From (default is to reject if From field is not signed)\n"); 7491 + fprintf(stderr, "S allow Unsigned Subject (default is to reject if Subject field is not signed)\n"); 7111 7492 + fprintf(stderr, "v verify the message\n"); 7112 7493 + fprintf(stderr, "p <ssp|adsp> 0 - disable practice (default), 1- SSP, or 2 - ADSP verification\n"); … … 7120 7501 + fprintf(stderr, "z <hash> 1 for sha1, 2 for sha256, 3 for both\n"); 7121 7502 +#endif 7122 + fprintf(stderr, "f 0 = From headers not included in the signature are not allowed\n");7123 + fprintf(stderr, " 1 = allowed\n");7124 7503 + fprintf(stderr, "y <selector> the selector tag DEFAULT=private\n"); 7125 7504 + fprintf(stderr, "s <privkeyfile> sign the message using the private key in privkeyfile\n"); 7505 + fprintf(stderr, "V set verbose mode\n"); 7126 7506 + fprintf(stderr, "H this help\n"); 7127 7507 + exit(1); … … 7135 7515 + ch = c; 7136 7516 + t = s; 7137 + for (;;) 7138 + { 7517 + for (;;) { 7139 7518 + if (!*t) 7140 7519 + break; … … 7187 7566 + * Allows you to add the headers contain the results and DKIM ADSP 7188 7567 + */ 7189 + intwriteHeader(int ret, int resDKIMSSP, int resDKIMADSP, int useSSP, int useADSP )7568 +void writeHeader(int ret, int resDKIMSSP, int resDKIMADSP, int useSSP, int useADSP ) 7190 7569 +{ 7191 7570 + char *dkimStatus, *sspStatus, *adspStatus; … … 7286 7665 + } 7287 7666 + } 7288 + if (useADSP && resDKIMADSP != -1) 7289 + { 7667 + if (useADSP && resDKIMADSP != -1) { 7290 7668 + switch(resDKIMADSP) 7291 7669 + { … … 7325 7703 + values[i] = 0; 7326 7704 + key = 0; 7327 + for(ptr = list;*ptr;) 7328 + { 7705 + for(ptr = list;*ptr;) { 7329 7706 + if ((*ptr == ' ') || (*ptr == '\t') || (*ptr == '\r') || (*ptr == '\n')) /*- FWS */ 7330 7707 + *ptr++ = 0; 7331 7708 + if (!key) 7332 7709 + key = ptr; 7333 + if (*ptr == '=') 7334 + { 7710 + if (*ptr == '=') { 7335 7711 + *ptr = 0; 7336 + for (i = 0;letters[i];i++) 7337 + { 7338 + if (!strcmp(letters[i], key)) 7339 + { 7712 + for (i = 0;letters[i];i++) { 7713 + if (!strcmp(letters[i], key)) { 7340 7714 + ptr++; 7341 + for (;*ptr;) 7342 + { 7343 + if ((*ptr == ' ') || (*ptr == '\t') || (*ptr == '\r') || (*ptr == '\n')) 7344 + { 7715 + for (;*ptr;) { 7716 + if ((*ptr == ' ') || (*ptr == '\t') || (*ptr == '\r') || (*ptr == '\n')) { 7345 7717 + ptr++; 7346 7718 + continue; … … 7353 7725 + if (*ptr) 7354 7726 + *ptr++ = 0; 7355 + for(;tmp != values[i];tmp--) /*- RFC 4871 3.2 */ 7356 + { 7357 + if ((*tmp == ' ') || (*tmp == '\t') || (*tmp == '\r') || (*tmp == '\n')) 7358 + { 7727 + for(;tmp != values[i];tmp--) /*- RFC 4871 3.2 */ { 7728 + if ((*tmp == ' ') || (*tmp == '\t') || (*tmp == '\r') || (*tmp == '\n')) { 7359 7729 + *tmp = 0; 7360 7730 + continue; … … 7381 7751 + 7382 7752 + *bTesting = 0; 7383 + if (!(query = (char *) DKIM_MALLOC(strlen("_ssp._domainkey.") + strlen(domain) + 1))) 7384 + { 7753 + if (!(query = (char *) DKIM_MALLOC(strlen("_ssp._domainkey.") + strlen(domain) + 1))) { 7385 7754 + fprintf(stderr, "malloc: %d: %s\n", strlen("_ssp._domainkey.") + strlen(domain) + 1, 7386 7755 + strerror(errno)); … … 7390 7759 + results = dns_text(query); 7391 7760 + DKIM_MFREE(query); 7392 + if (!strcmp(results, "e=temp;")) 7393 + { 7761 + if (!strcmp(results, "e=temp;")) { 7394 7762 + DKIM_MFREE(results); 7395 7763 + return DKIM_SSP_TEMPFAIL; 7396 7764 + } else 7397 + if (!strcmp(results, "e=perm;")) 7398 + { 7765 + if (!strcmp(results, "e=perm;")) { 7399 7766 + DKIM_MFREE(results); 7400 7767 + results = dns_text(domain); 7401 + if (!strcmp(results, "e=temp;")) 7402 + { 7768 + if (!strcmp(results, "e=temp;")) { 7403 7769 + DKIM_MFREE(results); 7404 7770 + return DKIM_SSP_TEMPFAIL; 7405 7771 + } else 7406 + if (!strcmp(results, "e=perm;")) 7407 + { 7772 + if (!strcmp(results, "e=perm;")) { 7408 7773 + DKIM_MFREE(results); 7409 7774 + return DKIM_SSP_SCOPE; … … 7411 7776 + bIsParentSSP = 1; 7412 7777 + } 7413 + if (!ParseTagValues(results, tags, values)) 7414 + { 7778 + if (!ParseTagValues(results, tags, values)) { 7415 7779 + DKIM_MFREE(results); 7416 7780 + return DKIM_SSP_UNKNOWN; … … 7427 7791 + if (values[1] != NULL) { 7428 7792 + char *s, *p; 7429 + for (p = values[1], s = values[1]; *p; p++) 7430 + { 7793 + for (p = values[1], s = values[1]; *p; p++) { 7431 7794 + if (*p == '|') 7432 7795 + *p = 0; … … 7460 7823 + 7461 7824 + results = dns_text(domain); 7462 + if (!strcmp(results, "e=perm;")) 7463 + { 7825 + if (!strcmp(results, "e=perm;")) { 7464 7826 + DKIM_MFREE(results); 7465 7827 + return DKIM_ADSP_SCOPE; 7466 7828 + } else 7467 + if (!strcmp(results, "e=temp;")) 7468 + { 7829 + if (!strcmp(results, "e=temp;")) { 7469 7830 + DKIM_MFREE(results); 7470 7831 + return DKIM_ADSP_TEMPFAIL; 7471 7832 + } 7472 + if (!(query = (char *) DKIM_MALLOC(strlen((char *) "_adsp._domainkey.") + strlen(domain) + 1))) 7473 + { 7833 + if (!(query = (char *) DKIM_MALLOC(strlen((char *) "_adsp._domainkey.") + strlen(domain) + 1))) { 7474 7834 + fprintf(stderr, "malloc: %d: %s\n", strlen("_adsp._domainkey.") + strlen(domain) + 1, 7475 7835 + strerror(errno)); … … 7479 7839 + results = dns_text(query); 7480 7840 + DKIM_MFREE(query); 7481 + if (!strcmp(results, "e=perm;")) 7482 + { 7841 + if (!strcmp(results, "e=perm;")) { 7483 7842 + DKIM_MFREE(results); 7484 7843 + return DKIM_ADSP_SCOPE; 7485 7844 + } else 7486 + if (!strcmp(results, "e=temp;")) 7487 + { 7845 + if (!strcmp(results, "e=temp;")) { 7488 7846 + DKIM_MFREE(results); 7489 7847 + return DKIM_ADSP_TEMPFAIL; 7490 7848 + } 7491 + if (!ParseTagValues(results, tags, values)) 7492 + { 7849 + if (!ParseTagValues(results, tags, values)) { 7493 7850 + DKIM_MFREE(results); 7494 7851 + return DKIM_ADSP_UNKNOWN; … … 7541 7898 + strcpy(opts.szRequiredHeaders, "NonExistent"); 7542 7899 + opts.pfnHeaderCallback = SignThisHeader; 7543 + while (1) 7544 + { 7900 + while (1) { 7545 7901 + if ((ch = getopt(argc, argv, "lqtfhHSvVp:b:c:d:i:s:x:y:z:")) == -1) 7546 7902 + break; … … 7548 7904 + { 7549 7905 + case 'l': /*- body length tag */ 7906 + vopts.nHonorBodyLengthTag = 1; 7550 7907 + opts.nIncludeBodyLengthTag = 1; 7551 7908 + break; … … 7684 8041 + } 7685 8042 + if (bSign) { /*- sign */ 7686 + if (!PrivKeyFile) 7687 + { 8043 + if (!PrivKeyFile) { 7688 8044 + fprintf(stderr, "Private Key not provided\n"); 7689 8045 + usage(); … … 7701 8057 + return (1); 7702 8058 + } 7703 + if (fstat(PrivKeyFD, &statbuf) == -1) 7704 + { 8059 + if (fstat(PrivKeyFD, &statbuf) == -1) { 7705 8060 + fprintf(stderr, "fstat: %s: %s\n", PrivKeyFile, strerror(errno)); 7706 8061 + return (1); 7707 8062 + } 7708 + if (!(PrivKey = (char *) DKIM_MALLOC(sizeof(char) * ((nPrivKeyLen = statbuf.st_size) + 1)))) 7709 + { 8063 + if (!(PrivKey = (char *) DKIM_MALLOC(sizeof(char) * ((nPrivKeyLen = statbuf.st_size) + 1)))) { 7710 8064 + fprintf(stderr, "malloc: %ld bytes: %s\n", statbuf.st_size + 1, strerror(errno)); 7711 8065 + return (1); 7712 8066 + } 7713 + if (read(PrivKeyFD, PrivKey, nPrivKeyLen) != nPrivKeyLen) 7714 + { 8067 + if (read(PrivKeyFD, PrivKey, nPrivKeyLen) != nPrivKeyLen) { 7715 8068 + fprintf(stderr, "%s: read: %s\n", strerror(errno), program); 7716 8069 + return (1); … … 7718 8071 + close(PrivKeyFD); 7719 8072 + PrivKey[nPrivKeyLen] = '\0'; 7720 + if (DKIMSignInit(&ctxt, &opts) != DKIM_SUCCESS) 7721 + { 8073 + if (DKIMSignInit(&ctxt, &opts) != DKIM_SUCCESS) { 7722 8074 + fprintf(stderr, "DKIMSignInit: failed to initialize signature %s\n", PrivKeyFile); 7723 8075 + return (1); 7724 8076 + } 7725 + for (;;) 7726 + { 7727 + if ((ret = read(0, Buffer, sizeof(Buffer) - 1)) == -1) 7728 + { 8077 + for (;;) { 8078 + if ((ret = read(0, Buffer, sizeof(Buffer) - 1)) == -1) { 7729 8079 + fprintf(stderr, "read: %s\n", strerror(errno)); 7730 8080 + DKIMSignFree(&ctxt); … … 7733 8083 + if (!ret) 7734 8084 + break; 7735 + if (DKIMSignProcess(&ctxt, Buffer, ret) == DKIM_INVALID_CONTEXT) 7736 + { 8085 + if (DKIMSignProcess(&ctxt, Buffer, ret) == DKIM_INVALID_CONTEXT) { 7737 8086 + fprintf(stderr, "DKIMSignProcess: DKIMContext structure invalid for this operation\n"); 7738 8087 + DKIMSignFree(&ctxt); … … 7740 8089 + } 7741 8090 + } 7742 + if (DKIMSignGetSig2(&ctxt, PrivKey, &pSig) == DKIM_INVALID_CONTEXT) 7743 + { 8091 + if (DKIMSignGetSig2(&ctxt, PrivKey, &pSig) == DKIM_INVALID_CONTEXT) { 7744 8092 + fprintf(stderr, "DKIMSignProcess: DKIMContext structure invalid for this operation\n"); 7745 8093 + DKIMSignFree(&ctxt); 7746 8094 + return (1); 7747 8095 + } 7748 + if (pSig) 7749 + { 8096 + if (pSig) { 7750 8097 + fwrite(pSig, 1, strlen(pSig), stdout); 7751 8098 + fwrite("\n", 1, 1, stdout); … … 7766 8113 + vopts.nSubjectRequired = nAllowUnsignedSubject; 7767 8114 + DKIMVerifyInit(&ctxt, &vopts); /*- this is always successful */ 7768 + for (;;) 7769 + { 7770 + if ((i = read(0, Buffer, sizeof(Buffer) - 1)) == -1) 7771 + { 8115 + for (;;) { 8116 + if ((i = read(0, Buffer, sizeof(Buffer) - 1)) == -1) { 7772 8117 + fprintf(stderr, "read: %s\n", strerror(errno)); 7773 8118 + DKIMVerifyFree(&ctxt); … … 7783 8128 + break; 7784 8129 + } 7785 + if (!ret) 7786 + {7787 + if ( (ret = DKIMVerifyResults(&ctxt, &sCount, &sSize)) != DKIM_SUCCESS)8130 + if (!ret) { 8131 + ret = DKIMVerifyResults(&ctxt, &sCount, &sSize); 8132 + if (ret != DKIM_SUCCESS && ret != DKIM_3PS_SIGNATURE && ret != DKIM_NEUTRAL) 7788 8133 + dkim_error(ret); 7789 8134 + if ((ret = DKIMVerifyGetDetails(&ctxt, &nSigCount, &pDetails, szPolicy)) != DKIM_SUCCESS) 7790 8135 + dkim_error(ret); 7791 + else 7792 + { 7793 + for (ret = 0,i = 0; i < nSigCount; i++) { 8136 + else { 8137 + for (ret = DKIM_FAIL, i = 0; i < nSigCount; i++) { 7794 8138 + if (verbose) 7795 8139 + printf("Signature # %02d: ", i + 1); 7796 + if (pDetails[i].nResult >= 0) 7797 + {8140 + if (pDetails[i].nResult >= 0) { 8141 + ret = 0; 7798 8142 + if (verbose) 7799 8143 + printf("Success\n"); 7800 8144 + continue; 7801 + } else 7802 + {7803 + ret = pDetails[i].nResult;8145 + } else { 8146 + if (ret == DKIM_FAIL) 8147 + ret = pDetails[i].nResult; 7804 8148 + if (verbose) 7805 + printf("Failure %d\n", ret);8149 + printf("Failure %d\n", pDetails[i].nResult); 7806 8150 + } 7807 8151 + } … … 7811 8155 + } 7812 8156 + if (ret < 0 || ret == DKIM_3PS_SIGNATURE) { 7813 + if (useADSP) 7814 + { 8157 + if (useADSP) { 7815 8158 + char *domain; 7816 8159 + … … 7826 8169 + ret = DKIM_NEUTRAL; 7827 8170 + } else 7828 + if (useSSP) 7829 + { 8171 + if (useSSP) { 7830 8172 + int bTestingPractices = 0; 7831 8173 + char *domain; … … 7848 8190 + DKIMVerifyFree(&ctxt); 7849 8191 + writeHeader(ret, resDKIMSSP, resDKIMADSP, useSSP, useADSP); 7850 + if ((dkimverify = getenv("DKIMVERIFY"))) 7851 + { 7852 + if (ret < 0) 7853 + { 8192 + if ((dkimverify = getenv("DKIMVERIFY"))) { 8193 + if (ret < 0) { 7854 8194 + if (dkimverify[str_chr(dkimverify, 'F' - ret)]) 7855 8195 + ret = 14; /*- return permanent error */ 7856 8196 + if (dkimverify[str_chr(dkimverify, 'f' - ret)]) 7857 8197 + ret = 88; /*- return temporary error */ 7858 + } else 7859 + { 8198 + } else { 7860 8199 + if (dkimverify[str_chr(dkimverify, 'A' + ret)]) 7861 8200 + ret = 14; /*- return permanent error */ … … 7873 8212 +getversion_dkim_c() 7874 8213 +{ 7875 + static char *x = (char *) "$Id: dkim.c,v 1. 19 2016-03-01 16:23:38+05:30 Cprogrammer Exp mbhangui $";8214 + static char *x = (char *) "$Id: dkim.c,v 1.23 2019-06-14 21:24:59+05:30 Cprogrammer Exp mbhangui $"; 7876 8215 + 7877 8216 + x++; … … 7879 8218 diff -ruN ../netqmail-1.06-original/dkim.h netqmail-1.06/dkim.h 7880 8219 --- ../netqmail-1.06-original/dkim.h 1970-01-01 01:00:00.000000000 +0100 7881 +++ netqmail-1.06/dkim.h 201 8-04-03 14:46:51.364411606 +02008220 +++ netqmail-1.06/dkim.h 2019-02-27 20:57:13.386025114 +0100 7882 8221 @@ -0,0 +1,193 @@ 7883 8222 +/* … … 8076 8415 diff -ruN ../netqmail-1.06-original/dkimbase.cpp netqmail-1.06/dkimbase.cpp 8077 8416 --- ../netqmail-1.06-original/dkimbase.cpp 1970-01-01 01:00:00.000000000 +0100 8078 +++ netqmail-1.06/dkimbase.cpp 201 8-04-03 14:46:51.363411603+02008079 @@ -0,0 +1,33 6@@8417 +++ netqmail-1.06/dkimbase.cpp 2019-06-19 09:46:20.131250010 +0200 8418 @@ -0,0 +1,339 @@ 8080 8419 +/* 8081 8420 + * $Log: dkimbase.cpp,v $ 8421 + * Revision 1.5 2019-06-14 21:24:03+05:30 Cprogrammer 8422 + * BUG - honor body length tag in verification 8423 + * 8082 8424 + * Revision 1.4 2017-09-05 10:58:26+05:30 Cprogrammer 8083 8425 + * removed compiler warnings … … 8242 8584 + // process body line 8243 8585 + int Result = ProcessBody(m_Line, m_LinePos, bEOF); 8244 + if (Result != DKIM_SUCCESS ) {8586 + if (Result != DKIM_SUCCESS && Result != DKIM_FINISHED_BODY) { 8245 8587 + m_LinePos = 0; 8246 8588 + return Result; … … 8410 8752 +getversion_dkimbase_cpp() 8411 8753 +{ 8412 + static char *x = (char *) "$Id: dkimbase.cpp,v 1. 4 2017-09-05 10:58:26+05:30 Cprogrammer Exp mbhangui $";8754 + static char *x = (char *) "$Id: dkimbase.cpp,v 1.5 2019-06-14 21:24:03+05:30 Cprogrammer Exp mbhangui $"; 8413 8755 + 8414 8756 + x++; … … 8416 8758 diff -ruN ../netqmail-1.06-original/dkimbase.h netqmail-1.06/dkimbase.h 8417 8759 --- ../netqmail-1.06-original/dkimbase.h 1970-01-01 01:00:00.000000000 +0100 8418 +++ netqmail-1.06/dkimbase.h 201 8-04-03 14:46:51.363411603 +02008760 +++ netqmail-1.06/dkimbase.h 2019-02-27 20:57:13.386025114 +0100 8419 8761 @@ -0,0 +1,72 @@ 8420 8762 +/* … … 8492 8834 diff -ruN ../netqmail-1.06-original/dkimdns.cpp netqmail-1.06/dkimdns.cpp 8493 8835 --- ../netqmail-1.06-original/dkimdns.cpp 1970-01-01 01:00:00.000000000 +0100 8494 +++ netqmail-1.06/dkimdns.cpp 201 8-04-03 14:46:51.364411606+02008495 @@ -0,0 +1,32 2@@8836 +++ netqmail-1.06/dkimdns.cpp 2019-05-23 15:12:30.128092884 +0200 8837 @@ -0,0 +1,329 @@ 8496 8838 +/* 8497 8839 + * $Log: dns.cpp,v $ … … 8671 9013 + n = rrdlen - txtpos; 8672 9014 + if ((*txt_strlen + n + 1) > txtlen) { 8673 + if (!(ptr = (char *) realloc(txt, (*txt_strlen + n) * 2))) 9015 + if (!(ptr = (char *) realloc(txt, (*txt_strlen + n) * 2))) { 9016 + free(txt); 9017 + txtlen = 0; 9018 + *txt_strlen = 0; 8674 9019 + return DNS_MEM; 9020 + } 9021 + txt = ptr; 8675 9022 + txtlen = (*txt_strlen + n) * 2; 8676 9023 + } … … 8706 9053 + total = 0; 8707 9054 + if (!dnresultlen) { 8708 + if (!(dnresult = (char *) malloc 9055 + if (!(dnresult = (char *) malloc((2 * PACKETSZ) * sizeof(char)))) 8709 9056 + return DNS_MEM; 8710 9057 + dnresultlen = 2 * PACKETSZ; … … 8721 9068 + if ((total + len + 1) >= dnresultlen) { 8722 9069 + if (!(ptr = (char *) realloc(dnresult, (total + len) * 2))) { 9070 + free(dnresult); 8723 9071 + dnresultlen = 0; 8724 9072 + if (txtlen) { … … 8728 9076 + return DNS_MEM; 8729 9077 + } 9078 + dnresult = ptr; 8730 9079 + dnresultlen = (total + len) * 2; 8731 9080 + } … … 8818 9167 diff -ruN ../netqmail-1.06-original/dkimdns.h netqmail-1.06/dkimdns.h 8819 9168 --- ../netqmail-1.06-original/dkimdns.h 1970-01-01 01:00:00.000000000 +0100 8820 +++ netqmail-1.06/dkimdns.h 201 8-04-03 14:46:51.364411606 +02009169 +++ netqmail-1.06/dkimdns.h 2019-02-27 20:57:13.387025103 +0100 8821 9170 @@ -0,0 +1,54 @@ 8822 9171 +/* … … 8876 9225 diff -ruN ../netqmail-1.06-original/dkimfuncs.cpp netqmail-1.06/dkimfuncs.cpp 8877 9226 --- ../netqmail-1.06-original/dkimfuncs.cpp 1970-01-01 01:00:00.000000000 +0100 8878 +++ netqmail-1.06/dkimfuncs.cpp 201 8-04-03 14:46:51.364411606 +02009227 +++ netqmail-1.06/dkimfuncs.cpp 2019-02-27 20:57:13.387025103 +0100 8879 9228 @@ -0,0 +1,236 @@ 8880 9229 +/* … … 8965 9314 + 8966 9315 +int DKIM_CALL 8967 +DKIMSignGetSig(DKIMContext *pSignContext, char *szPrivKey, char *szSignature, unsignedint nSigLength)9316 +DKIMSignGetSig(DKIMContext *pSignContext, char *szPrivKey, char *szSignature, int nSigLength) 8968 9317 +{ 8969 9318 + CDKIMSign *pSign = (CDKIMSign *) ValidateContext(pSignContext, true); … … 9068 9417 +DKIMVersion() 9069 9418 +{ 9070 + return (char *) "1. 4";9419 + return (char *) "1.5"; 9071 9420 +} 9072 9421 + … … 9116 9465 diff -ruN ../netqmail-1.06-original/dkimsign.cpp netqmail-1.06/dkimsign.cpp 9117 9466 --- ../netqmail-1.06-original/dkimsign.cpp 1970-01-01 01:00:00.000000000 +0100 9118 +++ netqmail-1.06/dkimsign.cpp 20 18-04-03 14:46:51.365411610 +02009119 @@ -0,0 +1,10 16@@9467 +++ netqmail-1.06/dkimsign.cpp 2020-04-10 18:20:19.279077900 +0200 9468 @@ -0,0 +1,1029 @@ 9120 9469 +/* 9121 9470 + * $Log: dkimsign.cpp,v $ 9471 + * Revision 1.17 2020-04-10 21:36:20+05:30 Cprogrammer 9472 + * fixed BUG with domain assignment 9473 + * 9474 + * Revision 1.16 2020-04-09 21:21:04+05:30 Cprogrammer 9475 + * check for null domain after DKIMDOMAIN replacement 9476 + * 9477 + * Revision 1.15 2019-06-26 19:08:18+05:30 Cprogrammer 9478 + * added sBouncedAddr variable for X-Bounced-Address header added by qmail-send for bounces 9479 + * 9480 + * Revision 1.14 2019-06-24 22:22:15+05:30 Cprogrammer 9481 + * use DKIMDOMAIN only if Return-Path, From, Sender header are empty 9482 + * 9483 + * Revision 1.13 2018-08-25 18:01:59+05:30 Cprogrammer 9484 + * fixed dkim signing for From address containing company name 9485 + * 9486 + * Revision 1.12 2018-05-23 13:07:58+05:30 Cprogrammer 9487 + * fixed compiler warnings 9488 + * 9122 9489 + * Revision 1.11 2017-09-05 10:59:03+05:30 Cprogrammer 9123 9490 + * removed compiler warnings … … 9387 9754 +CDKIMSign::GetHeaderParams(const string & sHdr) 9388 9755 +{ 9389 + string::size_type pos1, pos2; 9390 + 9756 + if (_strnicmp(sHdr.c_str(), "X-Bounced-Address:", 18) == 0) 9757 + sBouncedAddr.assign(sHdr.c_str() + 21); 9758 + else 9391 9759 + if (_strnicmp(sHdr.c_str(), "X", 1) == 0) 9392 9760 + return; 9393 + if (_strnicmp(sHdr.c_str(), "From:", 5) == 0) {9761 + if (_strnicmp(sHdr.c_str(), "From:", 5) == 0) 9394 9762 + sFrom.assign(sHdr.c_str() + 5); 9395 + pos1 = sFrom.find('('); 9396 + pos2 = sFrom.find(')'); 9397 + if (pos1 != 0 && pos1 != string::npos && pos2 != 0 && pos2 != string::npos) 9398 + sFrom.erase(pos1, pos2); 9399 + } 9400 + if (_strnicmp(sHdr.c_str(), "Sender:", 7) == 0) { 9763 + if (_strnicmp(sHdr.c_str(), "Sender:", 7) == 0) 9401 9764 + sSender.assign(sHdr.c_str() + 7); 9402 + pos1 = sSender.find('(');9403 + pos2 = sSender.find(')');9404 + if (pos1 != 0 && pos1 != string::npos && pos2 != 0 && pos2 != string::npos)9405 + sSender.erase(pos1, pos2);9406 + }9407 9765 + if (_strnicmp(sHdr.c_str(), "Return-Path:", 12) == 0) 9408 9766 + sReturnPath.assign(sHdr.c_str() + 12); … … 9452 9810 + nSignThisTag = 1; 9453 9811 + IsRequiredHeader(sTag); // remove from required header list 9454 + } 9812 + } 9455 9813 + // is this in the list of headers that must be signed? 9456 9814 + else … … 9599 9957 + if (!sFrom.empty()) 9600 9958 + sAddress.assign(sFrom); 9959 + else /* use indimail's X-Bounced-Address header to find the domain that injected the bounce */ 9960 + if (!sBouncedAddr.empty()) 9961 + sAddress.assign(sBouncedAddr); 9601 9962 + else 9602 9963 + return false; 9603 + // simple for now, beef it up later 9604 + // remove '<' and anything before it 9964 + /*- 9965 + * simple for now, beef it up later 9966 + * remove '<' and anything before it 9967 + */ 9605 9968 + pos = sAddress.find('<'); 9606 9969 + if (pos != string::npos) 9607 + sAddress.erase(0, pos); 9608 + // remove '>' and anything after it 9970 + sAddress.erase(0, pos + 1); 9971 + 9972 + /* remove '>' and anything after it */ 9609 9973 + pos = sAddress.find('>'); 9610 9974 + if (pos != string::npos) 9611 9975 + sAddress.erase(pos, string::npos); 9612 + // look for '@' symbol 9613 + pos = sAddress.find('@'); 9614 + if (pos == string::npos) 9615 + return false; 9976 + /* look for '@' symbol */ 9616 9977 + if (sDomain.empty()) { 9617 + p = getenv("DKIMDOMAIN"); 9618 + if (p && *p) 9619 + { 9620 + if (!(at = strchr(p, '@'))) 9621 + at = p; 9622 + else 9623 + at++; 9624 + sDomain.assign(at); 9625 + } else 9978 + pos = sAddress.find('@'); 9979 + if (pos != string::npos) 9626 9980 + sDomain.assign(sAddress.c_str() + pos + 1); 9627 + RemoveSWSP(sDomain); 9628 + } 9981 + if (sDomain.empty()) { 9982 + p = getenv("DKIMDOMAIN"); 9983 + if (p && *p) { 9984 + if (!(at = strchr(p, '@'))) 9985 + at = p; 9986 + else 9987 + at++; 9988 + sDomain.assign(at); 9989 + } 9990 + } 9991 + } 9992 + RemoveSWSP(sDomain); 9629 9993 + return true; 9630 9994 +} … … 9895 10259 + for (sptr = ptr, len = 0;*sptr;sptr++) { 9896 10260 + if (*sptr == '%') 9897 + len += (int) strlen(dptr) ;10261 + len += (int) strlen(dptr) + 1; 9898 10262 + else 9899 10263 + len++; 9900 10264 + } 9901 + if (!(buf = new char[len])) {10265 + if (!(buf = new char[len])) 9902 10266 + return DKIM_OUT_OF_MEMORY; 9903 + }9904 10267 + for (cptr = buf, sptr = ptr; *sptr; sptr++) { 9905 10268 + if (*sptr == '%') { 9906 + strncpy(cptr, dptr, (len = strlen(dptr)));10269 + memcpy(cptr, dptr, (len = strlen(dptr))); 9907 10270 + cptr += len; 9908 + } else {10271 + } else 9909 10272 + *cptr++ = *sptr; 9910 + }9911 10273 + } 9912 10274 + *cptr = 0; … … 10130 10492 +getversion_dkimsign_cpp() 10131 10493 +{ 10132 + static char *x = (char *) "$Id: dkimsign.cpp,v 1.1 1 2017-09-05 10:59:03+05:30 Cprogrammer Exp mbhangui $";10494 + static char *x = (char *) "$Id: dkimsign.cpp,v 1.17 2020-04-10 21:36:20+05:30 Cprogrammer Exp mbhangui $"; 10133 10495 + 10134 10496 + x++; … … 10136 10498 diff -ruN ../netqmail-1.06-original/dkimsign.h netqmail-1.06/dkimsign.h 10137 10499 --- ../netqmail-1.06-original/dkimsign.h 1970-01-01 01:00:00.000000000 +0100 10138 +++ netqmail-1.06/dkimsign.h 20 18-04-03 14:46:51.366411614+020010139 @@ -0,0 +1,1 08@@10500 +++ netqmail-1.06/dkimsign.h 2020-04-10 18:39:39.483427628 +0200 10501 @@ -0,0 +1,115 @@ 10140 10502 +/* 10141 10503 + * $Log: dkimsign.h,v $ 10504 + * Revision 1.5 2019-06-26 19:09:07+05:30 Cprogrammer 10505 + * added sBouncedAddr variable for X-Bounced-Address header added by qmail-send for bounces 10506 + * 10507 + * Revision 1.4 2017-09-05 10:59:20+05:30 Cprogrammer 10508 + * removed compiler warnings 10509 + * 10142 10510 + * Revision 1.3 2017-08-09 22:03:09+05:30 Cprogrammer 10143 10511 + * initialized EVP_MD_CTX variables … … 10225 10593 + string sSelector; 10226 10594 + string sReturnPath; 10595 + string sBouncedAddr; /*- used for bounces */ 10227 10596 + string sDomain; 10228 10597 + string sIdentity; // for i= tag, if empty tag will not be included in sig … … 10248 10617 diff -ruN ../netqmail-1.06-original/dkimverify.cpp netqmail-1.06/dkimverify.cpp 10249 10618 --- ../netqmail-1.06-original/dkimverify.cpp 1970-01-01 01:00:00.000000000 +0100 10250 +++ netqmail-1.06/dkimverify.cpp 201 8-04-03 14:46:51.367411617+020010251 @@ -0,0 +1,1 285@@10619 +++ netqmail-1.06/dkimverify.cpp 2019-06-19 09:47:20.017583230 +0200 10620 @@ -0,0 +1,1303 @@ 10252 10621 +/* 10253 10622 + * $Log: dkimverify.cpp,v $ 10623 + * Revision 1.23 2019-05-22 11:29:09+05:30 Cprogrammer 10624 + * fix for 32 bit systems where time_t is 4 bytes & encounters year 2038 issue 10625 + * 10626 + * Revision 1.22 2019-05-21 22:27:17+05:30 Cprogrammer 10627 + * increased buffer size 10628 + * 10629 + * Revision 1.21 2019-02-17 11:32:05+05:30 Cprogrammer 10630 + * made scope of sFromDomain static 10631 + * 10632 + * Revision 1.20 2018-12-14 11:05:20+05:30 Cprogrammer 10633 + * fixed 'conversion from 'int' to 'char' inside { }â for cross compiling on arm 10634 + * 10635 + * Revision 1.19 2018-08-08 23:56:27+05:30 Cprogrammer 10636 + * changed comment style 10637 + * 10254 10638 + * Revision 1.18 2017-09-05 11:00:33+05:30 Cprogrammer 10255 10639 + * removed extra whitespace … … 10329 10713 +#include "config.h" 10330 10714 +#endif 10715 +#include "time_t_size.h" 10331 10716 +#define _strnicmp strncasecmp 10332 10717 +#define _stricmp strcasecmp … … 10340 10725 +#include "dkimdns.h" 10341 10726 + 10342 +#define MAX_SIGNATURES 10 / / maximum number of DKIM signatures to process in a message10727 +#define MAX_SIGNATURES 10 /*- maximum number of DKIM signatures to process in a message */ 10343 10728 + 10344 10729 +SignatureInfo::SignatureInfo(bool s) … … 10397 10782 + 10398 10783 + for (;;) { 10399 + / / skip whitespace10784 + /* skip whitespace */ 10400 10785 + while (isswsp(*s)) 10401 10786 + s++; 10402 + / / if at the end of the string, return success. note: this allows a list with no entries10787 + /* if at the end of the string, return success. note: this allows a list with no entries */ 10403 10788 + if (*s == '\0') 10404 10789 + return true; 10405 + / / get tag name10790 + /*- get tag name -*/ 10406 10791 + if (!isalpha(*s)) 10407 10792 + return false; … … 10411 10796 + } while (isalnum(*s) || *s == '-'); 10412 10797 + char *endtag = s; 10413 + / / skip whitespace before equals10798 + /*- skip whitespace before equals -*/ 10414 10799 + while (isswsp(*s)) 10415 10800 + s++; 10416 + / / next character must be equals10801 + /*- next character must be equals -*/ 10417 10802 + if (*s != '=') 10418 10803 + return false; 10419 10804 + s++; 10420 + / / null-terminate tag name10805 + /*- null-terminate tag name -*/ 10421 10806 + *endtag = '\0'; 10422 + / / skip whitespace after equals10807 + /*- skip whitespace after equals -*/ 10423 10808 + while (isswsp(*s)) 10424 10809 + s++; 10425 + / / get tag value10810 + /*- get tag value -*/ 10426 10811 + char *value = s; 10427 10812 + while (*s != ';' && ((*s == '\t' || *s == '\r' || *s == '\n') || (*s >= ' ' && *s <= '~'))) 10428 10813 + s++; 10429 10814 + char *e = s; 10430 + / / make sure the next character is the null terminator (which means we're done) or a semicolon (not done)10815 + /*- make sure the next character is the null terminator (which means we're done) or a semicolon (not done) -*/ 10431 10816 + bool done = false; 10432 10817 + if (*s == '\0') … … 10437 10822 + s++; 10438 10823 + } 10439 + / / skip backwards past any trailing whitespace10824 + /*- skip backwards past any trailing whitespace -*/ 10440 10825 + while (e > value && isswsp(e[-1])) 10441 10826 + e--; 10442 + / / null-terminate tag value10827 + /*- null-terminate tag value -*/ 10443 10828 + *e = '\0'; 10444 + / / check to see if we want this tag10829 + /*- check to see if we want this tag -*/ 10445 10830 + for (unsigned i = 0; wanted[i] != NULL; i++) { 10446 10831 + if (strcmp(wanted[i], tag) == 0) { 10447 + / / return failure if we already have a value for this tag (duplicates not allowed)10832 + /*- return failure if we already have a value for this tag (duplicates not allowed) -*/ 10448 10833 + if (values[i] != NULL) 10449 10834 + return false; … … 10457 10842 +} 10458 10843 + 10459 +/ / Convert hex char to value (0-15)10844 +/*- Convert hex char to value (0-15) -*/ 10460 10845 +char 10461 10846 +tohex(char ch) … … 10510 10895 +DecodeBase64(char *ptr) 10511 10896 +{ 10512 + static const char base64_table[256] =10897 + static const signed char base64_table[256] = 10513 10898 + { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10514 10899 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, … … 10553 10938 +WildcardMatch(const char *p, const char *s) 10554 10939 +{ 10555 + / / special case: An empty "g=" value never matches any addresses10940 + /*- special case: An empty "g=" value never matches any addresses -*/ 10556 10941 + if (*p == '\0') 10557 10942 + return false; … … 10582 10967 + char *from = s; 10583 10968 + char *to = s; 10584 + char *lt = NULL; / / pointer to less than character (<) which starts the address if found10969 + char *lt = NULL; /*- pointer to less than character (<) which starts the address if found */ 10585 10970 + while (*from != '\0') { 10586 10971 + if (*from == '(') { 10587 + / / skip over comment10972 + /*- skip over comment -*/ 10588 10973 + from++; 10589 10974 + for (int depth = 1; depth != 0; from++) { … … 10602 10987 + } 10603 10988 + else 10604 + if (*from == ')') { 10605 + // ignore closing parenthesis outside of comment 10989 + if (*from == ')') /*- ignore closing parenthesis outside of comment -*/ 10606 10990 + from++; 10607 + }10608 +10609 10991 + else 10610 10992 + if (*from == ',' || *from == ';') { 10611 + / / comma/selicolon ends the address10993 + /*- comma/selicolon ends the address -*/ 10612 10994 + from++; 10613 10995 + break; 10614 10996 + } 10615 10997 + else 10616 + if (*from == ' ' || *from == '\t' || *from == '\r' || *from == '\n') { 10617 + // ignore whitespace 10998 + if (*from == ' ' || *from == '\t' || *from == '\r' || *from == '\n') /*- ignore whitespace -*/ 10618 10999 + from++; 10619 + }10620 11000 + else 10621 11001 + if (*from == '"') { 10622 + / / copy the contents of a quoted string11002 + /*- copy the contents of a quoted string -*/ 10623 11003 + from++; 10624 11004 + while (*from != '\0') { … … 10635 11015 + else 10636 11016 + if (*from == '\\' && from[1] != '\0') { 10637 + / / copy quoted-pair11017 + /*- copy quoted-pair -*/ 10638 11018 + *to++ = *from++; 10639 11019 + *to++ = *from++; 10640 11020 + } else { 10641 + / / copy any other char11021 + /*- copy any other char -*/ 10642 11022 + *to = *from++; 10643 11023 + // save pointer to '<' for later... … … 10648 11028 + } 10649 11029 + *to = '\0'; 10650 + / / if there's < > get what's inside11030 + /*- if there's < > get what's inside -*/ 10651 11031 + if (lt != NULL) { 10652 11032 + start = lt + 1; … … 10655 11035 + *gt = '\0'; 10656 11036 + } else { 10657 + / / look for and strip group name11037 + /*- look for and strip group name -*/ 10658 11038 + char *colon = strchr(start, ':'); 10659 11039 + if (colon != NULL) { … … 10686 11066 +} 10687 11067 + 10688 +/ / Init - save the options11068 +/*- Init - save the options -*/ 10689 11069 +int 10690 11070 +CDKIMVerify::Init(DKIMVerifyOptions *pOptions) … … 10703 11083 +} 10704 11084 + 10705 +/ / GetResults - return the pass/fail/neutral verification result11085 +/*- GetResults - return the pass/fail/neutral verification result -*/ 10706 11086 +int 10707 11087 +CDKIMVerify::GetResults(int *sCount, int *sSize) … … 10711 11091 + int TestingFailures = 0; 10712 11092 + int RealFailures = 0; 10713 + list <string> SuccessfulDomains; // can contain duplicates 10714 + /* get the From address's domain if we might need it */ 10715 + string sFromDomain; 11093 + list <string> SuccessfulDomains; /* can contain duplicates */ 11094 + string sFromDomain; /*- get the From address's domain if we might need it -*/ 10716 11095 + 10717 11096 + for (list < SignatureInfo >::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { 10718 11097 + if (i->Status == DKIM_SUCCESS) { 10719 + if (!i->BodyHashData.empty()) { 10720 + // check the body hash 11098 + if (!i->BodyHashData.empty()) { /*- check the body hash -*/ 10721 11099 + unsigned char md[EVP_MAX_MD_SIZE]; 10722 11100 + unsigned len = 0; … … 10727 11105 +#endif 10728 11106 + if (!res || len != i->BodyHashData.length() || memcmp(i->BodyHashData.data(), md, len) != 0) { 10729 + // body hash mismatch 10730 + // if the selector is in testing mode... 10731 + if (i->m_pSelector->Testing) { 10732 + i->Status = DKIM_SIGNATURE_BAD_BUT_TESTING; // todo: make a new error code for this? 11107 + /* body hash mismatch */ 11108 + if (i->m_pSelector->Testing) { /* if the selector is in testing mode... */ 11109 + i->Status = DKIM_SIGNATURE_BAD_BUT_TESTING; /* todo: make a new error code for this? */ 10733 11110 + TestingFailures++; 10734 11111 + } else { … … 10739 11116 + } 10740 11117 + } else { 10741 + / / hash CRLF separating the body from the signature11118 + /* hash CRLF separating the body from the signature */ 10742 11119 + i->Hash("\r\n", 2); 10743 11120 + } 10744 + / / check the header hash11121 + /*- check the header hash -*/ 10745 11122 + string sSignedSig = i->Header; 10746 11123 + string sSigValue = sSignedSig.substr(sSignedSig.find(':') + 1); … … 10756 11133 + if (i->HeaderCanonicalization == DKIM_CANON_NOWSP) { 10757 11134 + RemoveSWSP(sSignedSig); 10758 + / / convert "DKIM-Signature" to lower case11135 + /* convert "DKIM-Signature" to lower case */ 10759 11136 + sSignedSig.replace(0, 14, "dkim-signature", 14); 10760 11137 + } … … 10776 11153 + SuccessfulDomains.push_back(i->Domain); 10777 11154 + } else { 10778 + / / if the selector is in testing mode...11155 + /* if the selector is in testing mode... */ 10779 11156 + if (i->m_pSelector->Testing) { 10780 11157 + i->Status = DKIM_SIGNATURE_BAD_BUT_TESTING; … … 10789 11166 + || i->Status == DKIM_SELECTOR_ALGORITHM_MISMATCH 10790 11167 + || i->Status == DKIM_SELECTOR_KEY_REVOKED) { 10791 + / / treat these as failures10792 + / / todo: maybe see if the selector is in testing mode?11168 + /*- treat these as failures -*/ 11169 + /*- todo: maybe see if the selector is in testing mode? -*/ 10793 11170 + RealFailures++; 10794 11171 + } … … 10797 11174 + for (list < string >::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { 10798 11175 + if (_strnicmp(i->c_str(), "From", 4) == 0) { 10799 + / / skip over whitespace between the header name and :11176 + /*- skip over whitespace between the header name and : -*/ 10800 11177 + const char *s = i->c_str() + 4; 10801 11178 + while (*s == ' ' || *s == '\t') … … 10812 11189 + } 10813 11190 + } 10814 + // if a signature from the From domain verified successfully, return success now 10815 + // without checking the sender signing practices 11191 + /*- 11192 + * if a signature from the From domain verified successfully, 11193 + * return success now without checking the sender signing practices 11194 + */ 10816 11195 + if (SuccessCount > 0 && !sFromDomain.empty()) { 10817 11196 + for (list < string >::iterator i = SuccessfulDomains.begin(); i != SuccessfulDomains.end(); ++i) { 10818 + / / see if the successful domain is the same as or a parent of the From domain11197 + /* see if the successful domain is the same as or a parent of the From domain */ 10819 11198 + if (i->length() > sFromDomain.length()) 10820 11199 + continue; … … 10870 11249 + 10871 11250 + 10872 +/ / ProcessHeaders - Look for DKIM-Signatures and start processing them11251 +/*- ProcessHeaders - Look for DKIM-Signatures and start processing them -*/ 10873 11252 +int 10874 11253 +CDKIMVerify::ProcessHeaders(void) 10875 11254 +{ 10876 11255 + 10877 + / / look for DKIM-Signature header(s)11256 + /*- look for DKIM-Signature header(s) -*/ 10878 11257 + for (list < string >::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { 10879 11258 + if (_strnicmp(i->c_str(), "DKIM-Signature", 14) == 0) { 10880 + / / skip over whitespace between the header name and :11259 + /*- skip over whitespace between the header name and : -*/ 10881 11260 + const char *s = i->c_str() + 14; 10882 11261 + while (*s == ' ' || *s == '\t') … … 10905 11284 + return (sig.Status); 10906 11285 + } else { 10907 + / / check the granularity11286 + /*- check the granularity -*/ 10908 11287 + if (!WildcardMatch(sel.Granularity.c_str(), sig.IdentityLocalPart.c_str())) 10909 + sig.Status = DKIM_SELECTOR_GRANULARITY_MISMATCH; / / this error causes the signature to fail10910 + / / check the hash algorithm11288 + sig.Status = DKIM_SELECTOR_GRANULARITY_MISMATCH; /* this error causes the signature to fail */ 11289 + /*- check the hash algorithm -*/ 10911 11290 +#ifdef HAVE_EVP_SHA256 10912 11291 + if ((sig.m_nHash == DKIM_HASH_SHA1 && !sel.AllowSHA1) || (sig.m_nHash == DKIM_HASH_SHA256 && !sel.AllowSHA256)) … … 10914 11293 + if ((sig.m_nHash == DKIM_HASH_SHA1 && !sel.AllowSHA1)) 10915 11294 +#endif 10916 + sig.Status = DKIM_SELECTOR_ALGORITHM_MISMATCH; / / causes signature to fail10917 + / / check for same domain11295 + sig.Status = DKIM_SELECTOR_ALGORITHM_MISMATCH; /* causes signature to fail */ 11296 + /*- check for same domain -*/ 10918 11297 + if (sel.SameDomain && _stricmp(sig.Domain.c_str(), sig.IdentityDomain.c_str()) != 0) 10919 11298 + sig.Status = DKIM_BAD_SYNTAX; … … 10921 11300 + if (sig.Status != DKIM_SUCCESS) 10922 11301 + continue; 10923 + / / initialize the hashes11302 + /*- initialize the hashes -*/ 10924 11303 +#if OPENSSL_VERSION_NUMBER >= 0x10100000L 10925 11304 +#ifdef HAVE_EVP_SHA256 … … 10949 11328 +#endif 10950 11329 +#endif 10951 + / / compute the hash of the header11330 + /*- compute the hash of the header -*/ 10952 11331 + vector < list < string >::reverse_iterator > used; 10953 11332 + for (vector < string >::iterator x = sig.SignedHeaders.begin(); x != sig.SignedHeaders.end(); ++x) { … … 10955 11334 + for (i = HeaderList.rbegin(); i != HeaderList.rend(); ++i) { 10956 11335 + if (_strnicmp(i->c_str(), x->c_str(), x->length()) == 0) { 10957 + / / skip over whitespace between the header name and :11336 + /*- skip over whitespace between the header name and : -*/ 10958 11337 + const char *s = i->c_str() + x->length(); 10959 11338 + while (*s == ' ' || *s == '\t') … … 10965 11344 + if (i != HeaderList.rend()) { 10966 11345 + used.push_back(i); 10967 + / / hash this header11346 + /*- hash this header -*/ 10968 11347 + if (sig.HeaderCanonicalization == DKIM_CANON_SIMPLE) 10969 11348 + sig.Hash(i->c_str(), i->length()); … … 10976 11355 + string sTemp = *i; 10977 11356 + RemoveSWSP(sTemp); 10978 + / / convert characters before ':' to lower case11357 + /*- convert characters before ':' to lower case -*/ 10979 11358 + for (char *s = (char *)sTemp.c_str(); *s != '\0' && *s != ':'; s++) { 10980 11359 + if (*s >= 'A' && *s <= 'Z') … … 10986 11365 + } 10987 11366 + } 10988 + if (sig.BodyHashData.empty()) { 10989 + // hash CRLF separating headers from body 11367 + if (sig.BodyHashData.empty()) /*- hash CRLF separating headers from body -*/ 10990 11368 + sig.Hash("\r\n", 2); 10991 + }10992 11369 + if (!m_AllowUnsignedFromHeaders) { 10993 + / / make sure the message has no unsigned From headers11370 + /*- make sure the message has no unsigned From headers -*/ 10994 11371 + list<string>::reverse_iterator i; 10995 11372 + for( i = HeaderList.rbegin(); i != HeaderList.rend(); ++i ) { 10996 11373 + if( _strnicmp(i->c_str(), "From", 4 ) == 0 ) { 10997 + / / skip over whitespace between the header name and :11374 + /*- skip over whitespace between the header name and : -*/ 10998 11375 + const char *s = i->c_str()+4; 10999 11376 + while (*s == ' ' || *s == '\t') … … 11001 11378 + if (*s == ':') { 11002 11379 + if (find(used.begin(), used.end(), i) == used.end()) { 11003 + / / this From header was not signed11380 + /*- this From header was not signed -*/ 11004 11381 + break; 11005 11382 + } … … 11008 11385 + } 11009 11386 + if (i != HeaderList.rend()) { 11010 + / / treat signature as invalid11387 + /*- treat signature as invalid -*/ 11011 11388 + sig.Status = DKIM_UNSIGNED_FROM; 11012 11389 + continue; … … 11035 11412 + do { 11036 11413 + if (*s < '0' || *s > '9') 11037 + return false; // returns false for an initial '\0'11414 + return false; /*- returns false for an initial '\0' */ 11038 11415 + temp = temp * 10 + (*s - '0'); 11039 11416 + if (temp < last) … … 11050 11427 + 11051 11428 + 11052 +/ / ParseDKIMSignature - Parse a DKIM-Signature header field11429 +/*- ParseDKIMSignature - Parse a DKIM-Signature header field -*/ 11053 11430 +int 11054 11431 +CDKIMVerify::ParseDKIMSignature(const string &sHeader, SignatureInfo &sig) 11055 11432 +{ 11056 11433 + 11057 + / / save header for later11434 + /*- save header for later -*/ 11058 11435 + sig.Header = sHeader; 11059 11436 + string sValue = sHeader.substr(sHeader.find(':') + 1); … … 11064 11441 + if (!ParseTagValueList((char *) sValue.c_str(), tags, values)) 11065 11442 + return DKIM_BAD_SYNTAX; 11066 + / / check signature version11443 + /*- check signature version -*/ 11067 11444 + if (values[0] != NULL) { 11068 11445 + if (strcmp(values[0], "1") == 0 || strcmp(values[0], "0.5") == 0 || strcmp(values[0], "0.4") == 0 11069 11446 + || strcmp(values[0], "0.3") == 0 || strcmp(values[0], "0.2") == 0) { 11070 11447 + sig.Version = DKIM_SIG_VERSION_02_PLUS; 11071 + } else { 11072 + // unknown version 11448 + } else /*- unknown version -*/ 11073 11449 + return DKIM_STAT_INCOMPAT; 11074 + }11075 11450 + } else { 11076 + // Note: DKIM Interop 1 pointed out that v= is now required, but we do 11077 + // not enforce that in order to verify signatures made by older drafts. 11078 + 11079 + // prior to 0.2, there MUST NOT have been a v= 11080 + // (optionally) support these signatures, for backwards compatibility 11451 + /*- 11452 + * Note: DKIM Interop 1 pointed out that v= is now required, but we do 11453 + * not enforce that in order to verify signatures made by older drafts. 11454 + * prior to 0.2, there MUST NOT have been a v= 11455 + * (optionally) support these signatures, for backwards compatibility 11456 + */ 11081 11457 + if (true) { 11082 11458 + sig.Version = DKIM_SIG_VERSION_PRE_02; … … 11085 11461 + } 11086 11462 + } 11087 + / / signature MUST have a=, b=, d=, h=, s=11463 + /*- signature MUST have a=, b=, d=, h=, s= -*/ 11088 11464 + if (values[1] == NULL || values[2] == NULL || values[3] == NULL || values[4] == NULL || values[5] == NULL) 11089 11465 + return DKIM_BAD_SYNTAX; 11090 + / / algorithm can be "rsa-sha1" or "rsa-sha256"11466 + /*- algorithm can be "rsa-sha1" or "rsa-sha256" -*/ 11091 11467 + if (strcmp(values[1], "rsa-sha1") == 0) { 11092 11468 + sig.m_nHash = DKIM_HASH_SHA1; 11093 11469 + } 11094 11470 +#ifdef HAVE_EVP_SHA256 11095 + else if (strcmp(values[1], "rsa-sha256") == 0) { 11471 + else 11472 + if (strcmp(values[1], "rsa-sha256") == 0) 11096 11473 + sig.m_nHash = DKIM_HASH_SHA256; 11097 + }11098 11474 +#endif 11099 + else { 11100 + return DKIM_BAD_SYNTAX; // todo: maybe create a new error code for unknown algorithm 11101 + } 11102 + // make sure the signature data is not empty 11475 + else 11476 + return DKIM_BAD_SYNTAX; /* todo: maybe create a new error code for unknown algorithm */ 11477 + /*- make sure the signature data is not empty -*/ 11103 11478 + unsigned SigDataLen = DecodeBase64(values[2]); 11104 11479 + if (SigDataLen == 0) 11105 11480 + return DKIM_BAD_SYNTAX; 11106 11481 + sig.SignatureData.assign(values[2], SigDataLen); 11107 + / / check for body hash11482 + /*- check for body hash -*/ 11108 11483 + if (values[12] == NULL) { 11109 + / / use the old single hash way for backwards compatibility11484 + /*- use the old single hash way for backwards compatibility -*/ 11110 11485 + if (sig.Version != DKIM_SIG_VERSION_PRE_02) 11111 11486 + return DKIM_BAD_SYNTAX; … … 11116 11491 + sig.BodyHashData.assign(values[12], BodyHashLen); 11117 11492 + } 11118 + / / domain must not be empty11493 + /*- domain must not be empty -*/ 11119 11494 + if (*values[3] == '\0') 11120 11495 + return DKIM_BAD_SYNTAX; 11121 11496 + sig.Domain = values[3]; 11122 + / / signed headers must not be empty (more verification is done later)11497 + /*- signed headers must not be empty (more verification is done later) -*/ 11123 11498 + if (*values[4] == '\0') 11124 11499 + return DKIM_BAD_SYNTAX; 11125 + / / selector must not be empty11500 + /*- selector must not be empty -*/ 11126 11501 + if (*values[5] == '\0') 11127 11502 + return DKIM_BAD_SYNTAX; 11128 11503 + sig.Selector = values[5]; 11129 + / / canonicalization11504 + /*- canonicalization -*/ 11130 11505 + if (values[6] == NULL) { 11131 11506 + sig.HeaderCanonicalization = sig.BodyCanonicalization = DKIM_CANON_SIMPLE; 11132 11507 + } 11133 11508 + else 11134 + if (sig.Version == DKIM_SIG_VERSION_PRE_02 && strcmp(values[6], "nowsp") == 0) { 11135 + // for backwards compatibility 11509 + if (sig.Version == DKIM_SIG_VERSION_PRE_02 && strcmp(values[6], "nowsp") == 0) /*- for backwards compatibility -*/ 11136 11510 + sig.HeaderCanonicalization = sig.BodyCanonicalization = DKIM_CANON_NOWSP; 11137 + }else {11511 + else { 11138 11512 + char *slash = strchr(values[6], '/'); 11139 11513 + if (slash != NULL) … … 11154 11528 + return DKIM_BAD_SYNTAX; 11155 11529 + } 11156 + / / identity11530 + /*- identity -*/ 11157 11531 + if (values[7] == NULL) { 11158 11532 + sig.IdentityLocalPart.erase(); 11159 11533 + sig.IdentityDomain = sig.Domain; 11160 11534 + } else { 11161 + / / quoted-printable decode the value11535 + /*- quoted-printable decode the value -*/ 11162 11536 + DecodeQuotedPrintable(values[7]); 11163 + / / must have a '@' separating the local part from the domain11537 + /*- must have a '@' separating the local part from the domain -*/ 11164 11538 + char *at = strchr(values[7], '@'); 11165 11539 + if (at == NULL) … … 11168 11542 + char *ilocalpart = values[7]; 11169 11543 + char *idomain = at + 1; 11170 + / / i= domain must be the same as or a subdomain of the d= domain11544 + /*- i= domain must be the same as or a subdomain of the d= domain -*/ 11171 11545 + int idomainlen = strlen(idomain); 11172 11546 + int ddomainlen = strlen(values[3]); 11173 11547 + 11174 + / / todo: maybe create a new error code for invalid identity domain11548 + /*- todo: maybe create a new error code for invalid identity domain -*/ 11175 11549 + if (idomainlen < ddomainlen) 11176 11550 + return DKIM_BAD_SYNTAX; … … 11182 11556 + sig.IdentityDomain = idomain; 11183 11557 + } 11184 + / / body count11558 + /*- body count -*/ 11185 11559 + if (values[8] == NULL || !m_HonorBodyLengthTag) { 11186 11560 + sig.BodyLength = -1; … … 11189 11563 + return DKIM_BAD_SYNTAX; 11190 11564 + } 11191 + / / query methods11565 + /*- query methods -*/ 11192 11566 + if (values[9] != NULL) { 11193 11567 + 11194 + / / make sure "dns" is in the list11568 + /*- make sure "dns" is in the list -*/ 11195 11569 + bool HasDNS = false; 11196 11570 + char *s = strtok_r(values[9], ":", &saveptr); … … 11205 11579 + return DKIM_BAD_SYNTAX; // todo: maybe create a new error code for unknown query method 11206 11580 + } 11207 + // signature time 11581 +#if SIZEOF_TIME_T == 8 11582 + /*- signature time -*/ 11208 11583 + time_t SignedTime = -1; 11584 +#else 11585 + long long SignedTime = -1; 11586 +#endif 11209 11587 + if (values[10] != NULL) { 11210 11588 + if (!ParseUnsigned(values[10], (unsigned long *) &SignedTime)) 11211 11589 + return DKIM_BAD_SYNTAX; 11212 11590 + } 11213 + / / expiration time11591 + /*- expiration time -*/ 11214 11592 + if (values[11] == NULL) { 11215 11593 + sig.ExpireTime = -1; … … 11218 11596 + return DKIM_BAD_SYNTAX; 11219 11597 + if (sig.ExpireTime != -1) { 11220 + // the value of x= MUST be greater than the value of t= if both are present 11598 + /*- the value of x= MUST be greater than the value of t= if both are present -*/ 11599 +#if SIZEOF_TIME_T == 8 11221 11600 + if (SignedTime != -1 && sig.ExpireTime <= SignedTime) 11222 11601 + return DKIM_BAD_SYNTAX; 11223 + // todo: if possible, use the received date/time instead of the current time 11602 +#else 11603 + if (SignedTime != -1 && (long long) sig.ExpireTime <= SignedTime) 11604 + return DKIM_BAD_SYNTAX; 11605 +#endif 11606 + /*- todo: if possible, use the received date/time instead of the current time -*/ 11224 11607 + time_t curtime = time(NULL); 11608 +#if SIZEOF_TIME_T == 8 11225 11609 + if (curtime > sig.ExpireTime) 11226 11610 + return DKIM_SIGNATURE_EXPIRED; 11611 +#else /*- handle year 2038 the best we can, beyond which one has to upgrade to a 64 bit os */ 11612 + if (curtime < 2147483648 && curtime > sig.ExpireTime) 11613 + return DKIM_SIGNATURE_EXPIRED; 11614 +#endif 11227 11615 + } 11228 11616 + } 11229 + / / parse the signed headers list11617 + /*- parse the signed headers list -*/ 11230 11618 + bool HasFrom = false, HasSubject = false; 11231 + RemoveSWSP(values[4]); / / header names shouldn't have spaces in them so this should be ok...11619 + RemoveSWSP(values[4]); /*- header names shouldn't have spaces in them so this should be ok... */ 11232 11620 + char *s = strtok_r(values[4], ":", &saveptr); 11233 11621 + while (s != NULL) { … … 11241 11629 + } 11242 11630 + if (!HasFrom) 11243 + return DKIM_BAD_SYNTAX; / / todo: maybe create a new error code for h= missing From11631 + return DKIM_BAD_SYNTAX; /*- todo: maybe create a new error code for h= missing From */ 11244 11632 + if (m_SubjectIsRequired && !HasSubject) 11245 + return DKIM_BAD_SYNTAX; / / todo: maybe create a new error code for h= missing Subject11633 + return DKIM_BAD_SYNTAX; /*- todo: maybe create a new error code for h= missing Subject */ 11246 11634 + return DKIM_SUCCESS; 11247 11635 +} 11248 11636 + 11249 11637 + 11250 +/ / ProcessBody - Process message body data11638 +/*- ProcessBody - Process message body data -*/ 11251 11639 +int 11252 11640 +CDKIMVerify::ProcessBody(char *szBuffer, int nBufLength, bool bEOF) … … 11330 11718 + return DKIM_SELECTOR_INVALID; 11331 11719 + if (values[0] != NULL) { 11332 + 11333 + // make sure the version is "DKIM1" 11720 + /*- make sure the version is "DKIM1" -*/ 11334 11721 + if (strcmp(values[0], "DKIM1") != 0) 11335 + return DKIM_SELECTOR_INVALID; // todo: maybe create a new error code for unsupported selector version 11336 + // make sure v= is the first tag in the response // todo: maybe don't enforce this, it seems unnecessary 11722 + return DKIM_SELECTOR_INVALID; /*- todo: maybe create a new error code for unsupported selector version */ 11723 + /*- make sure v= is the first tag in the response */ 11724 + /*- todo: maybe don't enforce this, it seems unnecessary */ 11337 11725 + for (unsigned int j = 1; j < sizeof (values) / sizeof (values[0]); j++) { 11338 11726 + if (values[j] != NULL && values[j] < values[0]) { … … 11341 11729 + } 11342 11730 + } 11343 + / / selector MUST have p= tag11731 + /*- selector MUST have p= tag -*/ 11344 11732 + if (values[4] == NULL) 11345 11733 + return DKIM_SELECTOR_INVALID; 11346 + / / granularity11734 + /*- granularity -*/ 11347 11735 + if (values[1] == NULL) 11348 11736 + Granularity = "*"; … … 11350 11738 + else 11351 11739 + Granularity = values[1]; 11352 + / / hash algorithm11740 + /*- hash algorithm -*/ 11353 11741 + if (values[2] == NULL) { 11354 11742 + AllowSHA1 = true; … … 11359 11747 +#endif 11360 11748 + } else { 11361 + / / MUST include "sha1" or "sha256"11749 + /*- MUST include "sha1" or "sha256" -*/ 11362 11750 + char *s = strtok_r(values[2], ":", &saveptr); 11363 11751 + while (s != NULL) { … … 11375 11763 + if (!AllowSHA1) 11376 11764 +#endif 11377 + return DKIM_SELECTOR_INVALID; / / todo: maybe create a new error code for unsupported hash algorithm11378 + } 11379 + / / key type11765 + return DKIM_SELECTOR_INVALID; /*- todo: maybe create a new error code for unsupported hash algorithm */ 11766 + } 11767 + /*- key type -*/ 11380 11768 + if (values[3] != NULL) { 11381 + / / key type MUST be "rsa"11769 + /*- key type MUST be "rsa" -*/ 11382 11770 + if (strcmp(values[3], "rsa") != 0) 11383 11771 + return DKIM_SELECTOR_INVALID; 11384 11772 + } 11385 + / / service type11773 + /*- service type -*/ 11386 11774 + if (values[5] != NULL) { 11387 + / / make sure "*" or "email" is in the list11775 + /*- make sure "*" or "email" is in the list -*/ 11388 11776 + bool ServiceTypeMatch = false; 11389 11777 + char *s = strtok_r(values[5], ":", &saveptr); … … 11398 11786 + return DKIM_SELECTOR_INVALID; 11399 11787 + } 11400 + / / flags11788 + /*- flags -*/ 11401 11789 + if (values[6] != NULL) { 11402 11790 + char *s = strtok_r(values[6], ":", &saveptr); … … 11411 11799 + } 11412 11800 + } 11413 +#define M_ToConstUCharPtr(p) reinterpret_cast<const unsigned char*>(p) // Cast to unsigned char*11801 +#define M_ToConstUCharPtr(p) reinterpret_cast<const unsigned char*>(p) /* Cast to unsigned char* */ 11414 11802 + /*- public key data */ 11415 11803 + unsigned PublicKeyLen = DecodeBase64(values[4]); 11416 11804 + if (PublicKeyLen == 0) 11417 + return DKIM_SELECTOR_KEY_REVOKED; // this error causes the signature to fail11805 + return DKIM_SELECTOR_KEY_REVOKED; /*- this error causes the signature to fail */ 11418 11806 + else { 11419 11807 + EVP_PKEY *pkey; … … 11447 11835 +} 11448 11836 + 11449 +/ / GetSelector - Get a DKIM selector for a domain11837 +/*- GetSelector - Get a DKIM selector for a domain -*/ 11450 11838 +SelectorInfo &CDKIMVerify::GetSelector(const string &sSelector, const string &sDomain) 11451 11839 +{ 11452 + 11453 + // see if we already have this selector 11840 + /*- see if we already have this selector -*/ 11454 11841 + for (list < SelectorInfo >::iterator i = Selectors.begin(); i != Selectors.end(); ++i) { 11455 11842 + if (_stricmp(i->Selector.c_str(), sSelector.c_str()) == 0 && _stricmp(i->Domain.c_str(), sDomain.c_str()) == 0) { … … 11462 11849 + sFQDN += "._domainkey."; 11463 11850 + sFQDN += sDomain; 11464 + char Buffer[ 1024];11851 + char Buffer[4096]; 11465 11852 + int DNSResult; 11466 11853 + … … 11487 11874 +} 11488 11875 + 11489 +/ / GetDetails - Get DKIM verification details (per signature)11876 +/*- GetDetails - Get DKIM verification details (per signature) -*/ 11490 11877 +int 11491 11878 +CDKIMVerify::GetDetails(int *nSigCount, DKIMVerifyDetails ** pDetails) … … 11508 11895 +CDKIMVerify::GetDomain(void) 11509 11896 +{ 11510 + st ringsFromDomain;11897 + static string sFromDomain; 11511 11898 + for (list <string>::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { 11512 11899 + if (_strnicmp(i->c_str(), "From", 4) == 0) { 11513 + / / skip over whitespace between the header name and :11900 + /*- skip over whitespace between the header name and : -*/ 11514 11901 + const char *s = i->c_str() + 4; 11515 11902 + while (*s == ' ' || *s == '\t') … … 11531 11918 +getversion_dkimverify_cpp() 11532 11919 +{ 11533 + static char *x = (char *) "$Id: dkimverify.cpp,v 1. 18 2017-09-05 11:00:33+05:30 Cprogrammer Exp mbhangui $";11920 + static char *x = (char *) "$Id: dkimverify.cpp,v 1.23 2019-05-22 11:29:09+05:30 Cprogrammer Exp mbhangui $"; 11534 11921 + 11535 11922 + x++; … … 11537 11924 diff -ruN ../netqmail-1.06-original/dkimverify.h netqmail-1.06/dkimverify.h 11538 11925 --- ../netqmail-1.06-original/dkimverify.h 1970-01-01 01:00:00.000000000 +0100 11539 +++ netqmail-1.06/dkimverify.h 201 8-04-03 14:46:51.367411617+020011540 @@ -0,0 +1,1 39@@11926 +++ netqmail-1.06/dkimverify.h 2019-06-19 09:47:30.665464671 +0200 11927 @@ -0,0 +1,150 @@ 11541 11928 +/* 11542 11929 + * $Log: dkimverify.h,v $ 11930 + * Revision 1.9 2019-06-14 21:25:11+05:30 Cprogrammer 11931 + * BUG - honor body length tag in verification. Changed data type for BodyLength 11932 + * 11933 + * Revision 1.8 2019-05-22 11:30:06+05:30 Cprogrammer 11934 + * fix for 32 bit systems where time_t is 4 bytes & encounters year 2038 issue 11935 + * 11543 11936 + * Revision 1.7 2017-08-31 17:07:45+05:30 Cprogrammer 11544 11937 + * fixed g++ compiler warning … … 11586 11979 + 11587 11980 +#include "dkimbase.h" 11981 +#include "time_t_size.h" 11588 11982 +#include <vector> 11589 11983 + … … 11624 12018 + string CanonicalizedData; 11625 12019 + vector <string> SignedHeaders; 11626 + intBodyLength;12020 + long BodyLength; 11627 12021 + unsigned HeaderCanonicalization; 11628 12022 + unsigned BodyCanonicalization; 12023 +#if SIZEOF_TIME_T == 8 11629 12024 + time_t ExpireTime; 11630 + int VerifiedBodyCount; 11631 + unsigned UnverifiedBodyCount; 12025 +#else 12026 + long long ExpireTime; 12027 +#endif 12028 + long VerifiedBodyCount; 12029 + long UnverifiedBodyCount; 11632 12030 +#if OPENSSL_VERSION_NUMBER >= 0x10100000L 11633 12031 + EVP_MD_CTX *m_Hdr_ctx = NULL; … … 11680 12078 diff -ruN ../netqmail-1.06-original/dknewkey.sh netqmail-1.06/dknewkey.sh 11681 12079 --- ../netqmail-1.06-original/dknewkey.sh 1970-01-01 01:00:00.000000000 +0100 11682 +++ netqmail-1.06/dknewkey.sh 201 6-11-22 21:03:57.112528099+010012080 +++ netqmail-1.06/dknewkey.sh 2019-02-27 20:57:13.389025081 +0100 11683 12081 @@ -0,0 +1,27 @@ 11684 12082 +# … … 11711 12109 diff -ruN ../netqmail-1.06-original/dktest.9 netqmail-1.06/dktest.9 11712 12110 --- ../netqmail-1.06-original/dktest.9 1970-01-01 01:00:00.000000000 +0100 11713 +++ netqmail-1.06/dktest.9 201 6-11-22 21:03:57.112528099+010012111 +++ netqmail-1.06/dktest.9 2019-02-27 20:57:13.389025081 +0100 11714 12112 @@ -0,0 +1,86 @@ 11715 12113 +.TH dktest 8 … … 11801 12199 diff -ruN ../netqmail-1.06-original/dktest.c netqmail-1.06/dktest.c 11802 12200 --- ../netqmail-1.06-original/dktest.c 1970-01-01 01:00:00.000000000 +0100 11803 +++ netqmail-1.06/dktest.c 20 16-11-22 21:03:57.112528099 +010011804 @@ -0,0 +1,43 1@@12201 +++ netqmail-1.06/dktest.c 2020-04-09 19:44:51.053935329 +0200 12202 @@ -0,0 +1,434 @@ 11805 12203 +/* 11806 12204 + * $Log: dktest.c,v $ … … 12204 12602 + status = "bad sender (g=)"; 12205 12603 + break; 12604 + case DK_STAT_DUPLICATE: 12605 + status = "duplicate signature"; 12606 + break; 12206 12607 + } 12207 12608 +#if 0 … … 12236 12637 diff -ruN ../netqmail-1.06-original/dktrace.c netqmail-1.06/dktrace.c 12237 12638 --- ../netqmail-1.06-original/dktrace.c 1970-01-01 01:00:00.000000000 +0100 12238 +++ netqmail-1.06/dktrace.c 201 6-11-22 21:03:57.112528099+010012639 +++ netqmail-1.06/dktrace.c 2019-02-27 20:57:13.389025081 +0100 12239 12640 @@ -0,0 +1,277 @@ 12240 12641 +/* … … 12517 12918 diff -ruN ../netqmail-1.06-original/dktrace.h netqmail-1.06/dktrace.h 12518 12919 --- ../netqmail-1.06-original/dktrace.h 1970-01-01 01:00:00.000000000 +0100 12519 +++ netqmail-1.06/dktrace.h 201 6-11-22 21:03:57.112528099+010012920 +++ netqmail-1.06/dktrace.h 2019-02-27 20:57:13.389025081 +0100 12520 12921 @@ -0,0 +1,26 @@ 12521 12922 +/* $Id: dktrace.h,v 1.3 2005/06/27 18:47:57 ted46045 Exp $ */ … … 12547 12948 diff -ruN ../netqmail-1.06-original/dns.c netqmail-1.06/dns.c 12548 12949 --- ../netqmail-1.06-original/dns.c 2007-11-30 21:22:54.000000000 +0100 12549 +++ netqmail-1.06/dns.c 201 8-04-02 11:45:03.323768372+020012950 +++ netqmail-1.06/dns.c 2019-04-09 20:53:51.981528338 +0200 12550 12951 @@ -1,4 +1,3 @@ 12551 12952 -#include <stdio.h> … … 12710 13111 case DNS_MEM: return DNS_MEM; 12711 13112 case DNS_SOFT: return DNS_SOFT; 12712 @@ -254,25 +318,4 6@@13113 @@ -254,25 +318,49 @@ 12713 13114 if (r == DNS_SOFT) return DNS_SOFT; 12714 13115 if (r == 1) … … 12757 13158 if (!stralloc_0(&glue)) return DNS_MEM; 12758 13159 if (glue.s[0]) { 12759 - ix.pref = 0; 13160 +#ifndef IX_FQDN 13161 ix.pref = 0; 13162 +#endif 12760 13163 if (!glue.s[ip_scan(glue.s,&ix.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.ip)]) 12761 13164 { 12762 13165 if (!ipalloc_append(ia,&ix)) return DNS_MEM; 12763 @@ -291,9 +37 6,16 @@13166 @@ -291,9 +379,16 @@ 12764 13167 ix.ip = ip; 12765 13168 ix.pref = pref; … … 12779 13182 } 12780 13183 12781 @@ -313,7 +40 5,7 @@13184 @@ -313,7 +408,7 @@ 12782 13185 { 12783 13186 int r; … … 12788 13191 int i; 12789 13192 int j; 12790 @@ -325,7 +4 17,6@@13193 @@ -325,7 +420,9 @@ 12791 13194 if (!stralloc_copy(&glue,sa)) return DNS_MEM; 12792 13195 if (!stralloc_0(&glue)) return DNS_MEM; 12793 13196 if (glue.s[0]) { 12794 - ix.pref = 0; 13197 +#ifndef IX_FQDN 13198 ix.pref = 0; 13199 +#endif 12795 13200 if (!glue.s[ip_scan(glue.s,&ix.ip)] || !glue.s[ip_scanbracket(glue.s,&ix.ip)]) 12796 13201 { 12797 13202 if (!ipalloc_append(ia,&ix)) return DNS_MEM; 12798 @@ -396,3 +4 87,49 @@13203 @@ -396,3 +493,49 @@ 12799 13204 alloc_free(mx); 12800 13205 return flagsoft; … … 12848 13253 diff -ruN ../netqmail-1.06-original/dns.h netqmail-1.06/dns.h 12849 13254 --- ../netqmail-1.06-original/dns.h 1998-06-15 12:53:16.000000000 +0200 12850 +++ netqmail-1.06/dns.h 201 6-11-22 21:03:57.113528065+010013255 +++ netqmail-1.06/dns.h 2019-02-27 20:57:13.390025070 +0100 12851 13256 @@ -10,5 +10,6 @@ 12852 13257 int dns_mxip(); … … 12858 13263 diff -ruN ../netqmail-1.06-original/dnsfq.c netqmail-1.06/dnsfq.c 12859 13264 --- ../netqmail-1.06-original/dnsfq.c 1998-06-15 12:53:16.000000000 +0200 12860 +++ netqmail-1.06/dnsfq.c 201 6-11-22 21:03:57.113528065+010013265 +++ netqmail-1.06/dnsfq.c 2019-02-27 20:57:13.390025070 +0100 12861 13266 @@ -5,15 +5,19 @@ 12862 13267 #include "dnsdoe.h" … … 12896 13301 diff -ruN ../netqmail-1.06-original/dnsptr.c netqmail-1.06/dnsptr.c 12897 13302 --- ../netqmail-1.06-original/dnsptr.c 1998-06-15 12:53:16.000000000 +0200 12898 +++ netqmail-1.06/dnsptr.c 201 6-11-22 21:03:57.113528065+010013303 +++ netqmail-1.06/dnsptr.c 2019-02-27 20:57:13.390025070 +0100 12899 13304 @@ -6,22 +6,28 @@ 12900 13305 #include "dns.h" … … 12932 13337 diff -ruN ../netqmail-1.06-original/dnstxt.c netqmail-1.06/dnstxt.c 12933 13338 --- ../netqmail-1.06-original/dnstxt.c 1970-01-01 01:00:00.000000000 +0100 12934 +++ netqmail-1.06/dnstxt.c 201 6-11-22 21:03:57.113528065+010013339 +++ netqmail-1.06/dnstxt.c 2019-02-27 20:57:13.390025070 +0100 12935 13340 @@ -0,0 +1,32 @@ 12936 13341 +#include "substdio.h" … … 12968 13373 diff -ruN ../netqmail-1.06-original/domainkeys.h netqmail-1.06/domainkeys.h 12969 13374 --- ../netqmail-1.06-original/domainkeys.h 1970-01-01 01:00:00.000000000 +0100 12970 +++ netqmail-1.06/domainkeys.h 20 18-03-31 15:08:54.373109416+020012971 @@ -0,0 +1,37 8@@13375 +++ netqmail-1.06/domainkeys.h 2020-04-09 19:45:10.589742433 +0200 13376 @@ -0,0 +1,379 @@ 12972 13377 +/* This file is automatically created from the corresponding .c file */ 12973 13378 +/* Do not change this file; change the .c file instead. */ … … 13037 13442 + DK_STAT_INTERNAL, /* cannot call this routine in this context. Internal error. */ 13038 13443 + DK_STAT_GRANULARITY, /* Granularity mismatch: sender doesn't match g= option. */ 13444 + DK_STAT_DUPLICATE, /* Duplicate Domainkey-Header */ 13039 13445 +} DK_STAT; 13040 13446 + … … 13350 13756 diff -ruN ../netqmail-1.06-original/forward.c netqmail-1.06/forward.c 13351 13757 --- ../netqmail-1.06-original/forward.c 1998-06-15 12:53:16.000000000 +0200 13352 +++ netqmail-1.06/forward.c 201 6-11-22 21:03:57.114528032+010013758 +++ netqmail-1.06/forward.c 2019-02-27 20:57:13.391025058 +0100 13353 13759 @@ -6,11 +6,11 @@ 13354 13760 #include "strerr.h" … … 13384 13790 diff -ruN ../netqmail-1.06-original/global.h netqmail-1.06/global.h 13385 13791 --- ../netqmail-1.06-original/global.h 1970-01-01 01:00:00.000000000 +0100 13386 +++ netqmail-1.06/global.h 201 6-11-22 21:03:57.114528032+010013792 +++ netqmail-1.06/global.h 2019-02-27 20:57:13.391025058 +0100 13387 13793 @@ -0,0 +1,51 @@ 13388 13794 +/* GLOBAL.H - RSAREF types and constants */ … … 13437 13843 + 13438 13844 +#endif /* end _GLOBAL_H_ */ 13439 diff -ruN ../netqmail-1.06-original/goodrcptto-12.patch netqmail-1.06/goodrcptto-12.patch13440 --- ../netqmail-1.06-original/goodrcptto-12.patch 1970-01-01 01:00:00.000000000 +010013441 +++ netqmail-1.06/goodrcptto-12.patch 2004-11-09 20:12:53.000000000 +010013442 @@ -0,0 +1,834 @@13443 +This is a goodrcptto patch for qmail-1.03 or netqmail-1.05:13444 +http://netdevice.com/qmail/patch/goodrcptto-12.patch13445 +See http://cr.yp.to/qmail.html or http://qmail.org/netqmail/.13446 +13447 +A qmail server will normally accept email for any recipient address at a domain.13448 +This patch causes the server to reject single recipient email to an invalid13449 +recipient, and filter out the invalid recipients from multiple recipient email,13450 +while accepting the message for the valid recipients.13451 +This occurs during the initial SMTP conversation for a reduction in disk I/O.13452 +The server rejects attempts to queue messages to non existent recipients, and13453 +joe job bounces to forged recipients, preventing them from becoming double13454 +bounces.13455 +To prevent dictionary attacks, the transmission channel is closed after the13456 +number of bad recipients set in control/brtlimit or BRTLIMIT, two by default.13457 +Repeated attempts from the same IPs may be handled by a cron that looks at the13458 +logs and updates tcprules accordingly.13459 +13460 +A goodrcptto list and or moregoodrcptto database is maintained.13461 +Relay and accept clients are not held to the address check, control/brtlimit or13462 +BRTLIMIT.13463 +If you need to wildcard domains, list them one per line like @example.net13464 +in control/goodrcptto only.13465 +Recipient addresses like name@example.com may be included in control/goodrcptto,13466 +but the check will run fastest if you put these into control/moregoodrcptto,13467 +then into control/moregoodrcptto.cdb using qmail-newmgrt.13468 +A check against a 50,000 address moregoodrcptto.cdb is virtually instantaneous13469 +on a 300Mhz machine.13470 +13471 +A user may want to participate in mailing list discussions, but doesn't want13472 +spam or off list replies to her now public address.13473 +Set ACCEPTCLIENT="" for the IPs of the mailing list servers with tcprules, and13474 +put the recipient address in control/protectedgood instead.13475 +13476 +For an example of how to automate this process, see the parent directory for an13477 +interactive user run script where one can remotely add, remove or list their13478 +disposable alias addresses, and the mail server cron that keeps the13479 +moregoodrcptto.cdb up to date.13480 +The patch assumes a Dave Sill type of installation with regards to extra control13481 +files concurrencyincoming and defaultdelivery, see http://lifewithqmail.org.13482 +13483 +Use http@ to get the patch onto your box, tab characters must be preserved.13484 +Here are examples of how to patch.13485 +13486 +Solaris:13487 +# gzip -cd qmail-1.03.tar.gz |tar -xf - ;cd qmail-1.0313488 +# gpatch </path/to/goodrcptto-12.patch13489 +or13490 +# gzip -cd netqmail-1.05.tar.gz |tar -xf - ;cd netqmail-1.0513491 +# sh -c "cat collate.sh |sed -e s/patch/gpatch/ >collate.sh"13492 +# ./collate.sh ;cd netqmail-1.0513493 +# gpatch </path/to/goodrcptto-12.patch13494 +13495 +Others:13496 +# gzip -cd qmail-1.03.tar.gz |tar -xf - ;cd qmail-1.0313497 +# patch </path/to/goodrcptto-12.patch13498 +or13499 +# gzip -cd netqmail-1.05.tar.gz |tar -xf - ;cd netqmail-1.0513500 +# ./collate.sh ;cd netqmail-1.0513501 +# patch </path/to/goodrcptto-12.patch13502 +13503 +Log example:13504 +2003-06-08 12:56:28.951415500 qmail-smtpd: !ok 29791 Bad recipient user nonexistent@example.com from DealsonWheels@321sm.com by 205.235.78.101 (HELO mx4.321sm.com).13505 +13506 +2003-06-08 01: Original version, based on John Levine's badrcptto patch:13507 + http://www.iecc.com/bad-rcpt-noisy-patch.txt13508 +2003-06-15 02: Added support for domain wildcarding.13509 +2003-06-15 03: Running qmail-showctl also shows good recipient addresses.13510 +2003-07-01 04: The pid for the connection is included in the log.13511 +2003-07-11 05: Experimental.13512 +2003-07-13 06: Experimental.13513 +2003-07-20 07: Removed the message block on a mix of good and bad recipients.13514 + Allowed for only using a goodrcptto list.13515 + Corrected an error in the qmail-showctl.c patch.13516 +2003-09-02 08: Added publicly known recipient address protection using an13517 + ACCEPTCLIENT tcprules variable.13518 +2003-10-04 09: Running qmail-showctl also shows protected recipient addresses.13519 +2003-11-07 10: Discontinued the non logging version of goodrcptto.13520 + Added dictionary attack prevention within qmail-smtpd using13521 + control/brtlimit and or BRTLIMIT.13522 + Updated the qmail-smtpd.8 man page patch regarding ACCEPTCLIENT,13523 + control/brtlimit and BRTLIMIT.13524 + Updated the qmail-control.9 man page patch regarding brtlimit,13525 + concurrencyincoming, defaultdelivery, goodrcptto, moregoodrcptto13526 + and protectedgood.13527 +2004-02-14 11: Code cleanup and standardization with tcpserver logging at13528 + getpid.13529 + This single patch works with both qmail-1.03 and netqmail-1.05.13530 + The brtcount is continued across rsets.13531 +2004-03-05 12: No changes, matched version number with goodrcptto-ms-12.patch.13532 +13533 +Eben Pratt, goodrcptto at netdevice dot com13534 +_____13535 +13536 +diff -ur qmail-1.03.orig/Makefile qmail-1.03/Makefile13537 +--- qmail-1.03.orig/Makefile Mon Jun 15 06:53:16 199813538 ++++ qmail-1.03/Makefile Sat Feb 14 02:41:03 200413539 +@@ -803,7 +803,7 @@13540 + predate datemail mailsubj qmail-upq qmail-showctl qmail-newu \13541 + qmail-pw2u qmail-qread qmail-qstat qmail-tcpto qmail-tcpok \13542 + qmail-pop3d qmail-popup qmail-qmqpc qmail-qmqpd qmail-qmtpd \13543 +-qmail-smtpd sendmail tcp-env qmail-newmrh config config-fast dnscname \13544 ++qmail-smtpd sendmail tcp-env qmail-newmrh qmail-newmgrt config config-fast dnscname \13545 + dnsptr dnsip dnsmxip dnsfq hostname ipmeprint qreceipt qsmhook qbiff \13546 + forward preline condredirect bouncesaying except maildirmake \13547 + maildir2mbox maildirwatch qail elq pinq idedit install-big install \13548 +@@ -930,8 +930,8 @@13549 + qmail-queue.0 qmail-inject.0 mailsubj.0 qmail-showctl.0 qmail-newu.0 \13550 + qmail-pw2u.0 qmail-qread.0 qmail-qstat.0 qmail-tcpto.0 qmail-tcpok.0 \13551 + qmail-pop3d.0 qmail-popup.0 qmail-qmqpc.0 qmail-qmqpd.0 qmail-qmtpd.0 \13552 +-qmail-smtpd.0 tcp-env.0 qmail-newmrh.0 qreceipt.0 qbiff.0 forward.0 \13553 +-preline.0 condredirect.0 bouncesaying.0 except.0 maildirmake.0 \13554 ++qmail-smtpd.0 tcp-env.0 qmail-newmrh.0 qmail-newmgrt.0 qreceipt.0 qbiff.0 \13555 ++forward.0 preline.0 condredirect.0 bouncesaying.0 except.0 maildirmake.0 \13556 + maildir2mbox.0 maildirwatch.0 qmail.0 qmail-limits.0 qmail-log.0 \13557 + qmail-control.0 qmail-header.0 qmail-users.0 dot-qmail.0 \13558 + qmail-command.0 tcp-environ.0 maildir.0 mbox.0 addresses.0 \13559 +@@ -1241,6 +1241,31 @@13560 + uint32.h substdio.h13561 + ./compile qmail-newmrh.c13562 +13563 ++qmail-newmgrt: \13564 ++load qmail-newmgrt.o cdbmss.o getln.a open.a cdbmake.a seek.a case.a \13565 ++stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o13566 ++ ./load qmail-newmgrt cdbmss.o getln.a open.a cdbmake.a \13567 ++ seek.a case.a stralloc.a alloc.a strerr.a substdio.a \13568 ++ error.a str.a auto_qmail.o13569 ++13570 ++qmail-newmgrt.0: \13571 ++qmail-newmgrt.813572 ++ nroff -man qmail-newmgrt.8 > qmail-newmgrt.013573 ++13574 ++qmail-newmgrt.8: \13575 ++qmail-newmgrt.9 conf-break conf-spawn13576 ++ cat qmail-newmgrt.9 \13577 ++ | sed s}QMAILHOME}"`head -1 conf-qmail`"}g \13578 ++ | sed s}BREAK}"`head -1 conf-break`"}g \13579 ++ | sed s}SPAWN}"`head -1 conf-spawn`"}g \13580 ++ > qmail-newmgrt.813581 ++13582 ++qmail-newmgrt.o: \13583 ++compile qmail-newmgrt.c strerr.h stralloc.h gen_alloc.h substdio.h \13584 ++getln.h exit.h readwrite.h open.h auto_qmail.h cdbmss.h cdbmake.h \13585 ++uint32.h substdio.h13586 ++ ./compile qmail-newmgrt.c13587 ++13588 + qmail-newu: \13589 + load qmail-newu.o cdbmss.o getln.a open.a seek.a cdbmake.a case.a \13590 + stralloc.a alloc.a substdio.a error.a str.a auto_qmail.o13591 +@@ -1767,7 +1792,7 @@13592 + maildirwatch.1 mailsubj.1 mbox.5 preline.1 qbiff.1 qmail-clean.8 \13593 + qmail-command.8 qmail-control.9 qmail-getpw.9 qmail-header.5 \13594 + qmail-inject.8 qmail-limits.9 qmail-local.8 qmail-log.5 \13595 +-qmail-lspawn.8 qmail-newmrh.9 qmail-newu.9 qmail-pop3d.8 \13596 ++qmail-lspawn.8 qmail-newmrh.9 qmail-newmgrt.9 qmail-newu.9 qmail-pop3d.8 \13597 + qmail-popup.8 qmail-pw2u.9 qmail-qmqpc.8 qmail-qmqpd.8 qmail-qmtpd.8 \13598 + qmail-qread.8 qmail-qstat.8 qmail-queue.8 qmail-remote.8 \13599 + qmail-rspawn.8 qmail-send.9 qmail-showctl.8 qmail-smtpd.8 \13600 +@@ -1774,7 +1799,7 @@13601 + qmail-start.9 qmail-tcpok.8 qmail-tcpto.8 qmail-users.9 qmail.7 \13602 + qreceipt.1 splogger.8 tcp-env.1 config.sh config-fast.sh \13603 + qmail-clean.c qmail-getpw.c qmail-inject.c qmail-local.c \13604 +-qmail-lspawn.c qmail-newmrh.c qmail-newu.c qmail-pop3d.c \13605 ++qmail-lspawn.c qmail-newmrh.c qmail-newmgrt.c qmail-newu.c qmail-pop3d.c \13606 + qmail-popup.c qmail-pw2u.c qmail-qmqpc.c qmail-qmqpd.c qmail-qmtpd.c \13607 + qmail-qread.c qmail-qstat.sh qmail-queue.c qmail-remote.c \13608 + qmail-rspawn.c qmail-send.c qmail-showctl.c qmail-smtpd.c \13609 +diff -ur qmail-1.03.orig/TARGETS qmail-1.03/TARGETS13610 +--- qmail-1.03.orig/TARGETS Mon Jun 15 06:53:16 199813611 ++++ qmail-1.03/TARGETS Sat Feb 14 02:41:03 200413612 +@@ -257,6 +257,8 @@13613 + tcp-env.o13614 + remoteinfo.o13615 + tcp-env13616 ++qmail-newmgrt.o13617 ++qmail-newmgrt13618 + qmail-newmrh.o13619 + qmail-newmrh13620 + config13621 +@@ -352,6 +354,8 @@13622 + qmail-qmtpd.013623 + qmail-smtpd.013624 + tcp-env.013625 ++qmail-newmgrt.813626 ++qmail-newmgrt.013627 + qmail-newmrh.813628 + qmail-newmrh.013629 + qreceipt.013630 +diff -ur qmail-1.03.orig/conf-spawn qmail-1.03/conf-spawn13631 +--- qmail-1.03.orig/conf-spawn Mon Jun 15 06:53:16 199813632 ++++ qmail-1.03/conf-spawn Sat Feb 14 02:41:03 200413633 +@@ -1,4 +1,4 @@13634 +-12013635 ++25513636 +13637 + This is a silent concurrency limit. You can't set it above 255. On some13638 + systems you can't set it above 125. qmail will refuse to compile if the13639 +diff -ur qmail-1.03.orig/hier.c qmail-1.03/hier.c13640 +--- qmail-1.03.orig/hier.c Mon Jun 15 06:53:16 199813641 ++++ qmail-1.03/hier.c Sat Feb 14 02:41:03 200413642 +@@ -109,6 +109,7 @@13643 + c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711);13644 + c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711);13645 + c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711);13646 ++ c(auto_qmail,"bin","qmail-newmgrt",auto_uido,auto_gidq,0700);13647 + c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700);13648 + c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700);13649 + c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711);13650 +@@ -221,6 +222,8 @@13651 + c(auto_qmail,"man/cat8","qmail-inject.0",auto_uido,auto_gidq,0644);13652 + c(auto_qmail,"man/man8","qmail-showctl.8",auto_uido,auto_gidq,0644);13653 + c(auto_qmail,"man/cat8","qmail-showctl.0",auto_uido,auto_gidq,0644);13654 ++ c(auto_qmail,"man/man8","qmail-newmgrt.8",auto_uido,auto_gidq,0644);13655 ++ c(auto_qmail,"man/cat8","qmail-newmgrt.0",auto_uido,auto_gidq,0644);13656 + c(auto_qmail,"man/man8","qmail-newmrh.8",auto_uido,auto_gidq,0644);13657 + c(auto_qmail,"man/cat8","qmail-newmrh.0",auto_uido,auto_gidq,0644);13658 + c(auto_qmail,"man/man8","qmail-newu.8",auto_uido,auto_gidq,0644);13659 +diff -ur qmail-1.03.orig/install-big.c qmail-1.03/install-big.c13660 +--- qmail-1.03.orig/install-big.c Mon Jun 15 06:53:16 199813661 ++++ qmail-1.03/install-big.c Sat Feb 14 02:41:03 200413662 +@@ -109,6 +109,7 @@13663 + c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711);13664 + c(auto_qmail,"bin","qmail-send",auto_uido,auto_gidq,0711);13665 + c(auto_qmail,"bin","splogger",auto_uido,auto_gidq,0711);13666 ++ c(auto_qmail,"bin","qmail-newmgrt",auto_uido,auto_gidq,0700);13667 + c(auto_qmail,"bin","qmail-newu",auto_uido,auto_gidq,0700);13668 + c(auto_qmail,"bin","qmail-newmrh",auto_uido,auto_gidq,0700);13669 + c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711);13670 +@@ -221,6 +222,8 @@13671 + c(auto_qmail,"man/cat8","qmail-inject.0",auto_uido,auto_gidq,0644);13672 + c(auto_qmail,"man/man8","qmail-showctl.8",auto_uido,auto_gidq,0644);13673 + c(auto_qmail,"man/cat8","qmail-showctl.0",auto_uido,auto_gidq,0644);13674 ++ c(auto_qmail,"man/man8","qmail-newmgrt.8",auto_uido,auto_gidq,0644);13675 ++ c(auto_qmail,"man/cat8","qmail-newmgrt.0",auto_uido,auto_gidq,0644);13676 + c(auto_qmail,"man/man8","qmail-newmrh.8",auto_uido,auto_gidq,0644);13677 + c(auto_qmail,"man/cat8","qmail-newmrh.0",auto_uido,auto_gidq,0644);13678 + c(auto_qmail,"man/man8","qmail-newu.8",auto_uido,auto_gidq,0644);13679 +diff -ur qmail-1.03.orig/qmail-control.9 qmail-1.03/qmail-control.913680 +--- qmail-1.03.orig/qmail-control.9 Mon Jun 15 06:53:16 199813681 ++++ qmail-1.03/qmail-control.9 Sat Feb 14 02:41:03 200413682 +@@ -21,6 +21,7 @@13683 + Comments are allowed13684 + in13685 + .IR badmailfrom ,13686 ++.IR goodrcptto ,13687 + .IR locals ,13688 + .IR percenthack ,13689 + .IR qmqpservers ,13690 +@@ -43,8 +44,11 @@13691 + .I badmailfrom \fR(none) \fRqmail-smtpd13692 + .I bouncefrom \fRMAILER-DAEMON \fRqmail-send13693 + .I bouncehost \fIme \fRqmail-send13694 ++.I brtlimit \fR2 \fRqmail-smtpd13695 ++.I concurrencyincoming \fR40 \fRtcpserver13696 + .I concurrencylocal \fR10 \fRqmail-send13697 + .I concurrencyremote \fR20 \fRqmail-send13698 ++.I defaultdelivery \fR(none) \fRqmail-start13699 + .I defaultdomain \fIme \fRqmail-inject13700 + .I defaulthost \fIme \fRqmail-inject13701 + .I databytes \fR0 \fRqmail-smtpd13702 +@@ -51,13 +55,16 @@13703 + .I doublebouncehost \fIme \fRqmail-send13704 + .I doublebounceto \fRpostmaster \fRqmail-send13705 + .I envnoathost \fIme \fRqmail-send13706 ++.I goodrcptto \fR(none) \fRqmail-smtpd13707 + .I helohost \fIme \fRqmail-remote13708 + .I idhost \fIme \fRqmail-inject13709 + .I localiphost \fIme \fRqmail-smtpd13710 + .I locals \fIme \fRqmail-send13711 ++.I moregoodrcptto \fR(none) \fRqmail-smtpd13712 + .I morercpthosts \fR(none) \fRqmail-smtpd13713 + .I percenthack \fR(none) \fRqmail-send13714 + .I plusdomain \fIme \fRqmail-inject13715 ++.I protectedgood \fR(none) \fRqmail-showctl13716 + .I qmqpservers \fR(none) \fRqmail-qmqpc13717 + .I queuelifetime \fR604800 \fRqmail-send13718 + .I rcpthosts \fR(none) \fRqmail-smtpd13719 +diff -ur qmail-1.03.orig/qmail-newmgrt.9 qmail-1.03/qmail-newmgrt.913720 +--- qmail-1.03.orig/qmail-newmgrt.9 Thu Jan 1 00:00:00 197013721 ++++ qmail-1.03/qmail-newmgrt.9 Sat Feb 14 02:41:04 200413722 +@@ -0,0 +1,41 @@13723 ++.TH qmail-newmgrt 813724 ++.SH NAME13725 ++qmail-newmgrt \- prepare moregoodrcptto for qmail-smtpd13726 ++.SH SYNOPSIS13727 ++.B qmail-newmgrt13728 ++.SH DESCRIPTION13729 ++.B qmail-newmgrt13730 ++reads the instructions in13731 ++.B QMAILHOME/control/moregoodrcptto13732 ++and writes them into13733 ++.B QMAILHOME/control/moregoodrcptto.cdb13734 ++in a binary format suited13735 ++for quick access by13736 ++.BR qmail-smtpd .13737 ++13738 ++If there is a problem with13739 ++.BR control/moregoodrcptto ,13740 ++.B qmail-newmgrt13741 ++complains and leaves13742 ++.B control/moregoodrcptto.cdb13743 ++alone.13744 ++13745 ++.B qmail-newmgrt13746 ++ensures that13747 ++.B control/moregoodrcptto.cdb13748 ++is updated atomically,13749 ++so13750 ++.B qmail-smtpd13751 ++never has to wait for13752 ++.B qmail-newmgrt13753 ++to finish.13754 ++However,13755 ++.B qmail-newmgrt13756 ++makes no attempt to protect against two simultaneous updates of13757 ++.BR control/moregoodrcptto.cdb .13758 ++13759 ++The binary13760 ++.B control/moregoodrcptto.cdb13761 ++format is portable across machines.13762 ++.SH "SEE ALSO"13763 ++qmail-smtpd(8)13764 +diff -ur qmail-1.03.orig/qmail-newmgrt.c qmail-1.03/qmail-newmgrt.c13765 +--- qmail-1.03.orig/qmail-newmgrt.c Thu Jan 1 00:00:00 197013766 ++++ qmail-1.03/qmail-newmgrt.c Sat Feb 14 02:41:04 200413767 +@@ -0,0 +1,70 @@13768 ++#include "strerr.h"13769 ++#include "stralloc.h"13770 ++#include "substdio.h"13771 ++#include "getln.h"13772 ++#include "exit.h"13773 ++#include "readwrite.h"13774 ++#include "open.h"13775 ++#include "auto_qmail.h"13776 ++#include "cdbmss.h"13777 ++13778 ++#define FATAL "qmail-newmgrt: fatal: "13779 ++13780 ++void die_read()13781 ++{13782 ++ strerr_die2sys(111,FATAL,"unable to read control/moregoodrcptto: ");13783 ++}13784 ++void die_write()13785 ++{13786 ++ strerr_die2sys(111,FATAL,"unable to write to control/moregoodrcptto.tmp: ");13787 ++}13788 ++13789 ++char inbuf[1024];13790 ++substdio ssin;13791 ++13792 ++int fd;13793 ++int fdtemp;13794 ++13795 ++struct cdbmss cdbmss;13796 ++stralloc line = {0};13797 ++int match;13798 ++13799 ++void main()13800 ++{13801 ++ umask(033);13802 ++ if (chdir(auto_qmail) == -1)13803 ++ strerr_die4sys(111,FATAL,"unable to chdir to ",auto_qmail,": ");13804 ++13805 ++ fd = open_read("control/moregoodrcptto");13806 ++ if (fd == -1) die_read();13807 ++13808 ++ substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf);13809 ++13810 ++ fdtemp = open_trunc("control/moregoodrcptto.tmp");13811 ++ if (fdtemp == -1) die_write();13812 ++13813 ++ if (cdbmss_start(&cdbmss,fdtemp) == -1) die_write();13814 ++13815 ++ for (;;) {13816 ++ if (getln(&ssin,&line,&match,'\n') != 0) die_read();13817 ++ case_lowerb(line.s,line.len);13818 ++ while (line.len) {13819 ++ if (line.s[line.len - 1] == ' ') { --line.len; continue; }13820 ++ if (line.s[line.len - 1] == '\n') { --line.len; continue; }13821 ++ if (line.s[line.len - 1] == '\t') { --line.len; continue; }13822 ++ if (line.s[0] != '#')13823 ++ if (cdbmss_add(&cdbmss,line.s,line.len,"",0) == -1)13824 ++ die_write();13825 ++ break;13826 ++ }13827 ++ if (!match) break;13828 ++ }13829 ++13830 ++ if (cdbmss_finish(&cdbmss) == -1) die_write();13831 ++ if (fsync(fdtemp) == -1) die_write();13832 ++ if (close(fdtemp) == -1) die_write(); /* NFS stupidity */13833 ++ if (rename("control/moregoodrcptto.tmp","control/moregoodrcptto.cdb") == -1)13834 ++ strerr_die2sys(111,FATAL,"unable to move control/moregoodrcpto.tmp to control/moregoodrcptto.cdb");13835 ++13836 ++ _exit(0);13837 ++}13838 +diff -ur qmail-1.03.orig/qmail-showctl.c qmail-1.03/qmail-showctl.c13839 +--- qmail-1.03.orig/qmail-showctl.c Mon Jun 15 06:53:16 199813840 ++++ qmail-1.03/qmail-showctl.c Sat Feb 14 02:41:04 200413841 +@@ -142,6 +142,8 @@13842 + direntry *d;13843 + struct stat stmrh;13844 + struct stat stmrhcdb;13845 ++ struct stat stmgrt;13846 ++ struct stat stmgrtcdb;13847 +13848 + substdio_puts(subfdout,"qmail home directory: ");13849 + substdio_puts(subfdout,auto_qmail);13850 +@@ -217,9 +219,12 @@13851 + do_lst("badmailfrom","Any MAIL FROM is allowed.",""," not accepted in MAIL FROM.");13852 + do_str("bouncefrom",0,"MAILER-DAEMON","Bounce user name is ");13853 + do_str("bouncehost",1,"bouncehost","Bounce host name is ");13854 ++ do_int("brtlimit","2","Transmission channel close after "," bad recipients");13855 ++ do_int("concurrencyincoming","1","Incoming concurrency is ","");13856 + do_int("concurrencylocal","10","Local concurrency is ","");13857 + do_int("concurrencyremote","20","Remote concurrency is ","");13858 + do_int("databytes","0","SMTP DATA limit is "," bytes");13859 ++ do_str("defaultdelivery",1,"defaultdelivery","Default mailbox is ");13860 + do_str("defaultdomain",1,"defaultdomain","Default domain name is ");13861 + do_str("defaulthost",1,"defaulthost","Default host name is ");13862 + do_str("doublebouncehost",1,"doublebouncehost","2B recipient host: ");13863 +@@ -235,8 +240,8 @@13864 + do_lst("qmqpservers","No QMQP servers.","QMQP server: ",".");13865 + do_int("queuelifetime","604800","Message lifetime in the queue is "," seconds");13866 +13867 +- if (do_lst("rcpthosts","SMTP clients may send messages to any recipient.","SMTP clients may send messages to recipients at ","."))13868 +- do_lst("morercpthosts","No effect.","SMTP clients may send messages to recipients at ",".");13869 ++ if (do_lst("rcpthosts","SMTP relay clients may send to any recipient.","SMTP relay clients may send to recipients at ","."))13870 ++ do_lst("morercpthosts","No effect.","SMTP relay clients may send to recipients at ",".");13871 + else13872 + do_lst("morercpthosts","No rcpthosts; morercpthosts is irrelevant.","No rcpthosts; doesn't matter that morercpthosts has ",".");13873 + /* XXX: check morercpthosts.cdb contents */13874 +@@ -255,6 +260,27 @@13875 + else13876 + substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n");13877 +13878 ++ if (do_lst("goodrcptto","Oops? moregoodrcptto must exist if this doesn't.","SMTP clients may send to ","."))13879 ++ do_lst("moregoodrcptto","No effect.","SMTP clients may send to ",".");13880 ++ else13881 ++ do_lst("moregoodrcptto","Oops? goodrcptto must exist if this doesn't.","SMTP clients may send to ",".");13882 ++ /* XXX: check moregoodrcptto.cdb contents */13883 ++ substdio_puts(subfdout,"\nmoregoodrcptto.cdb: ");13884 ++ if (stat("moregoodrcptto",&stmgrt) == -1)13885 ++ if (stat("moregoodrcptto.cdb",&stmgrtcdb) == -1)13886 ++ substdio_puts(subfdout,"(Default.) No effect.\n");13887 ++ else13888 ++ substdio_puts(subfdout,"Oops! moregoodrcptto.cdb exists but moregoodrcptto doesn't.\n");13889 ++ else13890 ++ if (stat("moregoodrcptto.cdb",&stmgrtcdb) == -1)13891 ++ substdio_puts(subfdout,"Oops! moregoodrcptto exists but moregoodrcptto.cdb doesn't.\n");13892 ++ else13893 ++ if (stmgrt.st_mtime > stmgrtcdb.st_mtime)13894 ++ substdio_puts(subfdout,"Oops! moregoodrcptto.cdb is older than moregoodrcptto.\n");13895 ++ else13896 ++ substdio_puts(subfdout,"Modified recently enough; hopefully up to date.\n");13897 ++13898 ++ do_lst("protectedgood","No accept client addresses.","SMTP accept clients may send to ",".");13899 + do_str("smtpgreeting",1,"smtpgreeting","SMTP greeting: 220 ");13900 + do_lst("smtproutes","No artificial SMTP routes.","SMTP route: ","");13901 + do_int("timeoutconnect","60","SMTP client connection timeout is "," seconds");13902 +@@ -265,19 +291,21 @@13903 + while (d = readdir(dir)) {13904 + if (str_equal(d->d_name,".")) continue;13905 + if (str_equal(d->d_name,"..")) continue;13906 +- if (str_equal(d->d_name,"bouncefrom")) continue;13907 +- if (str_equal(d->d_name,"bouncehost")) continue;13908 + if (str_equal(d->d_name,"badmailfrom")) continue;13909 + if (str_equal(d->d_name,"bouncefrom")) continue;13910 + if (str_equal(d->d_name,"bouncehost")) continue;13911 ++ if (str_equal(d->d_name,"brtlimit")) continue;13912 ++ if (str_equal(d->d_name,"concurrencyincoming")) continue;13913 + if (str_equal(d->d_name,"concurrencylocal")) continue;13914 + if (str_equal(d->d_name,"concurrencyremote")) continue;13915 + if (str_equal(d->d_name,"databytes")) continue;13916 ++ if (str_equal(d->d_name,"defaultdelivery")) continue;13917 + if (str_equal(d->d_name,"defaultdomain")) continue;13918 + if (str_equal(d->d_name,"defaulthost")) continue;13919 + if (str_equal(d->d_name,"doublebouncehost")) continue;13920 + if (str_equal(d->d_name,"doublebounceto")) continue;13921 + if (str_equal(d->d_name,"envnoathost")) continue;13922 ++ if (str_equal(d->d_name,"goodrcptto")) continue;13923 + if (str_equal(d->d_name,"helohost")) continue;13924 + if (str_equal(d->d_name,"idhost")) continue;13925 + if (str_equal(d->d_name,"localiphost")) continue;13926 +@@ -285,8 +313,11 @@13927 + if (str_equal(d->d_name,"me")) continue;13928 + if (str_equal(d->d_name,"morercpthosts")) continue;13929 + if (str_equal(d->d_name,"morercpthosts.cdb")) continue;13930 ++ if (str_equal(d->d_name,"moregoodrcptto")) continue;13931 ++ if (str_equal(d->d_name,"moregoodrcptto.cdb")) continue;13932 + if (str_equal(d->d_name,"percenthack")) continue;13933 + if (str_equal(d->d_name,"plusdomain")) continue;13934 ++ if (str_equal(d->d_name,"protectedgood")) continue;13935 + if (str_equal(d->d_name,"qmqpservers")) continue;13936 + if (str_equal(d->d_name,"queuelifetime")) continue;13937 + if (str_equal(d->d_name,"rcpthosts")) continue;13938 +diff -ur qmail-1.03.orig/qmail-smtpd.8 qmail-1.03/qmail-smtpd.813939 +--- qmail-1.03.orig/qmail-smtpd.8 Mon Jun 15 06:53:16 199813940 ++++ qmail-1.03/qmail-smtpd.8 Sat Feb 14 02:41:04 200413941 +@@ -50,6 +50,20 @@13942 + meaning every address at13943 + .IR host .13944 + .TP 513945 ++.I brtlimit13946 ++Number of bad recipients before closing the transmission channel.13947 ++.B qmail-smtpd13948 ++will close the transmission channel after13949 ++reaching the number of bad recipients in13950 ++.IR brtlimit .13951 ++13952 ++If the environment variable13953 ++.B BRTLIMIT13954 ++is set, it overrides13955 ++.IR brtlimit .13956 ++13957 ++Default and minimum: 2.13958 ++.TP 513959 + .I databytes13960 + Maximum number of bytes allowed in a message,13961 + or 0 for no limit.13962 +@@ -77,6 +91,50 @@13963 + is set, it overrides13964 + .IR databytes .13965 + .TP 513966 ++.I goodrcptto13967 ++Allowed RCPT addresses.13968 ++.B qmail-smtpd13969 ++will reject13970 ++any envelope recipient address not listed in13971 ++.I goodrcptto13972 ++or13973 ++.IR moregoodrcptto .13974 ++A line in13975 ++.I goodrcptto13976 ++may be of the form13977 ++.BR @\fIhost ,13978 ++meaning every address at13979 ++.IR host .13980 ++13981 ++.I goodrcptto13982 ++format:13983 ++13984 ++.EX13985 ++ @heaven.af.mil13986 ++ box@heaven.af.mil13987 ++.EE13988 ++13989 ++Exceptions:13990 ++If the environment variable13991 ++.B RELAYCLIENT13992 ++is set,13993 ++.B qmail-smtpd13994 ++will ignore13995 ++.I goodrcptto13996 ++and13997 ++.IR moregoodrcptto ,13998 ++and will append the value of13999 ++.B RELAYCLIENT14000 ++to each incoming recipient address.14001 ++If the environment variable14002 ++.B ACCEPTCLIENT14003 ++is set,14004 ++.B qmail-smtpd14005 ++will ignore14006 ++.I goodrcptto14007 ++and14008 ++.IR moregoodrcptto .14009 ++.TP 514010 + .I localiphost14011 + Replacement host name for local IP addresses.14012 + Default:14013 +@@ -97,6 +155,38 @@14014 + This is done before14015 + .IR rcpthosts .14016 + .TP 514017 ++.I moregoodrcptto14018 ++Extra allowed RCPT addresses.14019 ++If14020 ++.I goodrcptto14021 ++and14022 ++.I moregoodrcptto14023 ++both exist,14024 ++.I moregoodrcptto14025 ++is effectively appended to14026 ++.IR goodrcptto .14027 ++14028 ++.I moregoodrcptto14029 ++format:14030 ++14031 ++.EX14032 ++ box@heaven.af.mil14033 ++.EE14034 ++14035 ++You must run14036 ++.B qmail-newmgrt14037 ++whenever14038 ++.I moregoodrcptto14039 ++changes.14040 ++14041 ++Rule of thumb:14042 ++Put your14043 ++.BR @\fIhost14044 ++wildcarded domains into14045 ++.IR goodrcptto ,14046 ++and the rest into14047 ++.IR moregoodrcptto .14048 ++.TP 514049 + .I morercpthosts14050 + Extra allowed RCPT domains.14051 + If14052 +@@ -150,7 +240,7 @@14053 + .EE14054 +14055 + Envelope recipient addresses without @ signs are14056 +-always allowed through.14057 ++allowed through if added to goodrcptto or moregoodrcptto.14058 + .TP 514059 + .I smtpgreeting14060 + SMTP greeting message.14061 +@@ -174,6 +264,7 @@14062 + tcp-environ(5),14063 + qmail-control(5),14064 + qmail-inject(8),14065 ++qmail-newmgrt(8),14066 + qmail-newmrh(8),14067 + qmail-queue(8),14068 + qmail-remote(8)14069 +diff -ur qmail-1.03.orig/qmail-smtpd.c qmail-1.03/qmail-smtpd.c14070 +--- qmail-1.03.orig/qmail-smtpd.c Mon Jun 15 06:53:16 199814071 ++++ qmail-1.03/qmail-smtpd.c Sat Feb 14 03:12:49 200414072 +@@ -23,11 +23,19 @@14073 + #include "timeoutread.h"14074 + #include "timeoutwrite.h"14075 + #include "commands.h"14076 ++#include "cdb.h"14077 +14078 + #define MAXHOPS 10014079 + unsigned int databytes = 0;14080 + int timeout = 1200;14081 +14082 ++char *remoteip;14083 ++char *remotehost;14084 ++char *remoteinfo;14085 ++char *local;14086 ++char *relayclient;14087 ++char *acceptclient;14088 ++14089 + int safewrite(fd,buf,len) int fd; char *buf; int len;14090 + {14091 + int r;14092 +@@ -42,12 +50,39 @@14093 + void flush() { substdio_flush(&ssout); }14094 + void out(s) char *s; { substdio_puts(&ssout,s); }14095 +14096 ++char sserrbuf[512];14097 ++substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof sserrbuf);14098 ++14099 ++char strnum[FMT_ULONG];14100 ++void log(s) char *s; { substdio_putsflush(&sserr,s); }14101 ++void logs(s1,s2,s3) char *s1; char *s2; char *s3; {14102 ++ substdio_putsflush(&sserr,s1);14103 ++ substdio_putsflush(&sserr,s2);14104 ++ substdio_putsflush(&sserr,s3);14105 ++}14106 ++void pid() { log("qmail-smtpd: !ok "); strnum[fmt_ulong(strnum,getpid())] = 0; log(strnum); }14107 ++14108 + void die_read() { _exit(1); }14109 +-void die_alarm() { out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); }14110 +-void die_nomem() { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); }14111 +-void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }14112 +-void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }14113 +-void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); }14114 ++void die_alarm() {14115 ++ pid(); logs(" Connection to ",remoteip," timed out.\n");14116 ++ out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1);14117 ++}14118 ++void die_nomem() {14119 ++ pid(); logs(" Out of memory while connected to ",remoteip,"!\n");14120 ++ out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1);14121 ++}14122 ++void die_control() {14123 ++ pid(); log(" Unable to read controls!\n");14124 ++ out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1);14125 ++}14126 ++void die_ipme() {14127 ++ pid(); log(" Unable to figure out my IP addresses!\n");14128 ++ out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1);14129 ++}14130 ++void straynewline() {14131 ++ pid(); logs(" Stray newline from ",remoteip,".\n");14132 ++ out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1);14133 ++}14134 +14135 + void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }14136 + void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); }14137 +@@ -76,12 +111,6 @@14138 + smtp_greet("221 "); out("\r\n"); flush(); _exit(0);14139 + }14140 +14141 +-char *remoteip;14142 +-char *remotehost;14143 +-char *remoteinfo;14144 +-char *local;14145 +-char *relayclient;14146 +-14147 + stralloc helohost = {0};14148 + char *fakehelo; /* pointer into helohost, or 0 */14149 +14150 +@@ -96,6 +125,11 @@14151 + int bmfok = 0;14152 + stralloc bmf = {0};14153 + struct constmap mapbmf;14154 ++int grtok = 0;14155 ++stralloc grt = {0};14156 ++struct constmap mapgrt;14157 ++int fdmgrt;14158 ++int brtlimit = 0;14159 +14160 + void setup()14161 + {14162 +@@ -117,6 +151,19 @@14163 + if (bmfok)14164 + if (!constmap_init(&mapbmf,bmf.s,bmf.len,0)) die_nomem();14165 +14166 ++ grtok = control_readfile(&grt,"control/goodrcptto",0);14167 ++ if (grtok == -1) die_control();14168 ++ if (grtok)14169 ++ if (!constmap_init(&mapgrt,grt.s,grt.len,0)) die_nomem();14170 ++14171 ++ fdmgrt = open_read("control/moregoodrcptto.cdb");14172 ++ if (fdmgrt == -1) if (errno != error_noent) die_control();14173 ++14174 ++ if (control_readint(&brtlimit,"control/brtlimit") == -1) die_control();14175 ++ x = env_get("BRTLIMIT");14176 ++ if (x) { scan_ulong(x,&u); brtlimit = u; };14177 ++ if (brtlimit <= 1) brtlimit = 2;14178 ++14179 + if (control_readint(&databytes,"control/databytes") == -1) die_control();14180 + x = env_get("DATABYTES");14181 + if (x) { scan_ulong(x,&u); databytes = u; }14182 +@@ -131,6 +178,7 @@14183 + if (!remotehost) remotehost = "unknown";14184 + remoteinfo = env_get("TCPREMOTEINFO");14185 + relayclient = env_get("RELAYCLIENT");14186 ++ acceptclient = env_get("ACCEPTCLIENT");14187 + dohelo(remotehost);14188 + }14189 +14190 +@@ -197,6 +245,16 @@14191 + return 1;14192 + }14193 +14194 ++void err_brt(s1,s2,s3,s4) char *s1; char *s2; char *s3; char *s4; {14195 ++ pid(); log(s1); log(s2); log(s3); log(s4); log(" by ");14196 ++ log(remoteip); log(" (HELO "); log(helohost.s); log(").\n");14197 ++}14198 ++14199 ++void die_attack() {14200 ++ pid(); logs(" Too many bad recipients from ",remoteip,", closing connection.\n");14201 ++ out("421 service shutting down and closing transmission channel (#4.3.0)\r\n"); flush(); _exit(1);14202 ++}14203 ++14204 + int bmfcheck()14205 + {14206 + int j;14207 +@@ -208,6 +266,24 @@14208 + return 0;14209 + }14210 +14211 ++int grtcheck()14212 ++{14213 ++ int g;14214 ++ case_lowerb(addr.s,addr.len);14215 ++ if (grtok) {14216 ++ if (constmap(&mapgrt,addr.s,addr.len - 1)) return 1;14217 ++ g = byte_rchr(addr.s,addr.len,'@');14218 ++ if (g < addr.len)14219 ++ if (constmap(&mapgrt,addr.s + g,addr.len - g - 1)) return 1;14220 ++ }14221 ++ if (fdmgrt != -1) {14222 ++ uint32 dlen;14223 ++ g = cdb_seek(fdmgrt, addr.s, addr.len - 1, &dlen);14224 ++ if (g) return g;14225 ++ }14226 ++ return 0;14227 ++}14228 ++14229 + int addrallowed()14230 + {14231 + int r;14232 +@@ -221,6 +297,7 @@14233 + int flagbarf; /* defined if seenmail */14234 + stralloc mailfrom = {0};14235 + stralloc rcptto = {0};14236 ++int brtcount;14237 +14238 + void smtp_helo(arg) char *arg;14239 + {14240 +@@ -250,7 +327,10 @@14241 + void smtp_rcpt(arg) char *arg; {14242 + if (!seenmail) { err_wantmail(); return; }14243 + if (!addrparse(arg)) { err_syntax(); return; }14244 +- if (flagbarf) { err_bmf(); return; }14245 ++ if (flagbarf) {14246 ++ err_brt(" Bad envelope sender ",mailfrom.s," to ",addr.s);14247 ++ err_bmf(); return;14248 ++ }14249 + if (relayclient) {14250 + --addr.len;14251 + if (!stralloc_cats(&addr,relayclient)) die_nomem();14252 +@@ -257,7 +337,23 @@14253 + if (!stralloc_0(&addr)) die_nomem();14254 + }14255 + else14256 +- if (!addrallowed()) { err_nogateway(); return; }14257 ++ if (!addrallowed()) {14258 ++ err_brt(" Bad recipient host ",addr.s," from ",mailfrom.s);14259 ++ if (++brtcount == brtlimit) die_attack();14260 ++ err_nogateway(); return;14261 ++ }14262 ++ else14263 ++ if (!acceptclient) {14264 ++ if (!grtcheck()) {14265 ++ if (str_equal(mailfrom.s,"")) {14266 ++ err_brt(" Forged recipient user ",addr.s," from ","null");14267 ++ }14268 ++ else14269 ++ err_brt(" Bad recipient user ",addr.s," from ",mailfrom.s);14270 ++ if (++brtcount == brtlimit) die_attack();14271 ++ out("550 sorry, no mailbox here by that name (#5.1.1)\r\n"); return;14272 ++ }14273 ++ }14274 + if (!stralloc_cats(&rcptto,"T")) die_nomem();14275 + if (!stralloc_cats(&rcptto,addr.s)) die_nomem();14276 + if (!stralloc_0(&rcptto)) die_nomem();14277 13845 diff -ruN ../netqmail-1.06-original/hier.c netqmail-1.06/hier.c 14278 13846 --- ../netqmail-1.06-original/hier.c 1998-06-15 12:53:16.000000000 +0200 14279 +++ netqmail-1.06/hier.c 2018-01-04 22:33:49.406411066 +0100 14280 @@ -32,6 +32,7 @@ 13847 +++ netqmail-1.06/hier.c 2019-06-26 16:39:31.573826970 +0200 13848 @@ -4,6 +4,9 @@ 13849 #include "fmt.h" 13850 #include "fifo.h" 13851 13852 +#include <stdio.h> 13853 +#include "channels.h" 13854 + 13855 char buf[100 + FMT_ULONG]; 13856 13857 void dsplit(base,uid,mode) 13858 @@ -29,9 +32,12 @@ 13859 13860 void hier() 13861 { 13862 + int cc; 13863 + 14281 13864 h(auto_qmail,auto_uido,auto_gidq,0755); 14282 13865 … … 14286 13869 d(auto_qmail,"bin",auto_uido,auto_gidq,0755); 14287 13870 d(auto_qmail,"boot",auto_uido,auto_gidq,0755); 14288 @@ -55, 6 +56,8@@13871 @@ -55,10 +61,20 @@ 14289 13872 d(auto_qmail,"queue/bounce",auto_uids,auto_gidq,0700); 14290 13873 … … 14295 13878 dsplit("queue/local",auto_uids,0700); 14296 13879 dsplit("queue/remote",auto_uids,0700); 14297 @@ -89,6 +92,7 @@ 13880 13881 + for (cc = 0;cc < SUPPL_CHANNELS;++cc) 13882 + { 13883 + char adbuf[100]; 13884 + 13885 + sprintf(adbuf,"queue/" QDIR_BASENAME "%d", cc); 13886 + dsplit(adbuf,auto_uids,0700); 13887 + } 13888 + 13889 d(auto_qmail,"queue/lock",auto_uidq,auto_gidq,0750); 13890 z(auto_qmail,"queue/lock/tcpto",1024,auto_uidr,auto_gidq,0644); 13891 z(auto_qmail,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600); 13892 @@ -89,6 +105,7 @@ 14298 13893 c(auto_qmail,"doc","TEST.receive",auto_uido,auto_gidq,0644); 14299 13894 c(auto_qmail,"doc","REMOVE.sendmail",auto_uido,auto_gidq,0644); … … 14303 13898 c(auto_qmail,"doc","PIC.local2ext",auto_uido,auto_gidq,0644); 14304 13899 c(auto_qmail,"doc","PIC.local2local",auto_uido,auto_gidq,0644); 14305 @@ -104,13 +1 08,26 @@13900 @@ -104,13 +121,26 @@ 14306 13901 c(auto_qmail,"bin","qmail-start",auto_uido,auto_gidq,0700); 14307 13902 c(auto_qmail,"bin","qmail-getpw",auto_uido,auto_gidq,0711); … … 14330 13925 c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755); 14331 13926 c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755); 14332 @@ -127,6 +1 44,7 @@13927 @@ -127,6 +157,7 @@ 14333 13928 c(auto_qmail,"bin","qmail-qmqpd",auto_uido,auto_gidq,0755); 14334 13929 c(auto_qmail,"bin","qmail-qmtpd",auto_uido,auto_gidq,0755); … … 14338 13933 c(auto_qmail,"bin","tcp-env",auto_uido,auto_gidq,0755); 14339 13934 c(auto_qmail,"bin","qreceipt",auto_uido,auto_gidq,0755); 14340 @@ -143,6 +1 61,9 @@13935 @@ -143,6 +174,9 @@ 14341 13936 c(auto_qmail,"bin","qail",auto_uido,auto_gidq,0755); 14342 13937 c(auto_qmail,"bin","elq",auto_uido,auto_gidq,0755); … … 14348 13943 c(auto_qmail,"man/man5","addresses.5",auto_uido,auto_gidq,0644); 14349 13944 c(auto_qmail,"man/cat5","addresses.0",auto_uido,auto_gidq,0644); 14350 @@ -198,6 +2 19,18 @@13945 @@ -198,6 +232,18 @@ 14351 13946 c(auto_qmail,"man/cat1","tcp-env.0",auto_uido,auto_gidq,0644); 14352 13947 … … 14369 13964 diff -ruN ../netqmail-1.06-original/hmac_md5.c netqmail-1.06/hmac_md5.c 14370 13965 --- ../netqmail-1.06-original/hmac_md5.c 1970-01-01 01:00:00.000000000 +0100 14371 +++ netqmail-1.06/hmac_md5.c 201 6-11-22 21:03:57.114528032+010013966 +++ netqmail-1.06/hmac_md5.c 2019-02-27 20:57:13.391025058 +0100 14372 13967 @@ -0,0 +1,76 @@ 14373 13968 +#include "global.h" … … 14449 14044 diff -ruN ../netqmail-1.06-original/hmac_md5.h netqmail-1.06/hmac_md5.h 14450 14045 --- ../netqmail-1.06-original/hmac_md5.h 1970-01-01 01:00:00.000000000 +0100 14451 +++ netqmail-1.06/hmac_md5.h 201 6-11-22 21:03:57.114528032+010014046 +++ netqmail-1.06/hmac_md5.h 2019-02-27 20:57:13.391025058 +0100 14452 14047 @@ -0,0 +1,11 @@ 14453 14048 + … … 14464 14059 diff -ruN ../netqmail-1.06-original/install-big.c netqmail-1.06/install-big.c 14465 14060 --- ../netqmail-1.06-original/install-big.c 1998-06-15 12:53:16.000000000 +0200 14466 +++ netqmail-1.06/install-big.c 2016-11-22 21:04:38.822137319 +0100 14467 @@ -89,6 +89,7 @@ 14061 +++ netqmail-1.06/install-big.c 2019-06-26 16:39:31.574826959 +0200 14062 @@ -4,6 +4,9 @@ 14063 #include "fmt.h" 14064 #include "fifo.h" 14065 14066 +#include <stdio.h> 14067 +#include "channels.h" 14068 + 14069 char buf[100 + FMT_ULONG]; 14070 14071 void dsplit(base,uid,mode) 14072 @@ -29,6 +32,8 @@ 14073 14074 void hier() 14075 { 14076 + int cc; 14077 + 14078 h(auto_qmail,auto_uido,auto_gidq,0755); 14079 14080 d(auto_qmail,"control",auto_uido,auto_gidq,0755); 14081 @@ -59,6 +64,14 @@ 14082 dsplit("queue/local",auto_uids,0700); 14083 dsplit("queue/remote",auto_uids,0700); 14084 14085 + for (cc = 0;cc < SUPPL_CHANNELS;++cc) 14086 + { 14087 + char adbuf[100]; 14088 + 14089 + sprintf(adbuf,"queue/" QDIR_BASENAME "%d", cc); 14090 + dsplit(adbuf,auto_uids,0700); 14091 + } 14092 + 14093 d(auto_qmail,"queue/lock",auto_uidq,auto_gidq,0750); 14094 z(auto_qmail,"queue/lock/tcpto",1024,auto_uidr,auto_gidq,0644); 14095 z(auto_qmail,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600); 14096 @@ -89,6 +102,7 @@ 14468 14097 c(auto_qmail,"doc","TEST.receive",auto_uido,auto_gidq,0644); 14469 14098 c(auto_qmail,"doc","REMOVE.sendmail",auto_uido,auto_gidq,0644); … … 14473 14102 c(auto_qmail,"doc","PIC.local2ext",auto_uido,auto_gidq,0644); 14474 14103 c(auto_qmail,"doc","PIC.local2local",auto_uido,auto_gidq,0644); 14475 @@ -108,9 +1 09,13 @@14104 @@ -108,9 +122,13 @@ 14476 14105 c(auto_qmail,"bin","qmail-rspawn",auto_uido,auto_gidq,0711); 14477 14106 c(auto_qmail,"bin","qmail-clean",auto_uido,auto_gidq,0711); … … 14487 14116 c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755); 14488 14117 c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755); 14489 @@ -133,6 +1 38,7 @@14118 @@ -133,6 +151,7 @@ 14490 14119 c(auto_qmail,"bin","qsmhook",auto_uido,auto_gidq,0755); 14491 14120 c(auto_qmail,"bin","qbiff",auto_uido,auto_gidq,0755); … … 14497 14126 diff -ruN ../netqmail-1.06-original/ip.h netqmail-1.06/ip.h 14498 14127 --- ../netqmail-1.06-original/ip.h 1998-06-15 12:53:16.000000000 +0200 14499 +++ netqmail-1.06/ip.h 201 6-11-22 21:03:57.115527999+010014128 +++ netqmail-1.06/ip.h 2019-02-27 20:57:13.392025048 +0100 14500 14129 @@ -2,6 +2,7 @@ 14501 14130 #define IP_H … … 14508 14137 diff -ruN ../netqmail-1.06-original/ipalloc.h netqmail-1.06/ipalloc.h 14509 14138 --- ../netqmail-1.06-original/ipalloc.h 1998-06-15 12:53:16.000000000 +0200 14510 +++ netqmail-1.06/ipalloc.h 201 6-11-22 21:03:57.115527999+010014139 +++ netqmail-1.06/ipalloc.h 2019-02-27 20:57:13.392025048 +0100 14511 14140 @@ -3,7 +3,15 @@ 14512 14141 … … 14527 14156 diff -ruN ../netqmail-1.06-original/ipme.c netqmail-1.06/ipme.c 14528 14157 --- ../netqmail-1.06-original/ipme.c 2007-11-30 21:22:54.000000000 +0100 14529 +++ netqmail-1.06/ipme.c 201 6-11-22 21:03:57.115527999+010014158 +++ netqmail-1.06/ipme.c 2019-02-27 20:57:13.392025048 +0100 14530 14159 @@ -14,23 +14,65 @@ 14531 14160 #include "ipalloc.h" … … 14742 14371 diff -ruN ../netqmail-1.06-original/ipme.h netqmail-1.06/ipme.h 14743 14372 --- ../netqmail-1.06-original/ipme.h 1998-06-15 12:53:16.000000000 +0200 14744 +++ netqmail-1.06/ipme.h 201 6-11-22 21:03:57.115527999+010014373 +++ netqmail-1.06/ipme.h 2019-02-27 20:57:13.392025048 +0100 14745 14374 @@ -4,7 +4,7 @@ 14746 14375 #include "ip.h" … … 14754 14383 diff -ruN ../netqmail-1.06-original/ipmeprint.c netqmail-1.06/ipmeprint.c 14755 14384 --- ../netqmail-1.06-original/ipmeprint.c 1998-06-15 12:53:16.000000000 +0200 14756 +++ netqmail-1.06/ipmeprint.c 201 6-11-22 21:03:57.115527999+010014385 +++ netqmail-1.06/ipmeprint.c 2019-02-27 20:57:13.392025048 +0100 14757 14386 @@ -3,12 +3,15 @@ 14758 14387 #include "ip.h" … … 14794 14423 diff -ruN ../netqmail-1.06-original/ipmetest.c netqmail-1.06/ipmetest.c 14795 14424 --- ../netqmail-1.06-original/ipmetest.c 1970-01-01 01:00:00.000000000 +0100 14796 +++ netqmail-1.06/ipmetest.c 201 6-11-22 21:03:57.115527999+010014425 +++ netqmail-1.06/ipmetest.c 2019-02-27 20:57:13.392025048 +0100 14797 14426 @@ -0,0 +1,38 @@ 14798 14427 +#include "subfd.h" … … 14836 14465 diff -ruN ../netqmail-1.06-original/macros.h netqmail-1.06/macros.h 14837 14466 --- ../netqmail-1.06-original/macros.h 1970-01-01 01:00:00.000000000 +0100 14838 +++ netqmail-1.06/macros.h 201 6-11-22 21:03:57.115527999+010014467 +++ netqmail-1.06/macros.h 2019-02-27 20:57:13.392025048 +0100 14839 14468 @@ -0,0 +1,25 @@ 14840 14469 +/* … … 14865 14494 diff -ruN ../netqmail-1.06-original/maildirflags.c netqmail-1.06/maildirflags.c 14866 14495 --- ../netqmail-1.06-original/maildirflags.c 1970-01-01 01:00:00.000000000 +0100 14867 +++ netqmail-1.06/maildirflags.c 201 6-11-22 21:03:57.116527965+010014496 +++ netqmail-1.06/maildirflags.c 2019-02-27 20:57:13.392025048 +0100 14868 14497 @@ -0,0 +1,23 @@ 14869 14498 +/* … … 14892 14521 diff -ruN ../netqmail-1.06-original/maildirgetquota.c netqmail-1.06/maildirgetquota.c 14893 14522 --- ../netqmail-1.06-original/maildirgetquota.c 1970-01-01 01:00:00.000000000 +0100 14894 +++ netqmail-1.06/maildirgetquota.c 201 6-11-22 21:03:57.116527965+010014523 +++ netqmail-1.06/maildirgetquota.c 2019-02-27 20:57:13.393025036 +0100 14895 14524 @@ -0,0 +1,50 @@ 14896 14525 +/* … … 14946 14575 diff -ruN ../netqmail-1.06-original/maildirgetquota.h netqmail-1.06/maildirgetquota.h 14947 14576 --- ../netqmail-1.06-original/maildirgetquota.h 1970-01-01 01:00:00.000000000 +0100 14948 +++ netqmail-1.06/maildirgetquota.h 201 6-11-22 21:03:57.116527965+010014577 +++ netqmail-1.06/maildirgetquota.h 2019-02-27 20:57:13.393025036 +0100 14949 14578 @@ -0,0 +1,30 @@ 14950 14579 +#ifndef maildirgetquota_h … … 14980 14609 diff -ruN ../netqmail-1.06-original/maildirmisc.h netqmail-1.06/maildirmisc.h 14981 14610 --- ../netqmail-1.06-original/maildirmisc.h 1970-01-01 01:00:00.000000000 +0100 14982 +++ netqmail-1.06/maildirmisc.h 201 6-11-22 21:03:57.116527965+010014611 +++ netqmail-1.06/maildirmisc.h 2019-02-27 20:57:13.393025036 +0100 14983 14612 @@ -0,0 +1,145 @@ 14984 14613 +#ifndef maildirmisc_h … … 15129 14758 diff -ruN ../netqmail-1.06-original/maildiropen.c netqmail-1.06/maildiropen.c 15130 14759 --- ../netqmail-1.06-original/maildiropen.c 1970-01-01 01:00:00.000000000 +0100 15131 +++ netqmail-1.06/maildiropen.c 201 6-11-22 21:03:57.116527965+010014760 +++ netqmail-1.06/maildiropen.c 2019-02-27 20:57:13.393025036 +0100 15132 14761 @@ -0,0 +1,133 @@ 15133 14762 +/* … … 15266 14895 diff -ruN ../netqmail-1.06-original/maildirparsequota.c netqmail-1.06/maildirparsequota.c 15267 14896 --- ../netqmail-1.06-original/maildirparsequota.c 1970-01-01 01:00:00.000000000 +0100 15268 +++ netqmail-1.06/maildirparsequota.c 201 6-11-22 21:03:57.116527965+010014897 +++ netqmail-1.06/maildirparsequota.c 2019-02-27 20:57:13.393025036 +0100 15269 14898 @@ -0,0 +1,44 @@ 15270 14899 +/* … … 15314 14943 diff -ruN ../netqmail-1.06-original/maildirquota.c netqmail-1.06/maildirquota.c 15315 14944 --- ../netqmail-1.06-original/maildirquota.c 1970-01-01 01:00:00.000000000 +0100 15316 +++ netqmail-1.06/maildirquota.c 201 6-11-22 21:03:57.116527965+010014945 +++ netqmail-1.06/maildirquota.c 2019-02-27 20:57:13.393025036 +0100 15317 14946 @@ -0,0 +1,685 @@ 15318 14947 +/* … … 16003 15632 diff -ruN ../netqmail-1.06-original/maildirquota.h netqmail-1.06/maildirquota.h 16004 15633 --- ../netqmail-1.06-original/maildirquota.h 1970-01-01 01:00:00.000000000 +0100 16005 +++ netqmail-1.06/maildirquota.h 201 6-11-22 21:03:57.117527932+010015634 +++ netqmail-1.06/maildirquota.h 2019-02-27 20:57:13.393025036 +0100 16006 15635 @@ -0,0 +1,45 @@ 16007 15636 +#ifndef maildirquota_h … … 16052 15681 diff -ruN ../netqmail-1.06-original/md5.h netqmail-1.06/md5.h 16053 15682 --- ../netqmail-1.06-original/md5.h 1970-01-01 01:00:00.000000000 +0100 16054 +++ netqmail-1.06/md5.h 201 6-11-22 21:03:57.117527932+010015683 +++ netqmail-1.06/md5.h 2019-02-27 20:57:13.394025025 +0100 16055 15684 @@ -0,0 +1,49 @@ 16056 15685 +/* MD5.H - header file for MD5C.C … … 16105 15734 diff -ruN ../netqmail-1.06-original/md5c.c netqmail-1.06/md5c.c 16106 15735 --- ../netqmail-1.06-original/md5c.c 1970-01-01 01:00:00.000000000 +0100 16107 +++ netqmail-1.06/md5c.c 201 6-11-22 21:03:57.117527932+010015736 +++ netqmail-1.06/md5c.c 2019-02-27 20:57:13.394025025 +0100 16108 15737 @@ -0,0 +1,334 @@ 16109 15738 +/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm … … 16443 16072 diff -ruN ../netqmail-1.06-original/mess822.h netqmail-1.06/mess822.h 16444 16073 --- ../netqmail-1.06-original/mess822.h 1970-01-01 01:00:00.000000000 +0100 16445 +++ netqmail-1.06/mess822.h 201 6-11-22 21:03:57.117527932+010016074 +++ netqmail-1.06/mess822.h 2019-02-27 20:57:13.394025025 +0100 16446 16075 @@ -0,0 +1,55 @@ 16447 16076 +/* … … 16502 16131 diff -ruN ../netqmail-1.06-original/mess822_ok.c netqmail-1.06/mess822_ok.c 16503 16132 --- ../netqmail-1.06-original/mess822_ok.c 1970-01-01 01:00:00.000000000 +0100 16504 +++ netqmail-1.06/mess822_ok.c 201 6-11-22 21:03:57.117527932+010016133 +++ netqmail-1.06/mess822_ok.c 2019-02-27 20:57:13.394025025 +0100 16505 16134 @@ -0,0 +1,55 @@ 16506 16135 +/* … … 16561 16190 diff -ruN ../netqmail-1.06-original/numlib.h netqmail-1.06/numlib.h 16562 16191 --- ../netqmail-1.06-original/numlib.h 1970-01-01 01:00:00.000000000 +0100 16563 +++ netqmail-1.06/numlib.h 201 6-11-22 21:03:57.117527932+010016192 +++ netqmail-1.06/numlib.h 2019-02-27 20:57:13.394025025 +0100 16564 16193 @@ -0,0 +1,45 @@ 16565 16194 +#ifndef numlib_h … … 16610 16239 diff -ruN ../netqmail-1.06-original/overmaildirquota.c netqmail-1.06/overmaildirquota.c 16611 16240 --- ../netqmail-1.06-original/overmaildirquota.c 1970-01-01 01:00:00.000000000 +0100 16612 +++ netqmail-1.06/overmaildirquota.c 201 6-11-22 21:03:57.117527932+010016241 +++ netqmail-1.06/overmaildirquota.c 2019-02-27 20:57:13.394025025 +0100 16613 16242 @@ -0,0 +1,41 @@ 16614 16243 +/* … … 16655 16284 diff -ruN ../netqmail-1.06-original/policy.c netqmail-1.06/policy.c 16656 16285 --- ../netqmail-1.06-original/policy.c 1970-01-01 01:00:00.000000000 +0100 16657 +++ netqmail-1.06/policy.c 201 6-11-22 21:03:57.118527899+010016286 +++ netqmail-1.06/policy.c 2019-02-27 20:57:13.395025014 +0100 16658 16287 @@ -0,0 +1,1210 @@ 16659 16288 +/* … … 17869 17498 diff -ruN ../netqmail-1.06-original/policy.h netqmail-1.06/policy.h 17870 17499 --- ../netqmail-1.06-original/policy.h 1970-01-01 01:00:00.000000000 +0100 17871 +++ netqmail-1.06/policy.h 201 6-11-22 21:03:57.118527899+010017500 +++ netqmail-1.06/policy.h 2019-02-27 20:57:13.395025014 +0100 17872 17501 @@ -0,0 +1,6 @@ 17873 17502 +#ifndef __POLICY_H_ … … 17879 17508 diff -ruN ../netqmail-1.06-original/qmail-clean.c netqmail-1.06/qmail-clean.c 17880 17509 --- ../netqmail-1.06-original/qmail-clean.c 1998-06-15 12:53:16.000000000 +0200 17881 +++ netqmail-1.06/qmail-clean.c 201 6-11-22 21:03:57.118527899+010017510 +++ netqmail-1.06/qmail-clean.c 2019-02-27 20:57:13.395025014 +0100 17882 17511 @@ -73,22 +73,26 @@ 17883 17512 if (line.len < 7) { respond("x"); continue; } … … 17914 17543 diff -ruN ../netqmail-1.06-original/qmail-control.9 netqmail-1.06/qmail-control.9 17915 17544 --- ../netqmail-1.06-original/qmail-control.9 1998-06-15 12:53:16.000000000 +0200 17916 +++ netqmail-1.06/qmail-control.9 201 6-11-28 17:36:57.350660496+010017545 +++ netqmail-1.06/qmail-control.9 2019-02-27 20:57:13.395025014 +0100 17917 17546 @@ -20,7 +20,11 @@ 17918 17547 … … 17991 17620 diff -ruN ../netqmail-1.06-original/qmail-dk.9 netqmail-1.06/qmail-dk.9 17992 17621 --- ../netqmail-1.06-original/qmail-dk.9 1970-01-01 01:00:00.000000000 +0100 17993 +++ netqmail-1.06/qmail-dk.9 201 8-04-03 14:46:51.371411632 +020017622 +++ netqmail-1.06/qmail-dk.9 2019-02-27 20:57:13.395025014 +0100 17994 17623 @@ -0,0 +1,164 @@ 17995 17624 +.TH qmail-dk 8 … … 18159 17788 diff -ruN ../netqmail-1.06-original/qmail-dk.c netqmail-1.06/qmail-dk.c 18160 17789 --- ../netqmail-1.06-original/qmail-dk.c 1970-01-01 01:00:00.000000000 +0100 18161 +++ netqmail-1.06/qmail-dk.c 201 8-04-03 14:46:51.372411636 +020017790 +++ netqmail-1.06/qmail-dk.c 2019-02-27 20:57:13.396025003 +0100 18162 17791 @@ -0,0 +1,866 @@ 18163 17792 +/* … … 19029 18658 diff -ruN ../netqmail-1.06-original/qmail-dkim.9 netqmail-1.06/qmail-dkim.9 19030 18659 --- ../netqmail-1.06-original/qmail-dkim.9 1970-01-01 01:00:00.000000000 +0100 19031 +++ netqmail-1.06/qmail-dkim.9 20 18-04-03 14:46:51.372411636+020019032 @@ -0,0 +1,32 1@@18660 +++ netqmail-1.06/qmail-dkim.9 2020-04-09 19:45:28.421566373 +0200 18661 @@ -0,0 +1,322 @@ 19033 18662 +.TH qmail-dkim 8 19034 18663 +.SH NAME … … 19061 18690 +variable, it is removed and replaced by the domain name in the From: header. 19062 18691 +If, after substituting the %, that file does not exist, the % character will be 19063 +removed. If theprivate key file does not exist and does not have a % character,18692 +removed. If a private key file does not exist and does not have a % character, 19064 18693 +the message will be rejected with error 35. The selector (s=) will be taken from 19065 18694 +the basename of the file. The private key should be created by … … 19107 18736 +.BR DKIMSIGNOPTIONS. 19108 18737 +.B qmail-dkim 19109 +uses the domain found in the Sender: header to set the domain tag. If not it uses the 19110 +From: header. You can override this by setting 19111 +.B DKIMDOMAIN 19112 +environment variable. 19113 +.B DKIMDOMAIN 18738 +uses the domain found in the Return-Path, Sender, From headers to set the domain tag. 18739 +If not it uses the \fBDKIMDOMAIN\fR environment variable. \fBDKIMDOMAIN\fR 19114 18740 +can be set to an email address or a domain (without the at sign). 19115 18741 + … … 19120 18746 +letter, where A is the first return status (DKIM_SUCCESS), B is the 19121 18747 +second (DKIM_FINISHED_BODY), etc. The letter should be uppercase if you 19122 +want a permanent error to be returned, and lowercase if 19123 +you want a temporary error to be returned (exit code 88). If you omit the letter, 19124 +\fBqmail-dkim\fR will not issue any error inspite of DKIM verification failure. It 19125 +will return success and the email will get delivered. The complete set of letters 19126 +with the corresponding return status is given below 18748 +want a permanent error to be returned, and lowercase if you want a temporary 18749 +error to be returned (exit code 88). If you omit the letter, qmail-dkim will 18750 +not issue any error inspite of DKIM verification failure. It will return 18751 +success and the email will get delivered. 18752 + 18753 +The complete set of letters with the corresponding return status is given below 19127 18754 + 19128 18755 + A - DKIM_SUCCESS - Function executed successfully … … 19191 18818 +.B DKIMVERIFY 19192 18819 +to an empty string. If you want to check all message's From header in signature set the 19193 +\fBUNSIGNED_FROM\fR environment variable to an empty string. 18820 +\fBUNSIGNED_FROM\fR environment variable to an empty string. If you want to check messages 18821 +without signed subject header, set \fBUNSIGNED_SUBJECT\fR environment variable. If you want 18822 +to honor body lengh tag (l=), set \fBHONOR_BODYLENGTHTAG\fR environment variable. 19194 18823 + 19195 18824 +qmail-dkim supports signing practice which can be additonall checked when a signature … … 19211 18840 +set the environment variable 19212 18841 +.BR DKIMPRACTICE="ST" . 19213 +If you want automatic behaviour, set DKIM ADSPERRORto an empty string. In this case ADSP/SSP will be used when return code18842 +If you want automatic behaviour, set DKIMPRACTICE to an empty string. In this case ADSP/SSP will be used when return code 19214 18843 +matches "FGHIJKLMNPQRSTUVWX". 19215 18844 +.B qmail-dkim … … 19266 18895 +containing a list of domains which you know are sure not to sign messages using DKIM. 19267 18896 +If a message comes from a domain listed in 19268 +.IR signaturedomains ,18897 +.IR nosignaturedomains , 19269 18898 +and does not have a DKIM-Signature header, 19270 18899 +.B qmail-dkim … … 19278 18907 +Typically, you would sign messages generated on-host by setting 19279 18908 +.B DKIMSIGN 19280 +in the environment before running an email program. DKIMSIGN will be carried19281 +through qmail 's sendmail emulation through18909 +in the environment before running an \fBqmail-smtpd\fR(8) or \fBsendmail(1)\fR / \fBqmail-inject\fR(8). DKIMSIGN will be carried 18910 +through qmail-smtpd or through qmail's sendmail emulation through 19282 18911 +.B qmail-inject 19283 18912 +to … … 19336 18965 +qmail-header(5), 19337 18966 +dknewkey(8), 18967 +dkim(8), 19338 18968 +dktest(8), 19339 18969 +qmail-inject(8), … … 19354 18984 diff -ruN ../netqmail-1.06-original/qmail-dkim.c netqmail-1.06/qmail-dkim.c 19355 18985 --- ../netqmail-1.06-original/qmail-dkim.c 1970-01-01 01:00:00.000000000 +0100 19356 +++ netqmail-1.06/qmail-dkim.c 201 8-04-03 14:46:51.373411639+020019357 @@ -0,0 +1,1 388@@18986 +++ netqmail-1.06/qmail-dkim.c 2019-06-19 09:48:44.632641078 +0200 18987 @@ -0,0 +1,1417 @@ 19358 18988 +/* 19359 18989 + * $Log: qmail-dkim.c,v $ 18990 + * Revision 1.53 2019-06-14 21:26:37+05:30 Cprogrammer 18991 + * added env variable HONOR_BODYLENGTHTAG to honor body length tag during verification 18992 + * 18993 + * Revision 1.52 2019-02-18 22:18:12+05:30 Cprogrammer 18994 + * allow DKIMVERIFY env variable in place of DKIMPRACTICE when SIGN_PRACTICE="local" 18995 + * 18996 + * Revision 1.51 2019-02-17 11:38:51+05:30 Cprogrammer 18997 + * set original DKIM error for SIGN_PRACTICE=local 18998 + * 18999 + * Revision 1.50 2019-02-15 21:25:04+05:30 Cprogrammer 19000 + * skip nosignaturedomains if domain is present in signaturedomains 19001 + * 19002 + * Revision 1.49 2018-08-08 23:58:01+05:30 Cprogrammer 19003 + * issue success if at lease one one good signature is found 19004 + * 19005 + * Revision 1.48 2017-09-05 12:37:16+05:30 Cprogrammer 19006 + * added missing DKIM_MFREE() 19007 + * 19360 19008 + * Revision 1.47 2016-06-03 09:57:59+05:30 Cprogrammer 19361 19009 + * moved qmail-multi to sbin … … 19819 19467 + 19820 19468 +#include <openssl/evp.h> 19821 +#define DKIM_MALLOC( s) OPENSSL_malloc(s)19469 +#define DKIM_MALLOC(n) OPENSSL_malloc(n) 19822 19470 +#define DKIM_MFREE(s) OPENSSL_free(s); s = NULL; 19823 19471 +char *dns_text(char *); … … 19958 19606 + DKIM_MFREE(results); 19959 19607 + return DKIM_ADSP_SCOPE; 19960 + } 19961 + else 19608 + } else 19962 19609 + if (!str_diff(results, "e=temp;")) { 19963 19610 + DKIM_MFREE(results); 19964 19611 + return DKIM_ADSP_TEMPFAIL; 19965 19612 + } 19966 + if (!(query = DKIM_MALLOC(str_len("_adsp._domainkey.") + str_len(domain) + 1))) 19613 + if (!(query = DKIM_MALLOC(str_len("_adsp._domainkey.") + str_len(domain) + 1))) { 19614 + DKIM_MFREE(results); 19967 19615 + die(51, 0); 19616 + } 19968 19617 + sprintf(query, "_adsp._domainkey.%s", domain); 19969 19618 + results = dns_text(query); … … 20290 19939 + 20291 19940 +int 20292 +checkPractice(int dkimRet )19941 +checkPractice(int dkimRet, int useADSP, int useSSP) 20293 19942 +{ 20294 19943 + char *ptr; 20295 19944 + 20296 + if (!(ptr = env_get("DKIMPRACTICE"))) 20297 + return (0); 20298 + else 19945 + if (!(ptr = env_get("DKIMPRACTICE"))) { 19946 + /*- if SIGN_PRACTICE="local" then you can use DKIMVERIFY env variable too */ 19947 + if (!useADSP && !useSSP) 19948 + dkimpractice = dkimverify; /*- DKIMVERIFY env variable */ 19949 + else 19950 + return (0); 19951 + } else 20299 19952 + dkimpractice = ptr; 20300 + if (!* ptr) {19953 + if (!*dkimpractice) { 20301 19954 + if (dkimRet < 0 || dkimRet == DKIM_3PS_SIGNATURE) 20302 19955 + return (1); … … 20525 20178 + useADSP = 1; 20526 20179 + accept3ps = 1; 20527 + } 20528 + else 20180 + } else 20529 20181 + if (!str_diffn("ssp", x, 3)) { 20530 20182 + useSSP = 1; … … 20548 20200 + vopts.nAllowUnsignedFromHeaders = 1; 20549 20201 + vopts.nSubjectRequired = env_get("UNSIGNED_SUBJECT") ? 0 : 1; 20202 + vopts.nHonorBodyLengthTag = env_get("HONOR_BODYLENGTHTAG") ? 0 : 1; 20550 20203 + DKIMVerifyInit(&ctxt, &vopts); /*- this is always successful */ 20551 20204 + } … … 20611 20264 + maybe_die_dkim(ret); 20612 20265 + else 20613 + for (ret = DKIM_SUCCESS,i = 0; i < nSigCount; i++) { 20614 + if (pDetails[i].nResult < 0) { 20615 + ret = pDetails[i].nResult; 20616 + break; /*- don't know if it is right to break */ 20266 + for (ret = DKIM_FAIL,i = 0; i < nSigCount; i++) { 20267 + if (pDetails[i].nResult >= 0) { 20268 + ret = 0; 20269 + } else { 20270 + if (ret == DKIM_FAIL) 20271 + ret = pDetails[i].nResult; 20617 20272 + } 20618 20273 + } … … 20621 20276 + } 20622 20277 + /*- what to do if DKIM Verification fails */ 20623 + if (checkPractice(ret )) {20278 + if (checkPractice(ret, useADSP, useSSP)) { 20624 20279 + char *domain; 20280 + int skip_nosignature_domain = 0; 20625 20281 + 20626 20282 + origRet = ret; … … 20635 20291 + len += ((token_len = str_len(p)) + 1); /*- next domain */ 20636 20292 + if (!case_diffb(p, token_len, domain)) { 20637 + ret = DKIM_FAIL; 20293 + ret = origRet; 20294 + skip_nosignature_domain = 1; 20638 20295 + useADSP = 0; 20639 20296 + useSSP = 0; … … 20642 20299 + p = sigdomains.s + len; 20643 20300 + } 20644 + if (!(p = env_get("NOSIGNATUREDOMAINS"))) { 20645 + if (control_readfile(&nsigdomains, "nosignaturedomains", 0) == -1) 20646 + die(55, 2); 20647 + } else 20648 + if (!stralloc_copys(&nsigdomains, p)) 20649 + die(51, 2); 20650 + for (len = 0, p = nsigdomains.s;len < nsigdomains.len;) { 20651 + len += ((token_len = str_len(p)) + 1); /*- next domain */ 20652 + if (*p == '*' || !case_diffb(p, token_len, domain)) { 20653 + ret = DKIM_NEUTRAL; 20654 + useADSP = 0; 20655 + useSSP = 0; 20656 + break; 20301 + if (!skip_nosignature_domain) { 20302 + if (!(p = env_get("NOSIGNATUREDOMAINS"))) { 20303 + if (control_readfile(&nsigdomains, "nosignaturedomains", 0) == -1) 20304 + die(55, 2); 20305 + } else 20306 + if (!stralloc_copys(&nsigdomains, p)) 20307 + die(51, 2); 20308 + for (len = 0, p = nsigdomains.s;len < nsigdomains.len;) { 20309 + len += ((token_len = str_len(p)) + 1); /*- next domain */ 20310 + if (*p == '*' || !case_diffb(p, token_len, domain)) { 20311 + ret = DKIM_NEUTRAL; 20312 + useADSP = 0; 20313 + useSSP = 0; 20314 + break; 20315 + } 20316 + p = nsigdomains.s + len; 20657 20317 + } 20658 + p = nsigdomains.s + len;20659 20318 + } 20660 20319 + } … … 20677 20336 + int bTestingPractices = 0; 20678 20337 + char *domain; 20679 + 20338 + 20680 20339 + if ((domain = DKIMVerifyGetDomain(&ctxt))) 20681 20340 + resDKIMSSP = checkSSP(domain, &bTestingPractices); … … 20740 20399 +getversion_qmail_dkim_c() 20741 20400 +{ 20742 + static char *x = "$Id: qmail-dkim.c,v 1. 37 2013-01-24 22:37:22+05:30 Cprogrammer Exp mbhangui $";20401 + static char *x = "$Id: qmail-dkim.c,v 1.49 2018-08-08 23:58:01+05:30 Cprogrammer Exp mbhangui $"; 20743 20402 + 20744 20403 + x++; … … 20746 20405 diff -ruN ../netqmail-1.06-original/qmail-inject.c netqmail-1.06/qmail-inject.c 20747 20406 --- ../netqmail-1.06-original/qmail-inject.c 1998-06-15 12:53:16.000000000 +0200 20748 +++ netqmail-1.06/qmail-inject.c 201 6-11-22 21:03:57.120527832 +010020407 +++ netqmail-1.06/qmail-inject.c 2019-02-27 20:57:13.397024992 +0100 20749 20408 @@ -22,6 +22,7 @@ 20750 20409 #include "auto_qmail.h" … … 20798 20457 diff -ruN ../netqmail-1.06-original/qmail-local.c netqmail-1.06/qmail-local.c 20799 20458 --- ../netqmail-1.06-original/qmail-local.c 2007-11-30 21:22:54.000000000 +0100 20800 +++ netqmail-1.06/qmail-local.c 201 8-01-01 12:10:21.981102868+010020459 +++ netqmail-1.06/qmail-local.c 2019-02-27 20:57:13.398024981 +0100 20801 20460 @@ -28,6 +28,7 @@ 20802 20461 #include "myctime.h" … … 20877 20536 diff -ruN ../netqmail-1.06-original/qmail-lspawn.c netqmail-1.06/qmail-lspawn.c 20878 20537 --- ../netqmail-1.06-original/qmail-lspawn.c 1998-06-15 12:53:16.000000000 +0200 20879 +++ netqmail-1.06/qmail-lspawn.c 201 6-11-22 21:03:57.120527832+010020538 +++ netqmail-1.06/qmail-lspawn.c 2019-02-27 20:57:13.398024981 +0100 20880 20539 @@ -1,4 +1,5 @@ 20881 20540 #include "fd.h" … … 20906 20565 diff -ruN ../netqmail-1.06-original/qmail-newmvrt.c netqmail-1.06/qmail-newmvrt.c 20907 20566 --- ../netqmail-1.06-original/qmail-newmvrt.c 1970-01-01 01:00:00.000000000 +0100 20908 +++ netqmail-1.06/qmail-newmvrt.c 201 6-11-22 21:04:20.041763530+010020567 +++ netqmail-1.06/qmail-newmvrt.c 2019-02-27 20:57:13.398024981 +0100 20909 20568 @@ -0,0 +1,70 @@ 20910 20569 +#include "strerr.h" … … 20980 20639 diff -ruN ../netqmail-1.06-original/qmail-pop3d.c netqmail-1.06/qmail-pop3d.c 20981 20640 --- ../netqmail-1.06-original/qmail-pop3d.c 2007-11-30 21:22:54.000000000 +0100 20982 +++ netqmail-1.06/qmail-pop3d.c 201 6-11-22 21:03:57.121527799+010020641 +++ netqmail-1.06/qmail-pop3d.c 2019-02-27 20:57:13.398024981 +0100 20983 20642 @@ -16,6 +16,11 @@ 20984 20643 #include "readwrite.h" … … 21140 20799 diff -ruN ../netqmail-1.06-original/qmail-pw2u.c netqmail-1.06/qmail-pw2u.c 21141 20800 --- ../netqmail-1.06-original/qmail-pw2u.c 1998-06-15 12:53:16.000000000 +0200 21142 +++ netqmail-1.06/qmail-pw2u.c 201 6-11-22 21:03:57.121527799+010020801 +++ netqmail-1.06/qmail-pw2u.c 2019-02-27 20:57:13.398024981 +0100 21143 20802 @@ -1,3 +1,4 @@ 21144 20803 +#include <unistd.h> … … 21148 20807 diff -ruN ../netqmail-1.06-original/qmail-qmqpc.c netqmail-1.06/qmail-qmqpc.c 21149 20808 --- ../netqmail-1.06-original/qmail-qmqpc.c 1998-06-15 12:53:16.000000000 +0200 21150 +++ netqmail-1.06/qmail-qmqpc.c 201 6-11-22 21:03:57.121527799+010020809 +++ netqmail-1.06/qmail-qmqpc.c 2019-02-27 20:57:13.398024981 +0100 21151 20810 @@ -102,6 +102,8 @@ 21152 20811 char *server; … … 21169 20828 diff -ruN ../netqmail-1.06-original/qmail-qmtpd.c netqmail-1.06/qmail-qmtpd.c 21170 20829 --- ../netqmail-1.06-original/qmail-qmtpd.c 1998-06-15 12:53:16.000000000 +0200 21171 +++ netqmail-1.06/qmail-qmtpd.c 201 6-11-22 21:03:57.121527799+010020830 +++ netqmail-1.06/qmail-qmtpd.c 2019-02-27 20:57:13.399024970 +0100 21172 20831 @@ -1,3 +1,5 @@ 21173 20832 +#include <unistd.h> … … 21178 20837 diff -ruN ../netqmail-1.06-original/qmail-qstat.sh netqmail-1.06/qmail-qstat.sh 21179 20838 --- ../netqmail-1.06-original/qmail-qstat.sh 1998-06-15 12:53:16.000000000 +0200 21180 +++ netqmail-1.06/qmail-qstat.sh 201 6-11-22 21:03:57.121527799+010020839 +++ netqmail-1.06/qmail-qstat.sh 2019-02-27 20:57:13.399024970 +0100 21181 20840 @@ -1,7 +1,7 @@ 21182 20841 cd QMAIL … … 21191 20850 diff -ruN ../netqmail-1.06-original/qmail-queue.8 netqmail-1.06/qmail-queue.8 21192 20851 --- ../netqmail-1.06-original/qmail-queue.8 2007-11-30 21:22:54.000000000 +0100 21193 +++ netqmail-1.06/qmail-queue.8 201 6-12-05 19:24:19.597680897+010020852 +++ netqmail-1.06/qmail-queue.8 2019-02-27 20:57:13.399024970 +0100 21194 20853 @@ -46,6 +46,13 @@ 21195 20854 will invoke the contents of … … 21208 20867 diff -ruN ../netqmail-1.06-original/qmail-queue.c netqmail-1.06/qmail-queue.c 21209 20868 --- ../netqmail-1.06-original/qmail-queue.c 1998-06-15 12:53:16.000000000 +0200 21210 +++ netqmail-1.06/qmail-queue.c 201 6-12-05 19:24:19.597680897+010020869 +++ netqmail-1.06/qmail-queue.c 2019-02-27 20:57:13.399024970 +0100 21211 20870 @@ -16,6 +16,8 @@ 21212 20871 #include "auto_uids.h" … … 21360 21019 diff -ruN ../netqmail-1.06-original/qmail-remote.8 netqmail-1.06/qmail-remote.8 21361 21020 --- ../netqmail-1.06-original/qmail-remote.8 1998-06-15 12:53:16.000000000 +0200 21362 +++ netqmail-1.06/qmail-remote.8 201 6-11-22 21:03:57.122527765+010021021 +++ netqmail-1.06/qmail-remote.8 2019-02-27 20:57:13.399024970 +0100 21363 21022 @@ -100,6 +100,73 @@ 21364 21023 After this letter comes a human-readable description of … … 21643 21302 diff -ruN ../netqmail-1.06-original/qmail-remote.c netqmail-1.06/qmail-remote.c 21644 21303 --- ../netqmail-1.06-original/qmail-remote.c 1998-06-15 12:53:16.000000000 +0200 21645 +++ netqmail-1.06/qmail-remote.c 20 17-08-28 17:51:47.068287985+020021304 +++ netqmail-1.06/qmail-remote.c 2020-04-16 11:23:31.333050380 +0200 21646 21305 @@ -28,6 +28,7 @@ 21647 21306 #include "timeoutconn.h" … … 21716 21375 if (flagcritical) out("Possible duplicate! "); 21717 21376 +#ifdef TLS 21718 + if (ssl_err_str) { out( ssl_err_str); out(" "); }21377 + if (ssl_err_str) { out((char *)ssl_err_str); out(" "); } 21719 21378 +#endif 21720 21379 out("(#4.4.2)\n"); … … 21813 21472 { 21814 21473 int i; 21815 @@ -179,6 +284,1 1@@21474 @@ -179,6 +284,16 @@ 21816 21475 char *prepend; 21817 21476 char *append; … … 21819 21478 +#ifdef TLS 21820 21479 + /* shouldn't talk to the client unless in an appropriate state */ 21480 +#if OPENSSL_VERSION_NUMBER >= 0x10100000L 21481 + OSSL_HANDSHAKE_STATE state = ssl ? SSL_get_state(ssl) : TLS_ST_BEFORE; 21482 + if (state & TLS_ST_OK || (!smtps && state & TLS_ST_BEFORE)) 21483 +#else 21821 21484 + int state = ssl ? ssl->state : SSL_ST_BEFORE; 21822 21485 + if (state & SSL_ST_OK || (!smtps && state & SSL_ST_BEFORE)) 21486 +#endif 21823 21487 +#endif 21824 21488 substdio_putsflush(&smtpto,"QUIT\r\n"); 21825 21489 /* waiting for remote side is just too ridiculous */ 21826 21490 out(prepend); 21827 @@ -186,6 + 296,30 @@21491 @@ -186,6 +301,30 @@ 21828 21492 out(append); 21829 21493 out(".\n"); … … 21856 21520 } 21857 21521 21858 @@ -201,6 +3 35,16 @@21522 @@ -201,6 +340,16 @@ 21859 21523 if (ch == '.') 21860 21524 substdio_put(&smtpto,".",1); … … 21873 21537 r = substdio_get(&ssin,&ch,1); 21874 21538 if (r == 0) perm_partialline(); 21875 @@ -214,30 +3 58,432@@21539 @@ -214,30 +363,436 @@ 21876 21540 substdio_flush(&smtpto); 21877 21541 } … … 21885 21549 +void tls_quit(const char *s1, const char *s2) 21886 21550 +{ 21887 + out( s1); if (s2) { out(": "); out(s2); } TLS_QUIT;21551 + out((char *)s1); if (s2) { out(": "); out((char *)s2); } TLS_QUIT; 21888 21552 +} 21889 21553 +# define tls_quit_error(s) tls_quit(s, ssl_error()) … … 21949 21613 + if (!len) { 21950 21614 + if (!servercert) return 0; 21951 + out("ZNo TLS achieved while "); out( servercert);21615 + out("ZNo TLS achieved while "); out((char *)servercert); 21952 21616 + out(" exists"); smtptext.len = 0; TLS_QUIT; 21953 21617 + } … … 21980 21644 + SSL_CTX_use_RSAPrivateKey_file(ctx, CLIENTCERT, SSL_FILETYPE_PEM); 21981 21645 +# undef CLIENTCERT 21646 + 21647 +#if OPENSSL_VERSION_NUMBER >= 0x10101000L 21648 + SSL_CTX_set_post_handshake_auth(ctx, 1); 21649 +#endif 21982 21650 + 21983 21651 + myssl = SSL_new(ctx); … … 22011 21679 + if (!servercert) return 0; 22012 21680 + out("ZSTARTTLS rejected while "); 22013 + out( servercert); out(" exists"); TLS_QUIT;21681 + out((char *)servercert); out(" exists"); TLS_QUIT; 22014 21682 + } 22015 21683 + smtptext.len = 0; … … 22063 21731 + i = X509_NAME_get_index_by_NID(subj, NID_commonName, -1); 22064 21732 + if (i >= 0) { 22065 + const ASN1_STRING *s = X509_NAME_ get_entry(subj, i)->value;21733 + const ASN1_STRING *s = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(subj, i)); 22066 21734 + if (s) { peer.len = s->length; peer.s = s->data; } 22067 21735 + } … … 22319 21987 for (i = 0;i < reciplist.len;++i) { 22320 21988 substdio_puts(&smtpto,"RCPT TO:<"); 22321 @@ -297,19 +843,14 @@ 21989 @@ -246,15 +801,23 @@ 21990 substdio_flush(&smtpto); 21991 code = smtpcode(); 21992 if (code >= 500) { 21993 - out("h"); outhost(); out(" does not like recipient.\n"); 21994 + /* added by Endersys R&D Team */ 21995 + out("h<From:"); outsafe(&sender); out(" To:"); outsafe(&reciplist.sa[i]); out("> "); outhost(); out(" does not like recipient.\n"); 21996 outsmtptext(); zero(); 21997 } 21998 else if (code >= 400) { 21999 - out("s"); outhost(); out(" does not like recipient.\n"); 22000 + /* added by Endersys R&D Team */ 22001 + out("s<From:"); outsafe(&sender); out(" To:"); outsafe(&reciplist.sa[i]); out("> "); outhost(); out(" does not like recipient.\n"); 22002 outsmtptext(); zero(); 22003 } 22004 else { 22005 - out("r"); zero(); 22006 + /* 22007 + * James Raftery <james@now.ie> 22008 + * Log _real_ envelope recipient, post canonicalisation. 22009 + * and modified by Endersys R&D Team 22010 + */ 22011 + 22012 + out("r<From:"); outsafe(&sender); out(" To:"); outsafe(&reciplist.sa[i]); out("> "); zero(); 22013 flagbother = 1; 22014 } 22015 } 22016 @@ -297,19 +860,14 @@ 22322 22017 if (!stralloc_cats(saout,"@")) temp_nomem(); 22323 22018 … … 22341 22036 if (control_readint(&timeout,"control/timeoutremote") == -1) temp_control(); 22342 22037 if (control_readint(&timeoutconnect,"control/timeoutconnect") == -1) 22343 @@ -324,48 +8 65,108 @@22038 @@ -324,48 +882,108 @@ 22344 22039 case 1: 22345 22040 if (!constmap_init(&maproutes,routes.s,routes.len,1)) temp_nomem(); break; … … 22469 22164 if (ipme_init() != 1) temp_oserr(); 22470 22165 22471 @@ -414,10 +10 15,13 @@22166 @@ -414,10 +1032,13 @@ 22472 22167 smtpfd = socket(AF_INET,SOCK_STREAM,0); 22473 22168 if (smtpfd == -1) temp_oserr(); … … 22487 22182 diff -ruN ../netqmail-1.06-original/qmail-rspawn.c netqmail-1.06/qmail-rspawn.c 22488 22183 --- ../netqmail-1.06-original/qmail-rspawn.c 1998-06-15 12:53:16.000000000 +0200 22489 +++ netqmail-1.06/qmail-rspawn.c 201 6-11-22 21:03:57.123527732+010022184 +++ netqmail-1.06/qmail-rspawn.c 2019-02-27 20:57:13.400024959 +0100 22490 22185 @@ -1,3 +1,4 @@ 22491 22186 +#include "env.h" … … 22516 22211 diff -ruN ../netqmail-1.06-original/qmail-send.9 netqmail-1.06/qmail-send.9 22517 22212 --- ../netqmail-1.06-original/qmail-send.9 1998-06-15 12:53:16.000000000 +0200 22518 +++ netqmail-1.06/qmail-send.9 2016-11-22 21:03:57.123527732 +0100 22519 @@ -51,7 +51,9 @@ 22213 +++ netqmail-1.06/qmail-send.9 2019-06-26 16:45:05.514152928 +0200 22214 @@ -16,6 +16,15 @@ 22215 .B qmail-send 22216 leaves it in the queue and tries the addresses again later. 22217 22218 +.B Supplemental queues 22219 +allow more than one queue for remote recipients. (CHANNELS - 2) supplemental queues total, because one queue is always 22220 +designated for local deliveries and a second queue is always available for remote deliveries that 22221 +don't match any of the domains listed in the supplemental queue control files. 22222 +This makes it possible to divide remote deliveries into distinct queues at different concurrency 22223 +levels and can be used as a throttling mechanism based on domain. 22224 +Supplemental queues are managed by the supplsX and concurrencysupplX control files, where X is an integer from 22225 +0 to (CHANNELS - 3). 22226 + 22227 .B qmail-send 22228 prints a readable record of its activities to descriptor 0. 22229 It writes commands to 22230 @@ -51,7 +60,13 @@ 22520 22231 .B qmail-send 22521 22232 receives a HUP signal, … … 22524 22235 +.IR concurrencylocal , 22525 22236 +.IR concurrencyremote , 22526 +.IR locals 22237 +.IR locals, 22238 +.IR supplsX, 22239 +.IR concurrencylocal, 22240 +.IR concurrencyremote, 22241 +.IR concurrencysupplX 22527 22242 and 22528 22243 .IR virtualdomains . 22529 22244 .TP 5 22530 @@ -115,6 +117,10 @@ 22245 @@ -93,6 +108,15 @@ 22246 is limited at compile time to 22247 SPAWN. 22248 .TP 5 22249 +.I concurrencysupplX 22250 +Maximum number of simultaneous delivery attempts via supplemental 22251 +channel X, where X is an integer starting at 0. 22252 +Default: 20. 22253 +If 0, deliveries via channel X will be put on hold. 22254 +.I concurrencysupplX 22255 +is limited at compile time to 22256 +SPAWN. 22257 +.TP 5 22258 .I doublebouncehost 22259 Double-bounce host. 22260 Default: 22261 @@ -115,6 +139,10 @@ 22531 22262 (If that bounces, 22532 22263 .B qmail-send … … 22539 22270 .I envnoathost 22540 22271 Presumed domain name for addresses without @ signs. 22272 @@ -147,6 +175,12 @@ 22273 is listed in 22274 .IR locals . 22275 .TP 5 22276 +.I supplsX 22277 +List of domain names that the current host 22278 +will deliver on supplemental channel X where X is an integer starting at 0, 22279 +one per line. 22280 +No default. 22281 +.TP 5 22282 .I percenthack 22283 List of domain names where the percent hack is applied. 22284 If 22285 @@ -164,7 +198,9 @@ 22286 handles 22287 .I percenthack 22288 before 22289 -.IR locals . 22290 +.I locals 22291 +and 22292 +.IR supplsX. 22293 .TP 5 22294 .I queuelifetime 22295 Number of seconds 22541 22296 diff -ruN ../netqmail-1.06-original/qmail-send.c netqmail-1.06/qmail-send.c 22542 22297 --- ../netqmail-1.06-original/qmail-send.c 1998-06-15 12:53:16.000000000 +0200 22543 +++ netqmail-1.06/qmail-send.c 201 6-11-22 21:03:57.124527699 +010022544 @@ -31,6 +31, 7@@22298 +++ netqmail-1.06/qmail-send.c 2019-06-26 16:42:40.004753618 +0200 22299 @@ -31,6 +31,11 @@ 22545 22300 #include "constmap.h" 22546 22301 #include "fmtqfn.h" 22547 22302 #include "readsubdir.h" 22548 22303 +#include "srs.h" 22304 + 22305 +#include "auto_spawn.h" 22306 + 22307 +#include "channels.h" 22549 22308 22550 22309 /* critical timing feature #1: if not triggered, do not busy-loop */ 22551 22310 /* critical timing feature #2: if triggered, respond within fixed time */ 22552 @@ -44,6 +4 5,8 @@22311 @@ -44,6 +49,8 @@ 22553 22312 22554 22313 int lifetime = 604800; … … 22559 22318 struct constmap mappercenthack; 22560 22319 stralloc locals = {0}; 22561 @@ -55, 6 +58,7@@22320 @@ -55,17 +62,20 @@ 22562 22321 stralloc bouncehost = {0}; 22563 22322 stralloc doublebounceto = {0}; … … 22567 22326 char strnum2[FMT_ULONG]; 22568 22327 char strnum3[FMT_ULONG]; 22569 @@ -82,9 +86,6 @@ 22328 22329 -#define CHANNELS 2 22330 -char *chanaddr[CHANNELS] = { "local/", "remote/" }; 22331 -char *chanstatusmsg[CHANNELS] = { " local ", " remote " }; 22332 -char *tochan[CHANNELS] = { " to local ", " to remote " }; 22333 -int chanfdout[CHANNELS] = { 1, 3 }; 22334 -int chanfdin[CHANNELS] = { 2, 4 }; 22335 -int chanskip[CHANNELS] = { 10, 20 }; 22336 +char *chanaddr[CHANNELS]; 22337 +char *chanstatusmsg[CHANNELS]; 22338 +char *tochan[CHANNELS]; 22339 +int chanfdout[CHANNELS]; 22340 +int chanfdin[CHANNELS]; 22341 +int chanskip[CHANNELS]; 22342 +struct constmap mapsuppl[SUPPL_CHANNELS]; 22343 +stralloc suppls[SUPPL_CHANNELS]; 22344 +stralloc newsuppls[SUPPL_CHANNELS]; 22345 22346 int flagexitasap = 0; void sigterm() { flagexitasap = 1; } 22347 int flagrunasap = 0; void sigalrm() { flagrunasap = 1; } 22348 @@ -82,12 +92,10 @@ 22570 22349 22571 22350 datetime_sec recent; … … 22577 22356 stralloc fn2 = {0}; 22578 22357 char fnmake_strnum[FMT_ULONG]; 22579 @@ -96,7 +97,7 @@ 22358 +stralloc fname = {0}; 22359 22360 void fnmake_init() 22361 { 22362 @@ -96,7 +104,7 @@ 22580 22363 } 22581 22364 … … 22586 22369 void fnmake_foop(id) unsigned long id; { fn.len = fmtqfn(fn.s,"foop/",id,0); } 22587 22370 void fnmake_split(id) unsigned long id; { fn.len = fmtqfn(fn.s,"",id,1); } 22588 @@ -262,6 +263,8 @@ 22371 @@ -117,6 +125,7 @@ 22372 { 22373 int i; 22374 int j; 22375 + int c; 22376 char *x; 22377 static stralloc addr = {0}; 22378 int at; 22379 @@ -159,6 +168,13 @@ 22380 22381 if (!stralloc_cat(&rwline,&addr)) return 0; 22382 if (!stralloc_0(&rwline)) return 0; 22383 + 22384 + for (c = 0;c < SUPPL_CHANNELS;++c) 22385 + { 22386 + if (constmap(&mapsuppl[c],addr.s + at + 1,addr.len - at - 1)) 22387 + return c + 3; 22388 + } 22389 + 22390 return 2; 22391 } 22392 22393 @@ -228,7 +244,8 @@ 22394 22395 substdio sstoqc; char sstoqcbuf[1024]; 22396 substdio ssfromqc; char ssfromqcbuf[1024]; 22397 -stralloc comm_buf[CHANNELS] = { {0}, {0} }; 22398 + 22399 +stralloc comm_buf[CHANNELS]; 22400 int comm_pos[CHANNELS]; 22401 22402 void comm_init() 22403 @@ -262,6 +279,8 @@ 22589 22404 while (!stralloc_copys(&comm_buf[c],"")) nomem(); 22590 22405 ch = delnum; … … 22595 22410 while (!stralloc_cats(&comm_buf[c],fn.s)) nomem(); 22596 22411 while (!stralloc_0(&comm_buf[c])) nomem(); 22597 @@ -683,15 +686,39 @@ 22412 @@ -382,7 +401,7 @@ 22413 /* this file is too long ----------------------------------- PRIORITY QUEUES */ 22414 22415 prioq pqdone = {0}; /* -todo +info; HOPEFULLY -local -remote */ 22416 -prioq pqchan[CHANNELS] = { {0}, {0} }; 22417 +prioq pqchan[CHANNELS]; 22418 /* pqchan 0: -todo +info +local ?remote */ 22419 /* pqchan 1: -todo +info ?local +remote */ 22420 prioq pqfail = {0}; /* stat() failure; has to be pqadded again */ 22421 @@ -683,15 +702,39 @@ 22598 22422 } 22599 22423 if (str_equal(sender.s,"#@[]")) … … 22638 22462 qmail_put(&qqt,newfield_date.s,newfield_date.len); 22639 22463 qmail_puts(&qqt,"From: "); 22640 @@ -740,9 +7 67,17 @@22464 @@ -740,9 +783,17 @@ 22641 22465 qmail_fail(&qqt); 22642 22466 else … … 22657 22481 if (r == -1) 22658 22482 qmail_fail(&qqt); 22659 @@ -906,41 +941,42 @@ 22483 @@ -780,8 +831,8 @@ 22484 ; 22485 22486 unsigned long masterdelid = 1; 22487 -unsigned int concurrency[CHANNELS] = { 10, 20 }; 22488 -unsigned int concurrencyused[CHANNELS] = { 0, 0 }; 22489 +unsigned int concurrency[CHANNELS]; 22490 +unsigned int concurrencyused[CHANNELS]; 22491 struct del *d[CHANNELS]; 22492 stralloc dline[CHANNELS]; 22493 char delbuf[2048]; 22494 @@ -808,9 +859,9 @@ 22495 for (c = 0;c < CHANNELS;++c) 22496 { 22497 flagspawnalive[c] = 1; 22498 - while (!(d[c] = (struct del *) alloc(concurrency[c] * sizeof(struct del)))) 22499 + while (!(d[c] = (struct del *) alloc(auto_spawn * sizeof(struct del)))) 22500 nomem(); 22501 - for (i = 0;i < concurrency[c];++i) 22502 + for (i = 0;i < auto_spawn;++i) 22503 { d[c][i].used = 0; d[c][i].recip.s = 0; } 22504 dline[c].s = 0; 22505 while (!stralloc_copys(&dline[c],"")) nomem(); 22506 @@ -906,41 +957,42 @@ 22660 22507 dline[c].len = REPORTMAX; 22661 22508 /* qmail-lspawn and qmail-rspawn are responsible for keeping it short */ … … 22665 22512 { 22666 22513 delnum = (unsigned int) (unsigned char) dline[c].s[0]; 22514 - if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used) 22667 22515 + delnum += (unsigned int) ((unsigned int) dline[c].s[1]) << 8; 22668 if ((delnum < 0) || (delnum >= concurrency[c]) || !d[c][delnum].used)22516 + if ((delnum < 0) || (delnum >= auto_spawn) || !d[c][delnum].used) 22669 22517 log1("warning: internal error: delivery report out of range\n"); 22670 22518 else … … 22708 22556 --jo[d[c][delnum].j].numtodo; 22709 22557 break; 22710 @@ -1215,8 +12 51,10 @@22558 @@ -1215,8 +1267,10 @@ 22711 22559 22712 22560 /* this file is too long ---------------------------------------------- TODO */ … … 22720 22568 char todobuf[SUBSTDIO_INSIZE]; 22721 22569 char todobufinfo[512]; 22722 @@ -1224,7 +12 62,7 @@22570 @@ -1224,7 +1278,7 @@ 22723 22571 22724 22572 void todo_init() … … 22729 22577 trigger_set(); 22730 22578 } 22731 @@ -1236,7 +12 74,7 @@22579 @@ -1236,7 +1290,7 @@ 22732 22580 { 22733 22581 if (flagexitasap) return; … … 22738 22586 } 22739 22587 22740 @@ -1253,8 +1 291,7 @@22588 @@ -1253,8 +1307,7 @@ 22741 22589 char ch; 22742 22590 int match; … … 22748 22596 unsigned long uid; 22749 22597 unsigned long pid; 22750 @@ -1265,32 +13 02,26 @@22598 @@ -1265,32 +1318,26 @@ 22751 22599 22752 22600 if (flagexitasap) return; … … 22790 22638 fnmake_todo(id); 22791 22639 22792 @@ -1438,10 +1469,148 @@ 22640 @@ -1363,12 +1410,9 @@ 22641 log1("\n"); 22642 break; 22643 case 'T': 22644 - switch(rewrite(todoline.s + 1)) 22645 - { 22646 - case 0: nomem(); goto fail; 22647 - case 2: c = 1; break; 22648 - default: c = 0; break; 22649 - } 22650 + c = rewrite(todoline.s + 1); 22651 + if (c == 0) { nomem(); goto fail; } 22652 + c--; 22653 if (fdchan[c] == -1) 22654 { 22655 fnmake_chanaddr(id,c); 22656 @@ -1438,17 +1482,175 @@ 22793 22657 if (fdchan[c] != -1) close(fdchan[c]); 22794 22658 } … … 22845 22709 + 22846 22710 + for (c = 0;c < CHANNELS;++c) flagchan[c] = 0; 22847 + switch(*s++) { 22848 + case 'L': 22849 + flagchan[0] = 1; 22850 + break; 22851 + case 'R': 22852 + flagchan[1] = 1; 22853 + break; 22854 + case 'B': 22855 + flagchan[0] = 1; 22856 + flagchan[1] = 1; 22857 + break; 22858 + case 'X': 22859 + break; 22860 + default: 22861 + log1("warning: qmail-send unable to understand qmail-todo\n"); 22862 + return; 22711 + 22712 + for (c = 0;c < CHANNELS;++c) 22713 + { 22714 + if (!*s) 22715 + { 22716 + log1("warning: qmail-send unable to understand qmail-todo\n"); 22717 + return; 22718 + } 22719 + 22720 + switch(*s++) { 22721 + case '0': 22722 + flagchan[c] = 0; 22723 + break; 22724 + case '1': 22725 + flagchan[c] = 1; 22726 + break; 22727 + default: 22728 + log1("warning: qmail-send unable to understand qmail-todo\n"); 22729 + return; 22730 + } 22863 22731 + } 22864 22732 + … … 22934 22802 /* this file is too long ---------------------------------------------- MAIN */ 22935 22803 22936 int getcontrols() { if (control_init() == -1) return 0; 22937 + if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0; 22804 -int getcontrols() { if (control_init() == -1) return 0; 22805 +int getcontrols() { 22806 + int c; 22807 + int ck = 0; 22808 + 22809 + if (control_init() == -1) return 0; 22810 + if (control_readint(&bouncemaxbytes,"control/bouncemaxbytes") == -1) return 0; 22938 22811 if (control_readint(&lifetime,"control/queuelifetime") == -1) return 0; 22939 22812 if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) return 0; 22940 22813 if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) return 0; 22941 @@ -1449,6 +1618,8 @@ 22814 + 22815 + for (c = 2,ck = 0;c < CHANNELS;++c) 22816 + { 22817 + strnum2[fmt_uint(strnum2,ck++)] = 0; 22818 + if (!stralloc_copys(&fname,"control/concurrencysuppl")) return 0; 22819 + if (!stralloc_cats(&fname,strnum2)) return 0; 22820 + if (!stralloc_0(&fname)) return 0; 22821 + if (control_readint(&concurrency[c],fname.s) == -1) return 0; 22822 + } 22823 + 22824 if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0; 22942 22825 if (control_rldef(&bouncefrom,"control/bouncefrom",0,"MAILER-DAEMON") != 1) return 0; 22943 22826 if (control_rldef(&bouncehost,"control/bouncehost",1,"bouncehost") != 1) return 0; … … 22948 22831 if (!stralloc_cats(&doublebounceto,"@")) return 0; 22949 22832 if (!stralloc_cat(&doublebounceto,&doublebouncehost)) return 0; 22950 @@ -1478,6 +1649,10 @@ 22833 @@ -1467,6 +1669,21 @@ 22834 case 0: if (!constmap_init(&mapvdoms,"",0,1)) return 0; break; 22835 case 1: if (!constmap_init(&mapvdoms,vdoms.s,vdoms.len,1)) return 0; break; 22836 } 22837 + 22838 + for (c = 0;c < SUPPL_CHANNELS;++c) 22839 + { 22840 + strnum2[fmt_uint(strnum2,c)] = 0; 22841 + if (!stralloc_copys(&fname,"control/suppls")) return 0; 22842 + if (!stralloc_cats(&fname,strnum2)) return 0; 22843 + if (!stralloc_0(&fname)) return 0; 22844 + switch (control_readfile(&suppls[c],fname.s,0)) 22845 + { 22846 + case -1: return 0; 22847 + case 0: if (!constmap_init(&mapsuppl[c],"",0,0)) return 0; break; 22848 + case 1: if (!constmap_init(&mapsuppl[c],suppls[c].s,suppls[c].len,0)) return 0; break; 22849 + } 22850 + } 22851 + 22852 return 1; } 22853 22854 stralloc newlocals = {0}; 22855 @@ -1475,9 +1692,33 @@ 22856 void regetcontrols() 22857 { 22858 int r; 22859 + int c; 22860 + int ck = 0; 22861 + 22862 + if (control_readint(&concurrency[0],"control/concurrencylocal") == -1) 22863 + { log1("alert: unable to reread control/concurrencylocal\n"); return; } 22864 + if (control_readint(&concurrency[1],"control/concurrencyremote") == -1) 22865 + { log1("alert: unable to reread control/concurrencyremote\n"); return; } 22866 + 22867 + for (c = 2,ck = 0;c < CHANNELS;++c) 22868 + { 22869 + strnum2[fmt_uint(strnum2,ck++)] = 0; 22870 + if (!stralloc_copys(&fname,"control/concurrencysuppl")) 22871 + { log3("alert: unable to reread ",fname.s,"\n"); return; } 22872 + if (!stralloc_cats(&fname,strnum2)) 22873 + { log3("alert: unable to reread ",fname.s,"\n"); return; } 22874 + if (!stralloc_0(&fname)) 22875 + { log3("alert: unable to reread ",fname.s,"\n"); return; } 22876 + if (control_readint(&concurrency[c],fname.s) == -1) 22877 + { log3("alert: unable to reread ",fname.s,"\n"); return; } 22878 + } 22951 22879 22952 22880 if (control_readfile(&newlocals,"control/locals",1) != 1) … … 22959 22887 if (r == -1) 22960 22888 { log1("alert: unable to reread control/virtualdomains\n"); return; } 22961 @@ -1504,6 +1679,9 @@ 22889 @@ -1495,6 +1736,28 @@ 22890 } 22891 else 22892 while (!constmap_init(&mapvdoms,"",0,1)) nomem(); 22893 + 22894 + for (c = 0;c < SUPPL_CHANNELS;++c) 22895 + { 22896 + strnum2[fmt_uint(strnum2,c)] = 0; 22897 + if (!stralloc_copys(&fname,"control/suppls")) nomem(); 22898 + if (!stralloc_cats(&fname,strnum2)) nomem(); 22899 + if (!stralloc_0(&fname)) nomem(); 22900 + r = control_readfile(&newsuppls[c],fname.s,0); 22901 + if (r == -1) 22902 + { log3("alert: qmail-todo: unable to reread ", fname.s, "\n"); return; } 22903 + 22904 + constmap_free(&mapsuppl[c]); 22905 + 22906 + if (r) 22907 + { 22908 + while (!stralloc_copy(&suppls[c],&newsuppls[c])) nomem(); 22909 + while (!constmap_init(&mapsuppl[c],suppls[c].s,suppls[c].len,0)) nomem(); 22910 + } 22911 + else 22912 + while (!constmap_init(&mapsuppl[c],"",0,0)) nomem(); 22913 + } 22914 + 22915 } 22916 22917 void reread() 22918 @@ -1504,6 +1767,9 @@ 22962 22919 log1("alert: unable to reread controls: unable to switch to home directory\n"); 22963 22920 return; … … 22969 22926 while (chdir("queue") == -1) 22970 22927 { 22971 @@ -1544,7 +1722,7 @@ 22928 @@ -1512,6 +1778,104 @@ 22929 } 22930 } 22931 22932 + 22933 +static int static_i = 0; 22934 +static int static_j = 0; 22935 +static void channels_init(void) 22936 +{ 22937 + chanaddr[0] = "local/"; 22938 + chanaddr[1] = "remote/"; 22939 + for (static_i=2,static_j=0;static_i<CHANNELS;static_i++,static_j++) 22940 + { 22941 + stralloc fnc = {0}; 22942 + strnum2[fmt_uint(strnum2,static_j)] = 0; 22943 + if (!stralloc_copys(&fname,QDIR_BASENAME)) nomem(); 22944 + if (!stralloc_cats(&fname,strnum2)) nomem(); 22945 + if (!stralloc_cats(&fname,"/")) nomem(); 22946 + if (!stralloc_0(&fname)) nomem(); 22947 + if (!stralloc_copy(&fnc,&fname)) nomem(); 22948 + chanaddr[static_i] = fnc.s; 22949 + } 22950 + 22951 + chanstatusmsg[0] = " local "; 22952 + chanstatusmsg[1] = " remote "; 22953 + for (static_i=2,static_j=0;static_i<CHANNELS;static_i++,static_j++) 22954 + { 22955 + stralloc fnc = {0}; 22956 + strnum2[fmt_uint(strnum2,static_j)] = 0; 22957 + if (!stralloc_copys(&fname," " QDIR_BASENAME)) nomem(); 22958 + if (!stralloc_cats(&fname,strnum2)) nomem(); 22959 + if (!stralloc_cats(&fname," ")) nomem(); 22960 + if (!stralloc_0(&fname)) nomem(); 22961 + if (!stralloc_copy(&fnc,&fname)) nomem(); 22962 + chanstatusmsg[static_i] = fnc.s; 22963 + } 22964 + 22965 + tochan[0] = " to local "; 22966 + tochan[1] = " to remote "; 22967 + static_j = 0; 22968 + for (static_i=2;static_i<CHANNELS;static_i++) 22969 + { 22970 + stralloc fnc = {0}; 22971 + strnum2[fmt_uint(strnum2,static_j++)] = 0; 22972 + if (!stralloc_copys(&fname," to " QDIR_BASENAME)) nomem(); 22973 + if (!stralloc_cats(&fname,strnum2)) nomem(); 22974 + if (!stralloc_cats(&fname," ")) nomem(); 22975 + if (!stralloc_0(&fname)) nomem(); 22976 + if (!stralloc_copy(&fnc,&fname)) nomem(); 22977 + tochan[static_i] = fnc.s; 22978 + } 22979 + 22980 + chanfdout[0] = 1; 22981 + chanfdout[1] = 3; 22982 + static_j = 1+CHANNEL_FD_OFFSET; 22983 + for (static_i=2;static_i<CHANNELS;static_i++) 22984 + { 22985 + chanfdout[static_i] = static_j; 22986 + static_j+=2; 22987 + } 22988 + 22989 + chanfdin[0] = 2; 22990 + chanfdin[1] = 4; 22991 + static_j = 2+CHANNEL_FD_OFFSET; 22992 + for (static_i=2;static_i<CHANNELS;static_i++) 22993 + { 22994 + chanfdin[static_i] = static_j; 22995 + static_j+=2; 22996 + } 22997 + 22998 + chanskip[0] = 10; 22999 + chanskip[1] = 20; 23000 + static_j = 20; 23001 + for (static_i=2;static_i<CHANNELS;static_i++) 23002 + { 23003 + chanskip[static_i] = static_j; 23004 + } 23005 + 23006 + for (static_i=0;static_i<CHANNELS;static_i++) 23007 + comm_buf[static_i].s = 0; 23008 + 23009 + for (static_i=0;static_i<CHANNELS;static_i++) 23010 + pqchan[static_i].p = 0; 23011 + 23012 + concurrency[0] = 10; 23013 + concurrency[1] = 20; 23014 + for (static_i=2;static_i<CHANNELS;static_i++) 23015 + { 23016 + concurrency[static_i] = 20; 23017 + } 23018 + 23019 + for (static_i=0;static_i<CHANNELS;static_i++) 23020 + concurrencyused[static_i] = 0; 23021 + 23022 + for (static_i=0;static_i<SUPPL_CHANNELS;static_i++) 23023 + suppls[static_i].s = 0; 23024 + 23025 + for (static_i=0;static_i<SUPPL_CHANNELS;static_i++) 23026 + newsuppls[static_i].s = 0; 23027 + 23028 +} 23029 + 23030 void main() 23031 { 23032 int fd; 23033 @@ -1522,6 +1886,8 @@ 23034 struct timeval tv; 23035 int c; 23036 23037 + channels_init(); 23038 + 23039 if (chdir(auto_qmail) == -1) 23040 { log1("alert: cannot start: unable to switch to home directory\n"); _exit(111); } 23041 if (!getcontrols()) 23042 @@ -1544,7 +1910,7 @@ 22972 23043 numjobs = 0; 22973 23044 for (c = 0;c < CHANNELS;++c) … … 22978 23049 int r; 22979 23050 do 22980 @@ -1552,7 +1 730,13 @@23051 @@ -1552,7 +1918,13 @@ 22981 23052 while ((r == -1) && (errno == error_intr)); 22982 23053 if (r < 1) … … 22992 23063 numjobs += concurrency[c]; 22993 23064 } 22994 @@ -1568,7 +1 752,11 @@23065 @@ -1568,7 +1940,11 @@ 22995 23066 todo_init(); 22996 23067 cleanup_init(); … … 23006 23077 diff -ruN ../netqmail-1.06-original/qmail-showctl.c netqmail-1.06/qmail-showctl.c 23007 23078 --- ../netqmail-1.06-original/qmail-showctl.c 1998-06-15 12:53:16.000000000 +0200 23008 +++ netqmail-1.06/qmail-showctl.c 201 6-11-28 19:39:45.341600337+010023079 +++ netqmail-1.06/qmail-showctl.c 2019-02-27 20:57:13.401024948 +0100 23009 23080 @@ -15,6 +15,7 @@ 23010 23081 #include "auto_patrn.h" … … 23126 23197 diff -ruN ../netqmail-1.06-original/qmail-smtpd.8 netqmail-1.06/qmail-smtpd.8 23127 23198 --- ../netqmail-1.06-original/qmail-smtpd.8 1998-06-15 12:53:16.000000000 +0200 23128 +++ netqmail-1.06/qmail-smtpd.8 201 6-12-18 19:08:22.496459855+010023199 +++ netqmail-1.06/qmail-smtpd.8 2019-02-27 20:57:13.402024937 +0100 23129 23200 @@ -14,6 +14,15 @@ 23130 23201 see … … 23450 23521 diff -ruN ../netqmail-1.06-original/qmail-smtpd.c netqmail-1.06/qmail-smtpd.c 23451 23522 --- ../netqmail-1.06-original/qmail-smtpd.c 2007-11-30 21:22:54.000000000 +0100 23452 +++ netqmail-1.06/qmail-smtpd.c 20 17-11-07 17:45:04.599607652 +010023523 +++ netqmail-1.06/qmail-smtpd.c 2020-04-25 15:15:28.957053097 +0200 23453 23524 @@ -12,6 +12,9 @@ 23454 23525 #include "ip.h" … … 23461 23532 #include "scan.h" 23462 23533 #include "byte.h" 23463 @@ -23,44 +26,1 78@@23534 @@ -23,44 +26,180 @@ 23464 23535 #include "timeoutread.h" 23465 23536 #include "timeoutwrite.h" … … 23467 23538 +#include "dns.h" 23468 23539 +#include "wait.h" 23469 +/* start chkuser code */ 23470 +#include "chkuser.h" 23471 +/* end chkuser code */ 23472 +#include "spf.h" 23473 +/* rbl: start */ 23474 +#include "strsalloc.h" 23475 +/* rbl: end */ 23476 + 23477 +#define AUTHSLEEP 5 23478 23479 #define MAXHOPS 100 23480 + 23481 +#define BMCHECK_BMF 0 23482 +#define BMCHECK_BMFNR 1 23483 +#define BMCHECK_BMT 2 23484 +#define BMCHECK_BMTNR 3 23485 +#define BMCHECK_BHELO 4 23486 +#define BMCHECK_BHELONR 5 23487 + 23488 +static char strnum[FMT_ULONG]; 23489 unsigned int databytes = 0; 23490 +unsigned int greetdelay = 0; 23491 +unsigned int drop_pre_greet = 0; 23492 int timeout = 1200; 23493 +int maxrcpt = -1; 23494 +unsigned int spfbehavior = 0; 23495 + 23496 +/* rejectrelaytest: start */ 23497 +unsigned int rejectrelaytest = 0; 23498 +/* rejecrelayttest: end */ 23499 +/* rejectnullsenders: start */ 23500 +unsigned int rejnsmf = 0; 23501 +/* rejectnullsenders: end */ 23502 + 23503 +const char *protocol = "SMTP"; 23504 + 23505 +/* spf ipv6 fix */ 23506 +char *remoteip4; 23507 +/* end spf ipv6 fix */ 23508 + 23540 + 23541 +/* chkuser.h will check if TLS_H is defined, so this has to come before chkuser.h */ 23509 23542 +#ifdef TLS 23510 23543 +#include <sys/stat.h> … … 23517 23550 +int forcetls = 1; 23518 23551 +#endif 23552 + 23553 +/* start chkuser code */ 23554 +#include "chkuser.h" 23555 +/* end chkuser code */ 23556 +#include "spf.h" 23557 +/* rbl: start */ 23558 +#include "strsalloc.h" 23559 +/* rbl: end */ 23560 + 23561 +#define AUTHSLEEP 5 23562 23563 #define MAXHOPS 100 23564 + 23565 +#define BMCHECK_BMF 0 23566 +#define BMCHECK_BMFNR 1 23567 +#define BMCHECK_BMT 2 23568 +#define BMCHECK_BMTNR 3 23569 +#define BMCHECK_BHELO 4 23570 +#define BMCHECK_BHELONR 5 23571 + 23572 +static char strnum[FMT_ULONG]; 23573 unsigned int databytes = 0; 23574 +unsigned int greetdelay = 0; 23575 +unsigned int drop_pre_greet = 0; 23576 int timeout = 1200; 23577 +int maxrcpt = -1; 23578 +unsigned int spfbehavior = 0; 23579 + 23580 +/* rejectrelaytest: start */ 23581 +unsigned int rejectrelaytest = 0; 23582 +/* rejecrelayttest: end */ 23583 +/* rejectnullsenders: start */ 23584 +unsigned int rejnsmf = 0; 23585 +/* rejectnullsenders: end */ 23586 + 23587 +static const char *protocol = "SMTP"; 23588 + 23589 +/* spf ipv6 fix */ 23590 +char *remoteip4; 23591 +/* end spf ipv6 fix */ 23519 23592 23520 23593 int safewrite(fd,buf,len) int fd; char *buf; int len; … … 23555 23628 -void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); } 23556 23629 -void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); } 23557 +void die_read( ) { logit("read failed"); _exit(1); }23630 +void die_read(char *reason) { logit2("read failed", reason); flush(); _exit(1); } 23558 23631 +void die_alarm() { qlogenvelope("rejected","alarmtimeout","","451"); logit("timeout"); out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); } 23559 23632 +void die_nomem() { qlogenvelope("rejected","outofmemory","","421"); out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); } … … 23649 23722 void smtp_greet(code) char *code; 23650 23723 { 23651 @@ -76,11 +21 3,33 @@23724 @@ -76,11 +215,33 @@ 23652 23725 smtp_greet("221 "); out("\r\n"); flush(); _exit(0); 23653 23726 } … … 23683 23756 stralloc helohost = {0}; 23684 23757 char *fakehelo; /* pointer into helohost, or 0 */ 23685 @@ -91,11 +25 0,101 @@23758 @@ -91,11 +252,101 @@ 23686 23759 fakehelo = case_diffs(remotehost,helohost.s) ? helohost.s : 0; 23687 23760 } … … 23786 23859 void setup() 23787 23860 { 23788 @@ -109,21 +3 58,110 @@23861 @@ -109,21 +360,110 @@ 23789 23862 if (liphostok == -1) die_control(); 23790 23863 if (control_readint(&timeout,"control/timeoutsmtpd") == -1) die_control(); … … 23898 23971 if (!local) local = env_get("TCPLOCALIP"); 23899 23972 if (!local) local = "unknown"; 23900 @@ -131,10 +4 69,67 @@23973 @@ -131,10 +471,67 @@ 23901 23974 if (!remotehost) remotehost = "unknown"; 23902 23975 remoteinfo = env_get("TCPREMOTEINFO"); … … 23967 24040 23968 24041 int addrparse(arg) 23969 @@ -155,6 +55 0,7 @@24042 @@ -155,6 +552,7 @@ 23970 24043 terminator = ' '; 23971 24044 arg += str_chr(arg,':'); … … 23975 24048 } 23976 24049 23977 @@ -197,6 +59 3,8 @@24050 @@ -197,6 +595,8 @@ 23978 24051 return 1; 23979 24052 } … … 23984 24057 { 23985 24058 int j; 23986 @@ -207, 68 +605,1102@@24059 @@ -207,76 +607,1108 @@ 23987 24060 if (constmap(&mapbmf,addr.s + j,addr.len - j - 1)) return 1; 23988 24061 return 0; … … 24459 24532 +} 24460 24533 + 24461 +void logit(message) const char* message; 24534 +/* logging patch */ 24535 + 24536 +void safeloglen(const char* string, const int len) { 24537 + if (string && len) { 24538 + if (!stralloc_catb(&log_buf, string, len-1)) die_nomem(); 24539 + } else { 24540 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24541 + } 24542 +} 24543 + 24544 +void safelog(const char* string) { 24545 + if (string) { 24546 + if (!stralloc_cats(&log_buf, string)) die_nomem(); 24547 + } else { 24548 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24549 + } 24550 +} 24551 + 24552 +void logit(const char* message) { 24553 + logit2(message, (const char*)0); 24554 +} 24555 + 24556 +void logit2(const char* message, const char* reason) 24462 24557 +{ 24463 24558 + if (!stralloc_copys(&log_buf, "qmail-smtpd: ")) die_nomem(); 24464 + if (!stralloc_cats(&log_buf, message)) die_nomem(); 24559 + safelog(message); 24560 + if (reason) { 24561 + if (!stralloc_cats(&log_buf, " (")) die_nomem(); 24562 + if (!stralloc_cats(&log_buf, reason)) die_nomem(); 24563 + if (!stralloc_cats(&log_buf, ")")) die_nomem(); 24564 + } 24465 24565 + if (!stralloc_catb(&log_buf, ": ", 2)) die_nomem(); 24466 + if (mailfrom.s) { 24467 + if (!stralloc_catb(&log_buf, mailfrom.s, mailfrom.len-1)) die_nomem(); 24468 + } else 24469 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24566 + safeloglen(mailfrom.s, mailfrom.len); 24470 24567 + if (!stralloc_catb(&log_buf, " from ", 6)) die_nomem(); 24471 + if (!stralloc_cats(&log_buf, remoteip)) die_nomem();24568 + safelog(remoteip); 24472 24569 + if (!stralloc_catb(&log_buf, " to ", 4)) die_nomem(); 24473 + if (addr.s) { 24474 + if (!stralloc_catb(&log_buf, addr.s, addr.len-1)) die_nomem(); 24475 + } else 24476 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24570 + safeloglen(addr.s, addr.len); 24477 24571 + if (!stralloc_catb(&log_buf, " helo ", 6)) die_nomem(); 24478 + if (helohost.s) { 24479 + if (!stralloc_catb(&log_buf, helohost.s, helohost.len-1)) die_nomem(); 24480 + } else 24481 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24572 + safeloglen(helohost.s, helohost.len); 24482 24573 + if (!stralloc_catb(&log_buf, "\n", 1)) die_nomem(); 24483 24574 + substdio_putflush(&sserr, log_buf); 24484 24575 +} 24485 24576 + 24486 +void logit2(message, reason) 24487 +const char* message; 24488 +const char* reason; 24489 +{ 24490 + if (!stralloc_copys(&log_buf,"qmail-smtpd: ")) die_nomem(); 24491 + if (!stralloc_cats(&log_buf, message)) die_nomem(); 24492 + if (!stralloc_cats(&log_buf, " (")) die_nomem(); 24493 + if (!stralloc_cats(&log_buf, reason)) die_nomem(); 24494 + if (!stralloc_cats(&log_buf, "): ")) die_nomem(); 24495 + if (mailfrom.s) { 24496 + if (!stralloc_catb(&log_buf, mailfrom.s, mailfrom.len-1)) die_nomem(); 24497 + } else 24498 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24499 + if (!stralloc_cats(&log_buf," from ")) die_nomem(); 24500 + if (!stralloc_cats(&log_buf, remoteip)) die_nomem(); 24501 + if (!stralloc_cats(&log_buf, " to ")) die_nomem(); 24502 + if (addr.s) { 24503 + if (!stralloc_catb(&log_buf, addr.s, addr.len-1)) die_nomem(); 24504 + } else 24505 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24506 + if (!stralloc_cats(&log_buf, " helo ")) die_nomem(); 24507 + if (helohost.s) { 24508 + if (!stralloc_catb(&log_buf, helohost.s, helohost.len-1)) die_nomem(); 24509 + } else 24510 + if (!stralloc_catb(&log_buf, "(null)", 6)) die_nomem(); 24511 + if (!stralloc_catb(&log_buf, "\n", 1)) die_nomem(); 24512 + substdio_putflush(&sserr, log_buf); 24513 +} 24577 +/* end logging patch */ 24514 24578 + 24515 24579 +int mailfrom_size(arg) char *arg; … … 24543 24607 + if (!remoteinfo) { 24544 24608 + remoteinfo = fuser.s; 24545 + if (!env_unset("TCPREMOTEINFO")) die_read( );24609 + if (!env_unset("TCPREMOTEINFO")) die_read("TCPREMOTEINFO"); 24546 24610 + if (!env_put2("TCPREMOTEINFO",remoteinfo)) die_nomem(); 24547 24611 + } … … 24577 24641 + if (bhelook) flagbarfbhelo = bmcheck(BMCHECK_BHELO); 24578 24642 + if ((!flagbarfbhelo) && (bhelonrok) && (!relayclient)) flagbarfbhelo = bmcheck(BMCHECK_BHELONR); 24579 +}24643 } 24580 24644 +char size_buf[FMT_ULONG]; 24581 24645 +void smtp_size() … … 24583 24647 + size_buf[fmt_ulong(size_buf,(unsigned long) databytes)] = 0; 24584 24648 + out("250 SIZE "); out(size_buf); out("\r\n"); 24585 24649 +} 24586 24650 + 24587 24651 +/* ESMTP extensions are published here */ … … 24620 24684 + seenmail = 0; /* seenauth = 0; RFC 5321: retain authentication */ 24621 24685 + mailfrom.len = 0; rcptto.len = 0; 24686 + /* prevents the maxrcpto error if control/maxrcpt limit has been exceeded in the same email, but not in multiple messages sequentially */ 24687 + rcptcount = 0; 24688 + envelopepos = 1; 24689 + /* end rcptcount adjustment */ 24622 24690 out("250 flushed\r\n"); 24623 24691 } … … 24669 24737 +/* qregex: start */ 24670 24738 + /* 24671 +flagbarf = bmfcheck();24739 flagbarf = bmfcheck(); 24672 24740 + */ 24673 24741 + flagbarfbmf = 0; /* bmcheck is skipped for empty envelope senders */ … … 24683 24751 +/* qregex: start */ 24684 24752 + /* 24685 24753 + flagbarf = bmfcheck(); 24686 24754 + */ 24687 24755 + flagbarfbmf = 0; /* bmcheck is skipped for empty envelope senders */ … … 25091 25159 r = timeoutread(timeout,fd,buf,len); 25092 25160 if (r == -1) if (errno == error_timeout) die_alarm(); 25093 if (r <= 0) die_read(); 25094 @@ -277,6 +1709,9 @@ 25161 - if (r <= 0) die_read(); 25162 + if (r <= 0) die_read("hang up before quit cmd"); 25163 return r; 25164 } 25095 25165 25096 25166 char ssinbuf[1024]; … … 25102 25172 struct qmail qqt; 25103 25173 unsigned int bytestooverflow = 0; 25104 @@ -300,7 +173 5,7 @@25174 @@ -300,7 +1732,7 @@ 25105 25175 int flagmaybex; /* 1 if this line might match RECEIVED, if fih */ 25106 25176 int flagmaybey; /* 1 if this line might match \r\n, if fih */ … … 25111 25181 *hops = 0; 25112 25182 flaginheader = 1; 25113 @@ -322,17 +175 7,16 @@25183 @@ -322,17 +1754,16 @@ 25114 25184 } 25115 25185 switch(state) { … … 25132 25202 state = 0; 25133 25203 break; 25134 @@ -351,10 +178 5,73 @@25204 @@ -351,10 +1782,73 @@ 25135 25205 } 25136 25206 } … … 25206 25276 out("250 ok "); 25207 25277 accept_buf[fmt_ulong(accept_buf,(unsigned long) when)] = 0; 25208 @@ -363,22 +18 60,32 @@25278 @@ -363,22 +1857,32 @@ 25209 25279 accept_buf[fmt_ulong(accept_buf,qp)] = 0; 25210 25280 out(accept_buf); … … 25241 25311 hops = (hops >= MAXHOPS); 25242 25312 if (hops) qmail_fail(&qqt); 25243 @@ -386,3 4 +1893,631@@25313 @@ -386,36 +1890,662 @@ 25244 25314 qmail_put(&qqt,rcptto.s,rcptto.len); 25245 25315 … … 25282 25352 + if (!stralloc_readyplus(&authin,1)) die_nomem(); /* XXX */ 25283 25353 + i = substdio_get(&ssin,authin.s + authin.len,1); 25284 + if (i != 1) die_read( );25354 + if (i != 1) die_read("authgetl"); 25285 25355 + if (authin.s[authin.len] == '\n') break; 25286 25356 + ++authin.len; … … 25461 25531 + relayclient = ""; 25462 25532 + remoteinfo = user.s; 25463 + if (!env_unset("TCPREMOTEINFO")) die_read( );25533 + if (!env_unset("TCPREMOTEINFO")) die_read("TCPREMOTEINFO"); 25464 25534 + if (!env_put2("TCPREMOTEINFO",remoteinfo)) die_nomem(); 25465 25535 + if (!env_put2("RELAYCLIENT",relayclient)) die_nomem(); 25466 25536 + 25467 + if (!env_unset("SMTPAUTHMETHOD")) die_read( );25537 + if (!env_unset("SMTPAUTHMETHOD")) die_read("SMTPAUTHMETHOD"); 25468 25538 + if (!env_put2("SMTPAUTHMETHOD", authcmds[i].text)) die_nomem(); 25469 + if (!env_unset("SMTPAUTHUSER")) die_read( );25539 + if (!env_unset("SMTPAUTHUSER")) die_read("SMTPAUTHUSER"); 25470 25540 + if (!env_put2("SMTPAUTHUSER",user.s)) die_nomem(); 25471 + if (!env_unset("SMTP_AUTH_USER")) die_read( );25541 + if (!env_unset("SMTP_AUTH_USER")) die_read("SMTP_AUTH_USER"); 25472 25542 + if (!env_put2("SMTP_AUTH_USER",user.s)) die_nomem(); 25473 25543 + … … 25495 25565 +RSA *tmp_rsa_cb(SSL *ssl, int export, int keylen) 25496 25566 +{ 25567 + RSA *rsa; 25568 + 25497 25569 + if (!export) keylen = 2048; 25498 25570 + if (keylen == 2048) { 25499 25571 + FILE *in = fopen("control/rsa2048.pem", "r"); 25500 25572 + if (in) { 25501 + RSA *rsa = PEM_read_RSAPrivateKey(in, NULL, NULL, NULL);25573 + rsa = PEM_read_RSAPrivateKey(in, NULL, NULL, NULL); 25502 25574 + fclose(in); 25503 25575 + if (rsa) return rsa; 25504 25576 + } 25505 25577 + } 25578 +#if OPENSSL_VERSION_NUMBER >= 0x10100000L 25579 + BIGNUM *e; /*exponent */ 25580 + e = BN_new(); 25581 + BN_set_word(e, RSA_F4); 25582 + if (RSA_generate_key_ex(rsa, keylen, e, NULL) == 1) 25583 + return rsa; 25584 + return NULL; 25585 +#else 25506 25586 + return RSA_generate_key(keylen, RSA_F4, NULL, NULL); 25587 +#endif 25507 25588 +} 25508 25589 + 25509 25590 +DH *tmp_dh_cb(SSL *ssl, int export, int keylen) 25510 25591 +{ 25592 + DH *dh; 25593 + 25511 25594 + if (!export) keylen = 2048; 25512 25595 + if (keylen == 2048) { 25513 25596 + FILE *in = fopen("control/dh2048.pem", "r"); 25514 25597 + if (in) { 25515 + DH *dh = PEM_read_DHparams(in, NULL, NULL, NULL);25598 + dh = PEM_read_DHparams(in, NULL, NULL, NULL); 25516 25599 + fclose(in); 25517 25600 + if (dh) return dh; … … 25526 25609 + } 25527 25610 + } 25611 +#if OPENSSL_VERSION_NUMBER >= 0x10100000L 25612 + if((dh = DH_new()) && (DH_generate_parameters_ex(dh, keylen, DH_GENERATOR_2, NULL) == 1)) 25613 + return dh; 25614 + return NULL; 25615 +#else 25528 25616 + return DH_generate_parameters(keylen, DH_GENERATOR_2, NULL, NULL); 25529 +} 25617 +#endif 25618 +} 25530 25619 + 25531 25620 +/* don't want to fail handshake if cert isn't verifiable */ 25532 +int verify_cb(int preverify_ok, X509_STORE_CTX * ctx) { return 1; }25621 +int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx) { return 1; } 25533 25622 + 25534 25623 +void tls_nogateway() … … 25545 25634 + out(" (#4.3.0)\r\n"); flush(); 25546 25635 +} 25547 +void tls_err(const char *s) { tls_out(s, ssl_error()); if (smtps) die_read( ); }25636 +void tls_err(const char *s) { tls_out(s, ssl_error()); if (smtps) die_read("tls_err"); } 25548 25637 + 25549 25638 +# define CLIENTCA "control/clientca.pem" … … 25572 25661 + if (sk) { 25573 25662 + SSL_set_client_CA_list(ssl, sk); 25574 + SSL_set_verify(ssl, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, NULL);25663 + SSL_set_verify(ssl, SSL_VERIFY_PEER, verify_cb); 25575 25664 + break; 25576 25665 + } … … 25583 25672 + if (ssl_timeoutrehandshake(timeout, ssl_rfd, ssl_wfd, ssl) <= 0) { 25584 25673 + const char *err = ssl_error_str(); 25585 + tls_out("rehandshake failed", err); die_read( );25674 + tls_out("rehandshake failed", err); die_read("rehandshake failed"); 25586 25675 + } 25587 25676 + … … 25600 25689 + n = X509_NAME_get_index_by_NID(subj, NID_pkcs9_emailAddress, -1); 25601 25690 + if (n >= 0) { 25602 + const ASN1_STRING *s = X509_NAME_ get_entry(subj, n)->value;25691 + const ASN1_STRING *s = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(subj, n)); 25603 25692 + if (s) { email.len = s->length; email.s = s->data; } 25604 25693 + } … … 25640 25729 + X509_STORE *store; 25641 25730 + X509_LOOKUP *lookup; 25731 + int session_id_context = 1; /* anything will do */ 25642 25732 + 25643 25733 + SSL_library_init(); … … 25650 25740 + SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); 25651 25741 + 25742 + /* renegotiation should include certificate request */ 25743 + SSL_CTX_set_options(ctx, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); 25744 + 25745 + /* never bother the application with retries if the transport is blocking */ 25746 + SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); 25747 + 25748 + /* relevant in renegotiation */ 25749 + SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); 25750 + if (!SSL_CTX_set_session_id_context(ctx, (void *)&session_id_context, 25751 + sizeof(session_id_context))) 25752 + { SSL_CTX_free(ctx); tls_err("failed to set session_id_context"); return; } 25753 + 25652 25754 + if (!SSL_CTX_use_certificate_chain_file(ctx, SERVERCERT)) 25653 25755 + { SSL_CTX_free(ctx); tls_err("missing certificate"); return; } 25654 25756 + SSL_CTX_load_verify_locations(ctx, CLIENTCA, NULL); 25655 25757 + 25656 +#if OPENSSL_VERSION_NUMBER >= 0x00907000L25657 25758 + /* crl checking */ 25658 25759 + store = SSL_CTX_get_cert_store(ctx); … … 25661 25762 + X509_STORE_set_flags(store, X509_V_FLAG_CRL_CHECK | 25662 25763 + X509_V_FLAG_CRL_CHECK_ALL); 25663 +#endif25664 25764 + 25665 25765 +#if OPENSSL_VERSION_NUMBER >= 0x10002000L … … 25668 25768 +#endif 25669 25769 + 25670 + /* set the callback here; SSL_set_verify didn't work before 0.9.6c */ 25671 + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, verify_cb); 25770 + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); 25672 25771 + 25673 25772 + /* a new SSL object, with the rest added to it directly to avoid copying */ … … 25705 25804 + /* neither cleartext nor any other response here is part of a standard */ 25706 25805 + const char *err = ssl_error_str(); 25707 + ssl_free(myssl); tls_out("connection failed", err); die_read();25806 + tls_out("connection failed", err); ssl_free(myssl); die_read("tls connection failed"); 25708 25807 + } 25709 25808 + ssl = myssl; … … 25878 25977 smtp_greet("220 "); 25879 25978 out(" ESMTP\r\n"); 25880 if (commands(&ssin,&smtpcommands) == 0) die_read(); 25979 - if (commands(&ssin,&smtpcommands) == 0) die_read(); 25980 + if (commands(&ssin,&smtpcommands) == 0) die_read("commands"); 25981 die_nomem(); 25982 } 25881 25983 diff -ruN ../netqmail-1.06-original/qmail-start.c netqmail-1.06/qmail-start.c 25882 25984 --- ../netqmail-1.06-original/qmail-start.c 1998-06-15 12:53:16.000000000 +0200 25883 +++ netqmail-1.06/qmail-start.c 2016-11-22 21:03:57.125527665 +0100 25884 @@ -8,6 +8,9 @@ 25985 +++ netqmail-1.06/qmail-start.c 2019-06-26 16:39:31.578826915 +0200 25986 @@ -4,10 +4,15 @@ 25987 #include "fork.h" 25988 #include "auto_uids.h" 25989 25990 +#include "channels.h" 25991 + 25992 char *(qsargs[]) = { "qmail-send", 0 }; 25885 25993 char *(qcargs[]) = { "qmail-clean", 0 }; 25886 25994 char *(qlargs[]) = { "qmail-lspawn", "./Mailbox", 0 }; … … 25892 26000 void die() { _exit(111); } 25893 26001 25894 @@ -18,1 3 +21,28@@26002 @@ -18,19 +23,51 @@ 25895 26003 int pi4[2]; 25896 26004 int pi5[2]; … … 25905 26013 +#endif 25906 26014 + 26015 +int suppl_pi[SUPPL_CHANNELS*2][2]; 26016 + 25907 26017 +void close23456() { 26018 + int c; 25908 26019 + close(2); close(3); close(4); close(5); close(6); 25909 26020 +#ifdef EXTERNAL_TODO 25910 26021 + close(7); close(8); 25911 26022 +#endif 26023 + for (c=1+CHANNEL_FD_OFFSET;c<=SUPPL_CHANNELS*2+CHANNEL_FD_OFFSET;c++) 26024 + { 26025 + close(c); 26026 + } 25912 26027 +} 25913 26028 25914 26029 void closepipes() { 26030 + int c; 26031 + 25915 26032 close(pi1[0]); close(pi1[1]); close(pi2[0]); close(pi2[1]); 25916 26033 close(pi3[0]); close(pi3[1]); close(pi4[0]); close(pi4[1]); … … 25920 26037 + close(pi9[0]); close(pi9[1]); close(pi10[0]); close(pi10[1]); 25921 26038 +#endif 26039 + 26040 + for (c=0;c<SUPPL_CHANNELS*2;c++) 26041 + { 26042 + close(suppl_pi[c][0]); 26043 + close(suppl_pi[c][1]); 26044 + } 25922 26045 } 25923 26046 25924 26047 void main(argc,argv) 25925 @@ -40,6 +58,10 @@ 26048 int argc; 26049 char **argv; 26050 { 26051 + int c, cc; 26052 + 26053 if (chdir("/") == -1) die(); 26054 umask(077); 26055 if (prot_gid(auto_gidq) == -1) die(); 26056 @@ -40,6 +77,14 @@ 25926 26057 if (fd_copy(4,0) == -1) die(); 25927 26058 if (fd_copy(5,0) == -1) die(); … … 25931 26062 + if (fd_copy(8,0) == -1) die(); 25932 26063 +#endif 26064 + for (c=1+CHANNEL_FD_OFFSET;c<=SUPPL_CHANNELS*2+CHANNEL_FD_OFFSET;c++) 26065 + { 26066 + if (fd_copy(c,0) == -1) die(); 26067 + } 25933 26068 25934 26069 if (argv[1]) { 25935 26070 qlargs[1] = argv[1]; 25936 @@ -70,6 + 92,12@@26071 @@ -70,6 +115,16 @@ 25937 26072 if (pipe(pi4) == -1) die(); 25938 26073 if (pipe(pi5) == -1) die(); … … 25944 26079 + if (pipe(pi10) == -1) die(); 25945 26080 +#endif 26081 + for (c=0;c<SUPPL_CHANNELS*2;c++) 26082 + { 26083 + if (pipe(suppl_pi[c]) == -1) die(); 26084 + } 25946 26085 25947 26086 switch(fork()) { 25948 26087 case -1: die(); 25949 @@ -106,6 +1 34,34@@26088 @@ -106,6 +161,57 @@ 25950 26089 die(); 25951 26090 } … … 25978 26117 + } 25979 26118 +#endif 25980 + 26119 + 26120 + for (c=0,cc=0;c<SUPPL_CHANNELS;++c,cc+=2) 26121 + { 26122 + switch(fork()) { 26123 + case -1: die(); 26124 + case 0: 26125 + if (prot_uid(auto_uidr) == -1) die(); 26126 + /* Does not increment cc in parent process */ 26127 + if (fd_copy(0,suppl_pi[cc++][0]) == -1) die(); 26128 + if (fd_copy(1,suppl_pi[cc][1]) == -1) die(); 26129 + close23456(); 26130 + closepipes(); 26131 + /*if (str_equal(channel_types[c],"remote")) 26132 + {*/ 26133 + execvp(*qrargs,qrargs); 26134 + /*} 26135 + else 26136 + { 26137 + execvp(*qlargs,qlargs); 26138 + }*/ 26139 + die(); 26140 + } 26141 + } 26142 + 25981 26143 if (prot_uid(auto_uids) == -1) die(); 25982 26144 if (fd_copy(0,1) == -1) die(); 25983 26145 if (fd_copy(1,pi1[1]) == -1) die(); 25984 @@ -114,6 + 170,10@@26146 @@ -114,6 +220,17 @@ 25985 26147 if (fd_copy(4,pi4[0]) == -1) die(); 25986 26148 if (fd_copy(5,pi5[1]) == -1) die(); … … 25990 26152 + if (fd_copy(8,pi8[0]) == -1) die(); 25991 26153 +#endif 26154 + 26155 + for (cc=0,c=1+CHANNEL_FD_OFFSET;c<=SUPPL_CHANNELS*2+CHANNEL_FD_OFFSET;c++) 26156 + { 26157 + if (fd_copy(c++,suppl_pi[cc++][1]) == -1) die(); 26158 + if (fd_copy(c,suppl_pi[cc++][0]) == -1) die(); 26159 + } 26160 + 25992 26161 closepipes(); 25993 26162 execvp(*qsargs,qsargs); … … 25995 26164 diff -ruN ../netqmail-1.06-original/qmail-todo.c netqmail-1.06/qmail-todo.c 25996 26165 --- ../netqmail-1.06-original/qmail-todo.c 1970-01-01 01:00:00.000000000 +0100 25997 +++ netqmail-1.06/qmail-todo.c 201 6-11-22 21:03:57.126527632 +010025998 @@ -0,0 +1,7 03@@26166 +++ netqmail-1.06/qmail-todo.c 2019-06-26 16:39:31.579826904 +0200 26167 @@ -0,0 +1,791 @@ 25999 26168 +#include <sys/types.h> 26000 26169 +#include <sys/stat.h> … … 26022 26191 +#include "trigger.h" 26023 26192 + 26193 +#include "channels.h" 26194 + 26024 26195 +/* critical timing feature #1: if not triggered, do not busy-loop */ 26025 26196 +/* critical timing feature #2: if triggered, respond within fixed time */ … … 26030 26201 +#define SLEEP_SYSFAIL 123 26031 26202 + 26203 + 26032 26204 +stralloc percenthack = {0}; 26033 26205 +struct constmap mappercenthack; … … 26037 26209 +struct constmap mapvdoms; 26038 26210 +stralloc envnoathost = {0}; 26211 +stralloc fname = {0}; 26039 26212 + 26040 26213 +char strnum[FMT_ULONG]; 26041 26214 + 26042 +/* XXX not good, if qmail-send.c changes this has to be updated */ 26043 +#define CHANNELS 2 26044 +char *chanaddr[CHANNELS] = { "local/", "remote/" }; 26215 +struct constmap mapsuppl[SUPPL_CHANNELS]; 26216 +stralloc suppls[SUPPL_CHANNELS]; 26217 +stralloc newsuppls[SUPPL_CHANNELS]; 26218 +char *chanaddr[CHANNELS]; 26045 26219 + 26046 26220 +datetime_sec recent; … … 26097 26271 + int i; 26098 26272 + int j; 26273 + int c; 26099 26274 + char *x; 26100 26275 + static stralloc addr = {0}; … … 26139 26314 + if (!stralloc_cat(&rwline,&addr)) return 0; 26140 26315 + if (!stralloc_0(&rwline)) return 0; 26316 + 26317 + for (c = 0;c < SUPPL_CHANNELS;++c) 26318 + { 26319 + if (constmap(&mapsuppl[c],addr.s + at + 1,addr.len - at - 1)) 26320 + return c + 3; 26321 + } 26322 + 26141 26323 + return 2; 26142 26324 +} … … 26206 26388 +} 26207 26389 + 26208 +void comm_write(unsigned long id, int local, int remote)26390 +void comm_write(unsigned long id, int flagchan[]) 26209 26391 +{ 26210 26392 + int pos; 26211 + char *s; 26393 + char s[CHANNELS+1]; 26394 + int c; 26212 26395 + 26213 + if(local && remote) s="B"; 26214 + else if(local) s="L"; 26215 + else if(remote) s="R"; 26216 + else s="X"; 26396 + for (c = 0;c < CHANNELS;++c) 26397 + { 26398 + if (flagchan[c]) 26399 + { 26400 + s[c] = '1'; 26401 + } 26402 + else 26403 + { 26404 + s[c] = '0'; 26405 + } 26406 + } 26407 + s[c] = 0; 26217 26408 + 26218 26409 + pos = comm_buf.len; … … 26496 26687 + break; 26497 26688 + case 'T': 26498 + switch(rewrite(todoline.s + 1)) 26499 + { 26500 + case 0: nomem(); goto fail; 26501 + case 2: c = 1; break; 26502 + default: c = 0; break; 26503 + } 26689 + c = rewrite(todoline.s + 1); 26690 + if (c == 0) { nomem(); goto fail; } 26691 + c--; 26504 26692 + if (fdchan[c] == -1) 26505 26693 + { … … 26553 26741 + } 26554 26742 + 26555 + comm_write(id, flagchan [0], flagchan[1]);26743 + comm_write(id, flagchan); 26556 26744 + 26557 26745 + return; … … 26568 26756 +int getcontrols(void) 26569 26757 +{ 26758 + int c; 26759 + 26570 26760 + if (control_init() == -1) return 0; 26571 26761 + if (control_rldef(&envnoathost,"control/envnoathost",1,"envnoathost") != 1) return 0; … … 26584 26774 + case 1: if (!constmap_init(&mapvdoms,vdoms.s,vdoms.len,1)) return 0; break; 26585 26775 + } 26776 + 26777 + for (c = 0;c < SUPPL_CHANNELS;++c) 26778 + { 26779 + strnum[fmt_uint(strnum,c)] = 0; 26780 + if (!stralloc_copys(&fname,"control/suppls")) return 0; 26781 + if (!stralloc_cats(&fname,strnum)) return 0; 26782 + if (!stralloc_0(&fname)) return 0; 26783 + switch (control_readfile(&suppls[c],fname.s,0)) 26784 + { 26785 + case -1: return 0; 26786 + case 0: if (!constmap_init(&mapsuppl[c],"",0,0)) return 0; break; 26787 + case 1: if (!constmap_init(&mapsuppl[c],suppls[c].s,suppls[c].len,0)) return 0; break; 26788 + } 26789 + } 26790 + 26586 26791 + return 1; 26587 26792 +} … … 26593 26798 +{ 26594 26799 + int r; 26800 + int c; 26595 26801 + 26596 26802 + if (control_readfile(&newlocals,"control/locals",1) != 1) … … 26613 26819 + else 26614 26820 + while (!constmap_init(&mapvdoms,"",0,1)) nomem(); 26821 + 26822 + for (c = 0;c < SUPPL_CHANNELS;++c) 26823 + { 26824 + strnum[fmt_uint(strnum,c)] = 0; 26825 + if (!stralloc_copys(&fname,"control/suppls")) nomem(); 26826 + if (!stralloc_cats(&fname,strnum)) nomem(); 26827 + if (!stralloc_0(&fname)) nomem(); 26828 + r = control_readfile(&newsuppls[c],fname.s,0); 26829 + if (r == -1) 26830 + { log3("alert: qmail-todo: unable to reread ", fname.s, "\n"); return; } 26831 + 26832 + constmap_free(&mapsuppl[c]); 26833 + 26834 + if (r) 26835 + { 26836 + while (!stralloc_copy(&suppls[c],&newsuppls[c])) nomem(); 26837 + while (!constmap_init(&mapsuppl[c],suppls[c].s,suppls[c].len,0)) nomem(); 26838 + } 26839 + else 26840 + while (!constmap_init(&mapsuppl[c],"",0,0)) nomem(); 26841 + } 26842 + 26615 26843 +} 26616 26844 + … … 26630 26858 +} 26631 26859 + 26860 +static int static_i = 0; 26861 +static int static_j = 0; 26862 +void channels_init(void) 26863 +{ 26864 + for (static_i=0;static_i<SUPPL_CHANNELS;static_i++) 26865 + suppls[static_i].s = 0; 26866 + 26867 + for (static_i=0;static_i<SUPPL_CHANNELS;static_i++) 26868 + newsuppls[static_i].s = 0; 26869 + 26870 + chanaddr[0] = "local/"; 26871 + chanaddr[1] = "remote/"; 26872 + static_j = 0; 26873 + for (static_i=2;static_i<CHANNELS;static_i++) 26874 + { 26875 + stralloc fnc = {0}; 26876 + strnum[fmt_uint(strnum,static_j++)] = 0; 26877 + if (!stralloc_copys(&fname,QDIR_BASENAME)) nomem(); 26878 + if (!stralloc_cats(&fname,strnum)) nomem(); 26879 + if (!stralloc_cats(&fname,"/")) nomem(); 26880 + if (!stralloc_0(&fname)) nomem(); 26881 + if (!stralloc_copy(&fnc,&fname)) nomem(); 26882 + chanaddr[static_i] = fnc.s; 26883 + } 26884 +} 26885 + 26886 + 26632 26887 +void main() 26633 26888 +{ … … 26639 26894 + int r; 26640 26895 + char c; 26896 + 26897 + channels_init(); 26641 26898 + 26642 26899 + if (chdir(auto_qmail) == -1) … … 26700 26957 +} 26701 26958 + 26959 diff -ruN ../netqmail-1.06-original/qmail-upq.sh netqmail-1.06/qmail-upq.sh 26960 --- ../netqmail-1.06-original/qmail-upq.sh 1998-06-15 12:53:16.000000000 +0200 26961 +++ netqmail-1.06/qmail-upq.sh 2019-06-26 16:39:31.579826904 +0200 26962 @@ -1,6 +1,6 @@ 26963 cd QMAIL 26964 cd queue 26965 -for dir in mess info local remote 26966 +for dir in mess info local remote suppl* 26967 do 26968 ( cd $dir; find . -type f -print ) | ( 26969 cd $dir 26702 26970 diff -ruN ../netqmail-1.06-original/qmail.c netqmail-1.06/qmail.c 26703 26971 --- ../netqmail-1.06-original/qmail.c 2007-11-30 21:22:54.000000000 +0100 26704 +++ netqmail-1.06/qmail.c 201 6-11-22 21:03:57.126527632+010026972 +++ netqmail-1.06/qmail.c 2019-02-27 20:57:13.404024915 +0100 26705 26973 @@ -23,22 +23,32 @@ 26706 26974 { … … 26800 27068 diff -ruN ../netqmail-1.06-original/qmail.h netqmail-1.06/qmail.h 26801 27069 --- ../netqmail-1.06-original/qmail.h 1998-06-15 12:53:16.000000000 +0200 26802 +++ netqmail-1.06/qmail.h 201 6-11-22 21:03:57.126527632+010027070 +++ netqmail-1.06/qmail.h 2019-02-27 20:57:13.404024915 +0100 26803 27071 @@ -3,11 +3,13 @@ 26804 27072 … … 26817 27085 diff -ruN ../netqmail-1.06-original/qregex.c netqmail-1.06/qregex.c 26818 27086 --- ../netqmail-1.06-original/qregex.c 1970-01-01 01:00:00.000000000 +0100 26819 +++ netqmail-1.06/qregex.c 201 6-11-22 21:03:57.126527632+010027087 +++ netqmail-1.06/qregex.c 2019-02-27 20:57:13.405024904 +0100 26820 27088 @@ -0,0 +1,239 @@ 26821 27089 +/* … … 27060 27328 diff -ruN ../netqmail-1.06-original/qregex.h netqmail-1.06/qregex.h 27061 27329 --- ../netqmail-1.06-original/qregex.h 1970-01-01 01:00:00.000000000 +0100 27062 +++ netqmail-1.06/qregex.h 201 6-11-22 21:03:57.126527632+010027330 +++ netqmail-1.06/qregex.h 2019-02-27 20:57:13.405024904 +0100 27063 27331 @@ -0,0 +1,24 @@ 27064 27332 +/* … … 27088 27356 diff -ruN ../netqmail-1.06-original/readwrite.h netqmail-1.06/readwrite.h 27089 27357 --- ../netqmail-1.06-original/readwrite.h 1998-06-15 12:53:16.000000000 +0200 27090 +++ netqmail-1.06/readwrite.h 201 6-11-22 21:03:57.126527632+010027358 +++ netqmail-1.06/readwrite.h 2019-02-27 20:57:13.405024904 +0100 27091 27359 @@ -1,7 +1,6 @@ 27092 27360 #ifndef READWRITE_H … … 27100 27368 diff -ruN ../netqmail-1.06-original/received.c netqmail-1.06/received.c 27101 27369 --- ../netqmail-1.06-original/received.c 1998-06-15 12:53:16.000000000 +0200 27102 +++ netqmail-1.06/received.c 201 6-11-22 21:03:57.127527599+010027370 +++ netqmail-1.06/received.c 2019-02-27 20:57:13.405024904 +0100 27103 27371 @@ -21,6 +21,9 @@ 27104 27372 return 0; … … 27128 27396 diff -ruN ../netqmail-1.06-original/remoteinfo.c netqmail-1.06/remoteinfo.c 27129 27397 --- ../netqmail-1.06-original/remoteinfo.c 1998-06-15 12:53:16.000000000 +0200 27130 +++ netqmail-1.06/remoteinfo.c 201 6-11-22 21:03:57.127527599+010027398 +++ netqmail-1.06/remoteinfo.c 2019-02-27 20:57:13.405024904 +0100 27131 27399 @@ -44,12 +44,12 @@ 27132 27400 s = socket(AF_INET,SOCK_STREAM,0); … … 27147 27415 diff -ruN ../netqmail-1.06-original/scan.h netqmail-1.06/scan.h 27148 27416 --- ../netqmail-1.06-original/scan.h 1998-06-15 12:53:16.000000000 +0200 27149 +++ netqmail-1.06/scan.h 201 8-03-31 14:54:40.767441567 +020027417 +++ netqmail-1.06/scan.h 2019-02-27 20:57:13.405024904 +0100 27150 27418 @@ -2,6 +2,7 @@ 27151 27419 #define SCAN_H … … 27158 27426 diff -ruN ../netqmail-1.06-original/scan_ulong.c netqmail-1.06/scan_ulong.c 27159 27427 --- ../netqmail-1.06-original/scan_ulong.c 1998-06-15 12:53:16.000000000 +0200 27160 +++ netqmail-1.06/scan_ulong.c 201 6-11-22 21:03:57.127527599+010027428 +++ netqmail-1.06/scan_ulong.c 2019-02-27 20:57:13.405024904 +0100 27161 27429 @@ -9,3 +9,43 @@ 27162 27430 { result = result * 10 + c; ++pos; } … … 27205 27473 diff -ruN ../netqmail-1.06-original/scan_xlong.c netqmail-1.06/scan_xlong.c 27206 27474 --- ../netqmail-1.06-original/scan_xlong.c 1970-01-01 01:00:00.000000000 +0100 27207 +++ netqmail-1.06/scan_xlong.c 201 6-11-22 21:03:57.127527599+010027475 +++ netqmail-1.06/scan_xlong.c 2019-02-27 20:57:13.405024904 +0100 27208 27476 @@ -0,0 +1,47 @@ 27209 27477 +/* … … 27256 27524 diff -ruN ../netqmail-1.06-original/select.h2 netqmail-1.06/select.h2 27257 27525 --- ../netqmail-1.06-original/select.h2 1998-06-15 12:53:16.000000000 +0200 27258 +++ netqmail-1.06/select.h2 201 6-11-22 21:03:57.127527599+010027526 +++ netqmail-1.06/select.h2 2019-02-27 20:57:13.405024904 +0100 27259 27527 @@ -1,6 +1,12 @@ 27260 27528 #ifndef SELECT_H … … 27272 27540 diff -ruN ../netqmail-1.06-original/socket_v4mappedprefix.c netqmail-1.06/socket_v4mappedprefix.c 27273 27541 --- ../netqmail-1.06-original/socket_v4mappedprefix.c 1970-01-01 01:00:00.000000000 +0100 27274 +++ netqmail-1.06/socket_v4mappedprefix.c 201 6-11-22 21:03:57.127527599+010027542 +++ netqmail-1.06/socket_v4mappedprefix.c 2019-02-27 20:57:13.406024893 +0100 27275 27543 @@ -0,0 +1,9 @@ 27276 27544 +/* … … 27285 27553 diff -ruN ../netqmail-1.06-original/socket_v6any.c netqmail-1.06/socket_v6any.c 27286 27554 --- ../netqmail-1.06-original/socket_v6any.c 1970-01-01 01:00:00.000000000 +0100 27287 +++ netqmail-1.06/socket_v6any.c 201 6-11-22 21:03:57.127527599+010027555 +++ netqmail-1.06/socket_v6any.c 2019-02-27 20:57:13.406024893 +0100 27288 27556 @@ -0,0 +1,9 @@ 27289 27557 +/* … … 27298 27566 diff -ruN ../netqmail-1.06-original/softwarelicense1-1.html netqmail-1.06/softwarelicense1-1.html 27299 27567 --- ../netqmail-1.06-original/softwarelicense1-1.html 1970-01-01 01:00:00.000000000 +0100 27300 +++ netqmail-1.06/softwarelicense1-1.html 201 6-11-22 21:03:57.128527565+010027568 +++ netqmail-1.06/softwarelicense1-1.html 2019-02-27 20:57:13.406024893 +0100 27301 27569 @@ -0,0 +1,59 @@ 27302 27570 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> … … 27361 27629 diff -ruN ../netqmail-1.06-original/spawn-filter.9 netqmail-1.06/spawn-filter.9 27362 27630 --- ../netqmail-1.06-original/spawn-filter.9 1970-01-01 01:00:00.000000000 +0100 27363 +++ netqmail-1.06/spawn-filter.9 201 6-11-22 21:03:57.128527565+010027631 +++ netqmail-1.06/spawn-filter.9 2019-02-27 20:57:13.406024893 +0100 27364 27632 @@ -0,0 +1,103 @@ 27365 27633 +.TH spawn-filter 8 … … 27468 27736 diff -ruN ../netqmail-1.06-original/spawn-filter.c netqmail-1.06/spawn-filter.c 27469 27737 --- ../netqmail-1.06-original/spawn-filter.c 1970-01-01 01:00:00.000000000 +0100 27470 +++ netqmail-1.06/spawn-filter.c 20 16-11-22 21:03:57.128527565 +010027471 @@ -0,0 +1,5 46 @@27738 +++ netqmail-1.06/spawn-filter.c 2020-04-09 19:45:45.390398843 +0200 27739 @@ -0,0 +1,506 @@ 27472 27740 +/* 27473 27741 + * netqmail-version without spam filter … … 27635 27903 +static int run_mailfilter(char *, char *, char **); 27636 27904 +int wildmat_internal(char *, char *); 27637 +static int check_size(char *);27638 27905 + 27639 27906 +static int remotE; 27640 27907 +stralloc sender = { 0 }; 27641 27908 +stralloc recipient = { 0 }; 27642 +27643 +static int27644 +check_size(char *size)27645 +{27646 + char *x;27647 + unsigned long databytes = -1, msgsize;27648 +27649 + if (!(x = env_get("DATABYTES")))27650 + {27651 + if (control_readulong(&databytes, "databytes") == -1)27652 + report(111, "spawn-filter: Unable to read databytes: ", error_str(errno), ". (#4.3.0)", 0, 0, 0);27653 + } else27654 + scan_ulong(x, &databytes);27655 + if (databytes == -1)27656 + return (0);27657 + scan_ulong(size, &msgsize);27658 + if (msgsize > databytes)27659 + return(1);27660 + else27661 + return(0);27662 +}27663 27909 + 27664 27910 +static void … … 27926 28172 +main(int argc, char **argv) 27927 28173 +{ 27928 + char *ptr, *mailprog, *domain, *errStr = 0, *size = "0", *qqeh, *ext; 27929 + char sizebuf[FMT_ULONG]; 27930 + struct stat statbuf; 28174 + char *ptr, *mailprog, *domain, *ext; 27931 28175 + int len; 27932 28176 + … … 27939 28183 + { 27940 28184 + mailprog = "bin/qmail-local"; 28185 + ext = argv[6]; 27941 28186 + domain = argv[7]; 27942 + ext = argv[6];27943 + qqeh = argv[10];27944 28187 + remotE = 0; 27945 28188 + if (!env_unset("QMAILREMOTE")) 27946 28189 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27947 + if (!fstat(0, &statbuf))27948 + {27949 + sizebuf[fmt_ulong(sizebuf, statbuf.st_size)] = 0;27950 + size = sizebuf;27951 + } else27952 + size = "0";27953 28190 + /*- sender */ 27954 28191 + if (!stralloc_copys(&sender, argv[8])) … … 27956 28193 + if (!stralloc_0(&sender)) 27957 28194 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27958 + if (!env_unset("QMAILREMOTE"))27959 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0);27960 28195 + /*- recipient */ 27961 + if (*ext) /*- EXT */ 27962 + { 28196 + if (*ext) { /*- EXT */ 27963 28197 + if (!stralloc_copys(&recipient, ext)) 27964 28198 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27965 28199 + } else /*- user */ 27966 + 27967 + 28200 + if (!stralloc_copys(&recipient, argv[2])) 28201 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27968 28202 + if (!stralloc_cats(&recipient, "@")) 27969 28203 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); … … 27977 28211 + mailprog = "bin/qmail-remote"; 27978 28212 + domain = argv[1]; 27979 + ext = argv[5];27980 + qqeh = argv[3];27981 + size = argv[4];27982 28213 + remotE = 1; 27983 28214 + if (!env_unset("QMAILLOCAL")) … … 27989 28220 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27990 28221 + /*- recipient */ 27991 + if (!stralloc_copys(&recipient, argv[ 5]))28222 + if (!stralloc_copys(&recipient, argv[3])) 27992 28223 + report(111, "spawn-filter: out of mem: ", error_str(errno), ". (#4.3.0)", 0, 0, 0); 27993 28224 + if (!stralloc_0(&recipient)) … … 28000 28231 + if (chdir(auto_qmail) == -1) 28001 28232 + report(111, "spawn-filter: Unable to switch to ", auto_qmail, ": ", error_str(errno), ". (#4.3.0)", 0); 28002 + /*- DATABYTES Check */28003 + if (check_size(size))28004 + report(100, "sorry, that message size exceeds my databytes limit (#5.3.4)", 0, 0, 0, 0, 0);28005 28233 + run_mailfilter(domain, mailprog, argv); 28006 28234 + report(111, "spawn-filter: could not exec ", mailprog, ": ", error_str(errno), ". (#4.3.0)", 0); … … 28018 28246 diff -ruN ../netqmail-1.06-original/spawn.c netqmail-1.06/spawn.c 28019 28247 --- ../netqmail-1.06-original/spawn.c 2007-11-30 21:22:54.000000000 +0100 28020 +++ netqmail-1.06/spawn.c 201 6-11-22 21:03:57.128527565+010028248 +++ netqmail-1.06/spawn.c 2019-02-27 20:57:13.407024882 +0100 28021 28249 @@ -1,4 +1,4 @@ 28022 28250 -#include <sys/types.h> … … 28097 28325 diff -ruN ../netqmail-1.06-original/spf.c netqmail-1.06/spf.c 28098 28326 --- ../netqmail-1.06-original/spf.c 1970-01-01 01:00:00.000000000 +0100 28099 +++ netqmail-1.06/spf.c 201 6-11-22 21:03:57.129527532 +010028327 +++ netqmail-1.06/spf.c 2019-02-27 20:57:13.407024882 +0100 28100 28328 @@ -0,0 +1,877 @@ 28101 28329 +#include "stralloc.h" … … 28978 29206 diff -ruN ../netqmail-1.06-original/spf.h netqmail-1.06/spf.h 28979 29207 --- ../netqmail-1.06-original/spf.h 1970-01-01 01:00:00.000000000 +0100 28980 +++ netqmail-1.06/spf.h 201 6-11-22 21:03:57.129527532 +010029208 +++ netqmail-1.06/spf.h 2019-02-27 20:57:13.407024882 +0100 28981 29209 @@ -0,0 +1,20 @@ 28982 29210 +#ifndef SPF_H … … 29002 29230 diff -ruN ../netqmail-1.06-original/spfquery.c netqmail-1.06/spfquery.c 29003 29231 --- ../netqmail-1.06-original/spfquery.c 1970-01-01 01:00:00.000000000 +0100 29004 +++ netqmail-1.06/spfquery.c 201 6-11-22 21:03:57.129527532 +010029232 +++ netqmail-1.06/spfquery.c 2019-02-27 20:57:13.407024882 +0100 29005 29233 @@ -0,0 +1,84 @@ 29006 29234 +#include "substdio.h" … … 29090 29318 diff -ruN ../netqmail-1.06-original/srs.c netqmail-1.06/srs.c 29091 29319 --- ../netqmail-1.06-original/srs.c 1970-01-01 01:00:00.000000000 +0100 29092 +++ netqmail-1.06/srs.c 201 6-11-22 21:03:57.129527532+010029320 +++ netqmail-1.06/srs.c 2019-02-27 20:57:13.408024870 +0100 29093 29321 @@ -0,0 +1,166 @@ 29094 29322 +#include <sys/types.h> … … 29260 29488 diff -ruN ../netqmail-1.06-original/srs.h netqmail-1.06/srs.h 29261 29489 --- ../netqmail-1.06-original/srs.h 1970-01-01 01:00:00.000000000 +0100 29262 +++ netqmail-1.06/srs.h 201 6-11-22 21:03:57.129527532+010029490 +++ netqmail-1.06/srs.h 2019-02-27 20:57:13.408024870 +0100 29263 29491 @@ -0,0 +1,9 @@ 29264 29492 +#ifndef SRS_H … … 29273 29501 diff -ruN ../netqmail-1.06-original/srsfilter.c netqmail-1.06/srsfilter.c 29274 29502 --- ../netqmail-1.06-original/srsfilter.c 1970-01-01 01:00:00.000000000 +0100 29275 +++ netqmail-1.06/srsfilter.c 201 6-11-22 21:03:57.129527532+010029503 +++ netqmail-1.06/srsfilter.c 2019-02-27 20:57:13.408024870 +0100 29276 29504 @@ -0,0 +1,137 @@ 29277 29505 +#include "sig.h" … … 29414 29642 diff -ruN ../netqmail-1.06-original/ssl_timeoutio.c netqmail-1.06/ssl_timeoutio.c 29415 29643 --- ../netqmail-1.06-original/ssl_timeoutio.c 1970-01-01 01:00:00.000000000 +0100 29416 +++ netqmail-1.06/ssl_timeoutio.c 2016-11-22 21:03:57.129527532 +0100 29417 @@ -0,0 +1,95 @@ 29644 +++ netqmail-1.06/ssl_timeoutio.c 2020-01-10 21:51:32.057157279 +0100 29645 @@ -0,0 +1,126 @@ 29646 +#ifdef TLS 29418 29647 +#include "select.h" 29419 29648 +#include "error.h" … … 29488 29717 +int ssl_timeoutrehandshake(int t, int rfd, int wfd, SSL *ssl) 29489 29718 +{ 29490 + int r; 29491 + 29492 + SSL_renegotiate(ssl); 29719 + int r=0; 29720 + 29721 +#if OPENSSL_VERSION_NUMBER >= 0x10101000L 29722 + if (SSL_version(ssl) >= TLS1_3_VERSION){ 29723 + if(SSL_verify_client_post_handshake(ssl) != 1) 29724 + return -EPROTO; 29725 + } else 29726 +#endif 29727 + { 29728 + r = SSL_renegotiate(ssl); 29729 + if (r<=0) return r; 29730 + } 29731 + 29732 +#if OPENSSL_VERSION_NUMBER >= 0x10001000L 29733 + char buf[1]; /* dummy read buffer */ 29734 + struct timeval tv; 29735 + fd_set fds; 29736 + r = ssl_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); 29737 + if (r <=0) return r; 29738 +#if OPENSSL_VERSION_NUMBER >= 0x10101000L 29739 + if (SSL_version(ssl) >= TLS1_3_VERSION) return r; 29740 +#endif 29741 + 29742 + tv.tv_sec = (time_t)t; tv.tv_usec = 0; 29743 + FD_ZERO(&fds); FD_SET(rfd, &fds); 29744 + if ((r = select(rfd + 1, &fds, NULL, NULL, &tv)>0) && FD_ISSET(rfd, &fds)){ 29745 + r = SSL_read(ssl, buf, 1); 29746 + if (SSL_get_error(ssl, r) == SSL_ERROR_WANT_READ) r = 1; /*ignore */ 29747 + } 29748 + if (r <=0) return r; 29749 +#else 29493 29750 + r = ssl_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); 29494 29751 + if (r <= 0 || ssl->type == SSL_ST_CONNECT) return r; … … 29496 29753 + /* this is for the server only */ 29497 29754 + ssl->state = SSL_ST_ACCEPT; 29755 +#endif 29498 29756 + return ssl_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); 29499 29757 +} … … 29511 29769 + return ssl_timeoutio(SSL_write, t, rfd, wfd, ssl, buf, len); 29512 29770 +} 29771 +#endif 29513 29772 diff -ruN ../netqmail-1.06-original/ssl_timeoutio.h netqmail-1.06/ssl_timeoutio.h 29514 29773 --- ../netqmail-1.06-original/ssl_timeoutio.h 1970-01-01 01:00:00.000000000 +0100 29515 +++ netqmail-1.06/ssl_timeoutio.h 201 6-11-22 21:03:57.130527499 +010029774 +++ netqmail-1.06/ssl_timeoutio.h 2019-04-07 13:05:52.192763950 +0200 29516 29775 @@ -0,0 +1,21 @@ 29517 29776 +#ifndef SSL_TIMEOUTIO_H … … 29521 29780 + 29522 29781 +/* the version is like this: 0xMNNFFPPS: major minor fix patch status */ 29523 +#if OPENSSL_VERSION_NUMBER < 0x0090 6000L29524 +# error "Need OpenSSL version at least 0.9. 6"29782 +#if OPENSSL_VERSION_NUMBER < 0x00908000L 29783 +# error "Need OpenSSL version at least 0.9.8" 29525 29784 +#endif 29526 29785 + … … 29538 29797 diff -ruN ../netqmail-1.06-original/str.h netqmail-1.06/str.h 29539 29798 --- ../netqmail-1.06-original/str.h 1998-06-15 12:53:16.000000000 +0200 29540 +++ netqmail-1.06/str.h 201 6-11-22 21:03:57.130527499+010029799 +++ netqmail-1.06/str.h 2019-02-27 20:57:13.408024870 +0100 29541 29800 @@ -2,6 +2,11 @@ 29542 29801 #define STR_H … … 29565 29824 diff -ruN ../netqmail-1.06-original/str_cpyb.c netqmail-1.06/str_cpyb.c 29566 29825 --- ../netqmail-1.06-original/str_cpyb.c 1970-01-01 01:00:00.000000000 +0100 29567 +++ netqmail-1.06/str_cpyb.c 201 6-11-22 21:03:57.130527499+010029826 +++ netqmail-1.06/str_cpyb.c 2019-02-27 20:57:13.408024870 +0100 29568 29827 @@ -0,0 +1,53 @@ 29569 29828 +/* … … 29622 29881 diff -ruN ../netqmail-1.06-original/str_cspn.c netqmail-1.06/str_cspn.c 29623 29882 --- ../netqmail-1.06-original/str_cspn.c 1970-01-01 01:00:00.000000000 +0100 29624 +++ netqmail-1.06/str_cspn.c 201 6-11-22 21:03:57.130527499+010029883 +++ netqmail-1.06/str_cspn.c 2019-02-27 20:57:13.408024870 +0100 29625 29884 @@ -0,0 +1,40 @@ 29626 29885 +/* … … 29666 29925 diff -ruN ../netqmail-1.06-original/strpidt.c netqmail-1.06/strpidt.c 29667 29926 --- ../netqmail-1.06-original/strpidt.c 1970-01-01 01:00:00.000000000 +0100 29668 +++ netqmail-1.06/strpidt.c 201 6-11-22 21:03:57.130527499+010029927 +++ netqmail-1.06/strpidt.c 2019-02-27 20:57:13.408024870 +0100 29669 29928 @@ -0,0 +1,26 @@ 29670 29929 +/* … … 29696 29955 diff -ruN ../netqmail-1.06-original/strsalloc.c netqmail-1.06/strsalloc.c 29697 29956 --- ../netqmail-1.06-original/strsalloc.c 1970-01-01 01:00:00.000000000 +0100 29698 +++ netqmail-1.06/strsalloc.c 201 6-11-22 21:03:57.130527499+010029957 +++ netqmail-1.06/strsalloc.c 2019-02-27 20:57:13.409024860 +0100 29699 29958 @@ -0,0 +1,7 @@ 29700 29959 +#include "alloc.h" … … 29707 29966 diff -ruN ../netqmail-1.06-original/strsalloc.h netqmail-1.06/strsalloc.h 29708 29967 --- ../netqmail-1.06-original/strsalloc.h 1970-01-01 01:00:00.000000000 +0100 29709 +++ netqmail-1.06/strsalloc.h 201 6-11-22 21:03:57.130527499+010029968 +++ netqmail-1.06/strsalloc.h 2019-02-27 20:57:13.409024860 +0100 29710 29969 @@ -0,0 +1,12 @@ 29711 29970 +#ifndef STRSALLOC_H … … 29723 29982 diff -ruN ../netqmail-1.06-original/strtimet.c netqmail-1.06/strtimet.c 29724 29983 --- ../netqmail-1.06-original/strtimet.c 1970-01-01 01:00:00.000000000 +0100 29725 +++ netqmail-1.06/strtimet.c 201 6-11-22 21:03:57.130527499+010029984 +++ netqmail-1.06/strtimet.c 2019-02-27 20:57:13.409024860 +0100 29726 29985 @@ -0,0 +1,26 @@ 29727 29986 +/* … … 29753 30012 diff -ruN ../netqmail-1.06-original/surblfilter.9 netqmail-1.06/surblfilter.9 29754 30013 --- ../netqmail-1.06-original/surblfilter.9 1970-01-01 01:00:00.000000000 +0100 29755 +++ netqmail-1.06/surblfilter.9 201 6-11-22 21:03:57.130527499 +010029756 @@ -0,0 +1,8 0@@30014 +++ netqmail-1.06/surblfilter.9 2019-06-19 09:49:02.553441531 +0200 30015 @@ -0,0 +1,82 @@ 29757 30016 +.TH surblfilter 8 29758 30017 +.SH NAME … … 29789 30048 +whitelist recipients by having the email addresses in \fIsurblrcpt\fR control file. You can 29790 30049 +change the name of this control file by setting \fBSURBLRCPT\fR environment variable. 30050 + 29791 30051 +.PP 29792 30052 +\fBsurblfilter\fR uses the control file \fIsurbldomainwhite\fR to whitelist a domain. … … 29797 30057 + 29798 30058 +.PP 29799 +\fBsurblfilter\fR caches results in QMAILHOME/control/cache. The filename represents the domain. 29800 +If a file as permission 0600, it means that the domain was blacklisted. The entries are 29801 +cached for a default of 300 seconds. You can change this by setting \fIcachelifetime\fR 29802 +control file. This directory should be owned by the uid set for running qmail-smtpd(8). 30059 +\fBsurblfilter\fR caches results in @controldir@/cache directory. The filename of files in this 30060 +directory represents the domain. If a file has permission 0600, it means that the domain was 30061 +blacklisted. The entries are cached for a default of 300 seconds. You can change this by 30062 +setting \fBCACHELIFETIME\fR environment variable or setting this value in \fBcacheliftime\fR 30063 +control file. The cache directory should be owned by the uid of the running qmail-smtpd(8). 29803 30064 + 29804 30065 +\fBsurblfilter\fR removes all leading host names, subdomains, www., randomized subdomains, etc. In … … 29837 30098 diff -ruN ../netqmail-1.06-original/surblfilter.c netqmail-1.06/surblfilter.c 29838 30099 --- ../netqmail-1.06-original/surblfilter.c 1970-01-01 01:00:00.000000000 +0100 29839 +++ netqmail-1.06/surblfilter.c 20 17-05-10 21:54:26.719100696+020029840 @@ -0,0 +1,88 1@@30100 +++ netqmail-1.06/surblfilter.c 2020-04-09 19:46:02.374231173 +0200 30101 @@ -0,0 +1,882 @@ 29841 30102 +/* 29842 30103 + * $Log: surblfilter.c,v $ … … 30058 30319 +dns_text(char *dn) 30059 30320 +{ 30060 + u_char response[PACKETSZ + PACKETSZ + 1];/* response */30321 + u_char response[PACKETSZ + PACKETSZ + 1]; /* response */ 30061 30322 + int responselen; /* buffer length */ 30062 + int rc; /* misc variables */30323 + int rc; /* misc variables */ 30063 30324 + int ancount, qdcount; /* answer count and query count */ 30064 30325 + u_short type, rdlength; /* fields of records returned */ 30065 30326 + u_char *eom, *cp; 30066 + u_char buf[PACKETSZ + 1]; /* we're storing a TXT record here, not just a DNAME */30327 + u_char buf[PACKETSZ + PACKETSZ + 1]; /* we're storing a TXT record here, not just a DNAME */ 30067 30328 + u_char *bufptr; 30068 30329 + 30069 + 30070 + 30071 + 30072 + 30073 + 30074 + 30075 + 30076 + 30077 + 30330 + for (rc = 0, responselen = PACKETSZ;rc < 2;rc++) { 30331 + if ((responselen = res_query(dn, C_IN, T_TXT, response, responselen)) < 0) { 30332 + if (h_errno == TRY_AGAIN) 30333 + return strdup("e=temp;"); 30334 + else 30335 + return strdup("e=perm;"); 30336 + } 30337 + if (responselen <= PACKETSZ) 30338 + break; 30078 30339 + else 30079 + 30340 + if (responselen >= (2 * PACKETSZ)) 30080 30341 + return strdup("e=perm;"); 30081 30342 + } … … 30108 30369 + 30109 30370 + cnt = *cp++; /* http://crynwr.com/rfc1035/rfc1035.html#3.3.14. */ 30110 + 30371 + if (bufptr - buf + cnt + 1 >= (2 * PACKETSZ)) 30111 30372 + return strdup("e=perm;"); 30112 30373 + if (cp + cnt > eom) … … 30200 30461 + return (-1); 30201 30462 + } 30202 + if (!stralloc_copy s(&cachefile, "control/cache", 13))30463 + if (!stralloc_copyb(&cachefile, "control/cache", 13)) 30203 30464 + die_nomem(); 30204 30465 + if (!stralloc_0(&cachefile)) … … 30720 30981 + x++; 30721 30982 +} 30983 + 30722 30984 diff -ruN ../netqmail-1.06-original/surblqueue.sh netqmail-1.06/surblqueue.sh 30723 30985 --- ../netqmail-1.06-original/surblqueue.sh 1970-01-01 01:00:00.000000000 +0100 30724 +++ netqmail-1.06/surblqueue.sh 201 6-11-22 21:03:57.131527465+010030986 +++ netqmail-1.06/surblqueue.sh 2019-02-27 20:57:13.409024860 +0100 30725 30987 @@ -0,0 +1,33 @@ 30726 30988 +#!/bin/sh … … 30759 31021 diff -ruN ../netqmail-1.06-original/tai.h netqmail-1.06/tai.h 30760 31022 --- ../netqmail-1.06-original/tai.h 1970-01-01 01:00:00.000000000 +0100 30761 +++ netqmail-1.06/tai.h 201 6-11-22 21:03:57.131527465+010031023 +++ netqmail-1.06/tai.h 2019-02-27 20:57:13.409024860 +0100 30762 31024 @@ -0,0 +1,34 @@ 30763 31025 +/* … … 30797 31059 diff -ruN ../netqmail-1.06-original/tcp-env.c netqmail-1.06/tcp-env.c 30798 31060 --- ../netqmail-1.06-original/tcp-env.c 1998-06-15 12:53:16.000000000 +0200 30799 +++ netqmail-1.06/tcp-env.c 201 6-11-22 21:03:57.131527465+010031061 +++ netqmail-1.06/tcp-env.c 2019-02-27 20:57:13.410024849 +0100 30800 31062 @@ -10,6 +10,7 @@ 30801 31063 #include "scan.h" … … 30844 31106 case_lowers(remotename.s); 30845 31107 if (!env_put2("TCPREMOTEHOST",remotename.s)) die(); 31108 diff -ruN ../netqmail-1.06-original/time_t_size.c netqmail-1.06/time_t_size.c 31109 --- ../netqmail-1.06-original/time_t_size.c 1970-01-01 01:00:00.000000000 +0100 31110 +++ netqmail-1.06/time_t_size.c 2019-05-23 15:12:30.140092743 +0200 31111 @@ -0,0 +1,8 @@ 31112 +#include <stdio.h> 31113 +#include <time.h> 31114 +int 31115 +main() 31116 +{ 31117 + printf("#define SIZEOF_TIME_T %d\n", sizeof(time_t)); 31118 + return (0); 31119 +} 30846 31120 diff -ruN ../netqmail-1.06-original/timeoutconn.c netqmail-1.06/timeoutconn.c 30847 31121 --- ../netqmail-1.06-original/timeoutconn.c 1998-06-15 12:53:16.000000000 +0200 30848 +++ netqmail-1.06/timeoutconn.c 201 6-11-22 21:03:57.131527465+010031122 +++ netqmail-1.06/timeoutconn.c 2019-02-27 20:57:13.410024849 +0100 30849 31123 @@ -10,9 +10,10 @@ 30850 31124 #include "byte.h" … … 30875 31149 diff -ruN ../netqmail-1.06-original/tls.c netqmail-1.06/tls.c 30876 31150 --- ../netqmail-1.06-original/tls.c 1970-01-01 01:00:00.000000000 +0100 30877 +++ netqmail-1.06/tls.c 2016-11-22 21:03:57.131527465 +0100 30878 @@ -0,0 +1,25 @@ 31151 +++ netqmail-1.06/tls.c 2019-04-09 20:56:31.139694929 +0200 31152 @@ -0,0 +1,27 @@ 31153 +#ifdef TLS 30879 31154 +#include "exit.h" 30880 31155 +#include "error.h" … … 30902 31177 + return (errno == error_timeout) ? "timed out" : error_str(errno); 30903 31178 +} 31179 +#endif 30904 31180 diff -ruN ../netqmail-1.06-original/tls.h netqmail-1.06/tls.h 30905 31181 --- ../netqmail-1.06-original/tls.h 1970-01-01 01:00:00.000000000 +0100 30906 +++ netqmail-1.06/tls.h 201 6-11-22 21:03:57.132527432+010031182 +++ netqmail-1.06/tls.h 2019-02-27 20:57:13.410024849 +0100 30907 31183 @@ -0,0 +1,16 @@ 30908 31184 +#ifndef TLS_H … … 30924 31200 diff -ruN ../netqmail-1.06-original/tryulong64.c netqmail-1.06/tryulong64.c 30925 31201 --- ../netqmail-1.06-original/tryulong64.c 1970-01-01 01:00:00.000000000 +0100 30926 +++ netqmail-1.06/tryulong64.c 201 6-11-22 21:03:57.132527432+010031202 +++ netqmail-1.06/tryulong64.c 2019-02-27 20:57:13.410024849 +0100 30927 31203 @@ -0,0 +1,47 @@ 30928 31204 +/* … … 30975 31251 diff -ruN ../netqmail-1.06-original/uint64.h1 netqmail-1.06/uint64.h1 30976 31252 --- ../netqmail-1.06-original/uint64.h1 1970-01-01 01:00:00.000000000 +0100 30977 +++ netqmail-1.06/uint64.h1 201 6-11-22 21:03:57.132527432+010031253 +++ netqmail-1.06/uint64.h1 2019-02-27 20:57:13.410024849 +0100 30978 31254 @@ -0,0 +1,12 @@ 30979 31255 +/* … … 30991 31267 diff -ruN ../netqmail-1.06-original/uint64.h2 netqmail-1.06/uint64.h2 30992 31268 --- ../netqmail-1.06-original/uint64.h2 1970-01-01 01:00:00.000000000 +0100 30993 +++ netqmail-1.06/uint64.h2 201 6-11-22 21:03:57.132527432+010031269 +++ netqmail-1.06/uint64.h2 2019-02-27 20:57:13.410024849 +0100 30994 31270 @@ -0,0 +1,12 @@ 30995 31271 +/* … … 31007 31283 diff -ruN ../netqmail-1.06-original/update_tmprsadh.sh netqmail-1.06/update_tmprsadh.sh 31008 31284 --- ../netqmail-1.06-original/update_tmprsadh.sh 1970-01-01 01:00:00.000000000 +0100 31009 +++ netqmail-1.06/update_tmprsadh.sh 201 6-11-22 21:03:57.132527432+010031285 +++ netqmail-1.06/update_tmprsadh.sh 2019-02-27 20:57:13.410024849 +0100 31010 31286 @@ -0,0 +1,22 @@ 31011 31287 +#!/bin/sh … … 31033 31309 diff -ruN ../netqmail-1.06-original/wildmat.c netqmail-1.06/wildmat.c 31034 31310 --- ../netqmail-1.06-original/wildmat.c 1970-01-01 01:00:00.000000000 +0100 31035 +++ netqmail-1.06/wildmat.c 201 6-11-22 21:03:57.132527432+010031311 +++ netqmail-1.06/wildmat.c 2019-02-27 20:57:13.410024849 +0100 31036 31312 @@ -0,0 +1,173 @@ 31037 31313 +/*-** wildmat.c.orig Wed Dec 3 11:46:31 1997
Note: See TracChangeset
for help on using the changeset viewer.