badzong / mopher Goto Github PK
View Code? Open in Web Editor NEWAwesome mail filter with firewall like configuration.
License: MIT License
Awesome mail filter with firewall like configuration.
License: MIT License
The MySQL Driver does not automatically reconnect if the connection is lost.
Implement regdom, a simple method of determining registered domain names
based on Mozilla's public suffix list (publicsuffix.org). Add regdom to
greylist_source in order to improve domain based greylisting.
--- build ---
for i in src/modules src man config; do (cd $i && /opt/local/bin/bmake build) || exit 1; done
--- cast.so ---
--- counter.so ---
--- cast.so ---
gcc -O2 -I/opt/local/include -I/usr/include -I../.. -I../../src/include -O2 -I/opt/local/include -I/usr/include -Wall cast.c -L/opt/local/lib -Wl,-R/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -nostartfiles -shared -fPIC -L/opt/local/lib -Wl,-R/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -o cast.so
--- counter.so ---
gcc -O2 -I/opt/local/include -I/usr/include -I../.. -I../../src/include -O2 -I/opt/local/include -I/usr/include -Wall counter.c -L/opt/local/lib -Wl,-R/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -nostartfiles -shared -fPIC -L/opt/local/lib -Wl,-R/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -o counter.so
--- cast.so ---
In file included from ../../src/include/var.h:6:0,
from ../../src/include/exp.h:4,
from ../../src/include/acl.h:4,
from ../../src/include/mopher.h:9,
from cast.c:4:
../../src/include/hash.h:8:38: error: unknown type name 'u_int32_t'
hash_t hash_one_at_a_time(char *key, u_int32_t len);
^
../../src/include/hash.h:9:28: error: unknown type name 'u_int32_t'
hash_t hash_djb(void *key, u_int32_t len);
^
../../src/include/hash.h:10:29: error: unknown type name 'u_int32_t'
hash_t hash_test(void *key, u_int32_t len);
^
../../src/include/hash.h:11:30: error: unknown type name 'u_int32_t'
hash_t hash_chain(void *key, u_int32_t len);
^
In file included from ../../src/include/exp.h:5:0,
from ../../src/include/acl.h:4,
from ../../src/include/mopher.h:9,
from cast.c:4:
../../src/include/ll.h:20:2: error: unknown type name 'u_int32_t'
u_int32_t ll_size;
^
--- counter.so ---
In file included from ../../src/include/var.h:6:0,
from ../../src/include/exp.h:4,
from ../../src/include/acl.h:4,
from ../../src/include/mopher.h:9,
from counter.c:8:
../../src/include/hash.h:8:38: error: unknown type name 'u_int32_t'
hash_t hash_one_at_a_time(char *key, u_int32_t len);
^
../../src/include/hash.h:9:28: error: unknown type name 'u_int32_t'
hash_t hash_djb(void *key, u_int32_t len);
^
../../src/include/hash.h:10:29: error: unknown type name 'u_int32_t'
hash_t hash_test(void *key, u_int32_t len);
^
../../src/include/hash.h:11:30: error: unknown type name 'u_int32_t'
hash_t hash_chain(void *key, u_int32_t len);
^
In file included from ../../src/include/exp.h:5:0,
from ../../src/include/acl.h:4,
from ../../src/include/mopher.h:9,
from counter.c:8:
../../src/include/ll.h:20:2: error: unknown type name 'u_int32_t'
u_int32_t ll_size;
^
--- cast.so ---
*** [cast.so] Error code 1
bmake: stopped in /home/pbulk/build/mail/mopher/work/mopher-0.5.3/src/modules
--- counter.so ---
*** [counter.so] Error code 1
Currently, it is not possible to omit the deadline keyword, since it will fall back to invalid defaults.
*
define foo rbl_def_a || rbl_def_b' -> false (always)
define foo tarpit_delayed || greylist_delayed' -> false (always)
`define foo rbl_def_a ||<\n><\t>rbl_def_b' -> true (always)
Building mopher with pkgsrc fails since LDFLAGS was removed from modules/Makefile.
Its probably best to distribute SOFLAGS content into CFLAGS/LDFLAGS and remove SOFLAGS.
cf_default says cleanup_interval, many other places mention dbt_cleanup_interval.
Config directives are almost all prefixed so dbt_cleanup_interval seems right.
Note that both functions need both treatments.
libidn punycode documentation:
http://www.gnu.org/software/libidn/manual/libidn.html#Punycode-Functions
When parsing the Message-ID, mopher-0.4 will recognize Message-ID but not Message-Id.
# ktruss /usr/pkg/sbin/mopherctl dump counter_penpal
(...)
18684 1 mopherctl connect(0x3, 0x7f7ff7b033b0, 0x10) = 0
18684 1 mopherctl write(0x3, 0x7f7fffff9ab0, 0x1a) = 26
"table_dump counter_penpal\n"
18684 1 mopherctl read(0x3, 0x7f7fffffabb0, 0x1000) = 6
"65241\n"
18684 1 mopherctl write(0x3, 0x46e74f, 0x2) = 2
"OK"
18684 1 mopherctl read(0x3, 0x7f7ff7b15000, 0x6) = 6
(...)
18684 1 mopherctl read(0x3, 0x7f7ff7b24ed6, 0x6) = 5
"6)\nOK"
That's on netbsd-6, connection over unix/inet doesn't matter.
Also: Server says 65241, awk counts 65243..
That would include registration and the default value.
I'm in favour of reverting 9330790
If you want to route incoming mail based on Subject, use sieve or any of its friends.
If you want to filter spam based on Subject, add custom rules to Spamassassin.
Also, Subject can look like this:
=?charset?encoding?encoded-text?=
which seems like something mopher does not want to deal with.
While testing #23 on Ubuntu (14.04) I tried to start mopherd as a user that has no rw access to workdir and got this:
$ /usr/local/sbin/mopherd -f
mopherd[11162]: milter_init: already running as unprivileged user
mopherd[11162]: sock_unix_listen: bind: /tmp/mopher/mopherd-c.sock: Permission denied
mopherd[11162]: server_init: sock_listen failed
mopherd[11162]: dbt_clear: pthread_mutex_join: No such thread: Permission denied
Bus error (core dumped)
$ /usr/local/sbin/mopherd -f
mopherd[11165]: milter_init: already running as unprivileged user
mopherd[11165]: sock_unix_listen: bind: /tmp/mopher/mopherd-c.sock: Permission denied
mopherd[11165]: server_init: sock_listen failed
mopherd[11165]: dbt_clear: pthread_mutex_join: No such thread: Permission denied
mopherd[11165]: dbt_clear: pthread_mutex_join: Deadlock: Success
Illegal instruction (core dumped)
$ /usr/local/sbin/mopherd -f
mopherd[11168]: milter_init: already running as unprivileged user
mopherd[11168]: sock_unix_listen: bind: /tmp/mopher/mopherd-c.sock: Permission denied
mopherd[11168]: server_init: sock_listen failed
mopherd[11168]: dbt_clear: pthread_mutex_join: No such thread: Permission denied
Segmentation fault (core dumped)
In gdb, though, mopherd exits normally.
Example:
foo >= 5 || bar
If foo is less then 5, bar will be skipped and the whole expression will evaluate false.
A high-volume mailing-list that delivers each of its messages with a unique envelope-sender inflated my counter_penpal and when I'm trying to dump it, moco fails:
# moco table -D counter_penpal
server_check: expected 0x4f4b ('OK') got 726f
server_data_cmd: server_check failed
moco_table_dump: server_data_cmd failed
Here is a quick tcpdump:
# tcpdump -ilo0 -s0 -A tcp port 44554
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo0, link-type NULL (BSD loopback), capture size 65535 bytes
12:46:13.215990 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [S], seq 830018289, win 32768, options [mss 33608,nop,wscale 3,sackOK,nop,nop,nop,nop,TS val 1 ecr 0], length 0
E..@..@.@..............
1y..........P......H...........
........
12:46:13.216027 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [S.], seq 853713292, ack 830018290, win 32768, options [mss 33608,nop,wscale 3,nop,nop,TS val 1 ecr 1,sackOK,nop,nop], length 0
E..@..@.@............
..2...1y......{......H.......
............
12:46:13.216041 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [.], ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
E..4..@.@..............
1y..2..............
........
12:46:13.216103 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [P.], seq 1:27, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 26
E..N.A@.@..............
1y..2..............
........table_dump counter_penpal
12:46:13.221216 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [P.], seq 1:7, ack 27, win 4096, options [nop,nop,TS val 1 ecr 1], length 6
E..:..@.@............
..2...1y.......W.....
........82585
12:46:13.221254 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [P.], seq 27:29, ack 7, win 4096, options [nop,nop,TS val 1 ecr 1], length 2
E..6..@.@..............
1y..2.......Z~.....
........OK
12:46:13.221314 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [P.], seq 7:16391, ack 29, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
[email protected]@.@............
..2...1y.............
........(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(<LIST-ITEM-REMOVED>)
(google.com,[email protected],[email protected],1409537396,1409537396,1410142196,1)
(google.com,[email protected],[email protected],1409568128,1409568128,1410172928,1)
(google.com,[email protected],[email protected],1409119743,1409119743,1409724543,1)
(...many more...)
(google.com,[email protected],[email protected],1409550030,1409550030,1410154830,1)
(google.com,[email protected],[email protected],1409057614,1409057614,1409662414,1)
(google.com,[email protected],[email protected],1409638606,1409638606,1410243406,1)
(google.com,list+bncBCA4DV7Z24DRBSPZ6WPQKGQ
12:46:13.221368 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [P.], seq 16391:32775, ack 29, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
[email protected]@.@............
..2...1y......IJ.....
[email protected],[email protected],1409121488,1409121488,1409726288,1)
(google.com,[email protected],[email protected],1409553238,1409553238,1410158038,1)
(google.com,[email protected],[email protected],1409206100,1409206100,1409810900,1)
(google.com,[email protected],[email protected],1409234010,1409234010,1409838810,1)
(...many more...)
(google.com,[email protected],[email protected],1409589957,1409589957,1410194757,1)
(google.com,[email protected],[email protected],1409063966,1409063966,1409668766,1)
(google.com,[email protected],[email protected],1409059895,1409059895,1409664695,1)
(google.com,list+bncBCO2BL6QRADBBH4CQSQAKGQE6VIMALQ@googleg
12:46:13.221386 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [.], ack 32775, win 0, options [nop,nop,TS val 1 ecr 1], length 0
E..4..@.@..............
1y..2.!.....9......
........
12:46:13.221439 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [.], ack 32775, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
E..4..@.@..............
1y..2.!.....)......
........
12:46:13.221473 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [.], seq 32775:53255, ack 29, win 4096, options [nop,nop,TS val 1 ecr 1], length 20480
E.P4.D@.@............
..2.!.1y......A......
........roups.com,[email protected],1409351976,1409351976,1409956776,1)
(google.com,[email protected],[email protected],1409309250,1409309250,1409914050,1)
(google.com,[email protected],[email protected],1409211417,1409211417,1409816217,1)
(google.com,[email protected],[email protected],1409194607,1409194607,1409799407,1)
(...many more...)
(google.com,[email protected],[email protected],1409224532,1409224532,1409829332,1)
(google.com,[email protected],[email protected],1409450502,1409450502,1410055302,1)
(google.com,[email protected],[email protected],1409335617,1409335617,1409940417,1)
(google.com,[email protected],[email protected],140
12:46:13.221867 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [F.], seq 29, ack 53255, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
E..4..@.@..............
1y..2.q............
........
12:46:13.221915 IP 127.0.0.1.44554 > 127.0.0.1.63455: Flags [P.], seq 53255:73735, ack 30, win 4096, options [nop,nop,TS val 1 ecr 1], length 20480
E.P4.K@.@............
..2.q.1y.......;.....
........9360696,1409360696,1409965496,1)
(google.com,[email protected],[email protected],1409609301,1409609301,1410214101,1)
(google.com,[email protected],[email protected],1409324657,1409324657,1409929457,1)
(google.com,[email protected],[email protected],1409347585,1409347585,1409952385,1)
(...many more...)
(google.com,[email protected],[email protected],1409364281,1409364281,1409969081,1)
(google.com,[email protected],[email protected],1409629120,1409629120,1410233920,1)
(google.com,[email protected],[email protected],1409185352,1409185352,1409790152,1)
(google.com,list+bncBDZ25HFW6
12:46:13.221940 IP 127.0.0.1.63455 > 127.0.0.1.44554: Flags [R], seq 830018319, win 0, length 0
E..(....@..............
1y......P....k..
Currently, the following regdom tests are failing:
1 regdom_assert: test "example.COM" expected "example.com" got "example.COM"
2 regdom_assert: test "WwW.example.COM" expected "example.com" got "example.COM"
3 regdom_assert: test ".example.com" expected "NULL" got "example.com"
4 regdom_assert: test ".example.example" expected "NULL" got "example.example"
5 regdom_assert: test "食狮.公司.cn" expected "食狮.公司.cn" got "公司.cn"
6 regdom_assert: test "www.食狮.公司.cn" expected "食狮.公司.cn" got "公司.cn"
7 regdom_assert: test "shishi.公司.cn" expected "shishi.公司.cn" got "公司.cn"
8 regdom_assert: test "公司.cn" expected "NULL" got "公司.cn"
the impact of this depends on how the MTA and/or libmilter presents the hostname to mopher. If it's already in lowercase (1-2) and translated to punycode (5-8) then everything is fine. Otherwise, at least 5-8 should be fixed since non-punycode utf-8 hostnames will obviously yield wrong results.
Right now the header looks like this:
Received: from sender.foo.com ([109.246.16.16] [109.246.16.16]) by receiver.bar.com (envelope-sender <<[email protected]>>) (mopherd) with SMTP id 3760A10696FA; Thu, 03 May 2012 16:12:05 +0000 * there are double `<<' `>>' in the envsender address * hosts with no rdns get ([109.246.16.16] [109.246.16.16]) instead of ([109.246.16.16]) which is sendmail-style and triggers RDNS_NONE
Here is a sendmail-received-header:
Received: from uchoosem.com (207-36-31-72.ptr.primarydns.com [207.36.31.72]) by mx01.i-is.com (8.12.11/8.12.11) with ESMTP id k32GfMBr059052 for <[email protected]>; Sun, 2 Apr 2006 12:41:22 -0400 (EDT) (envelope-from [email protected])
without rdns:
Received: from uchoosem.com ([207.36.31.72]) by mx01.i-is.com (8.12.11/8.12.11) with ESMTP id k32GfMBr059052 for <[email protected]>; Sun, 2 Apr 2006 12:41:22 -0400 (EDT) (envelope-from [email protected])
envrcpt: greylist: status=defer, delay=900, remaining=665, attempts=4, remaining=140183437574146
diff --git a/src/include/sht.h b/src/include/sht.h
index aff0278..8b27ac6 100644
--- a/src/include/sht.h
+++ b/src/include/sht.h
@@ -1,5 +1,5 @@
#ifndef _SHT_H_
-#define _SHT_H
+#define _SHT_H_
typedef void (*sht_delete_t)(void *data);
rbl_foo == 127.0.0.5' does not work,
rbl_foo == "127.0.0.5"' does
>
> admin stops mopherd..
>
mopherd[649]: terminated
>
> admin starts mopherd...
>
mopherd[17364]: unknown variable "null" in "/etc/pkg/mopher/mopherd.acl" on line 21
>
> admin fixes error in mopherd.acl...
> admin starts mopherd...
>
mopherd[7300]: sock_unix_listen: bind: /var/mopher/mopherd-ctl.sock: Address already in use
>
> admin removes socket
> admin starts mopherd
> mopherd reports success...
>
mopherd[7300]: mopherd-0.5.1 started
>
> but then fails...
>
mopherd[7300]: server_init: sock_listen failed
>
> admin removes socket...
> admin starts mopherd...
>
mopherd[13765]: util_pidfile: /var/run/mopher/mopherd.pid exists
>
> admin removes pidfile...
> admin starts mopherd...
>
mopherd[11685]: mopherd-0.5.1 started
Free-, Net-, Open- and DragonflyBSD all contain the legacy db(3) API interface in their libc so using it would remove bdb.c's current db[45..] dependency.
Note that dbopen(3) on *BSD says:
None of the access methods provide any form of concurrent access, locking, or transactions.
ac-example:
(....)
# find usable db library
db=none
# db 1.85, included in libc
AC_CHECK_FUNCS(dbopen, [AC_CHECK_HEADERS([db.h], [db=db; DBLIBS=''])])
# db 1.85, separate library
if test "$db" = "none"
then
AC_CHECK_LIB(db, dbopen,
[AC_CHECK_HEADERS([db.h], [db=db; DBLIBS='-ldb'])])
fi
# db 2 compatibility mode
if test "$db" = "none"
then
AC_CHECK_LIB(db2, dbopen,
[AC_CHECK_HEADERS([db2/db_185.h db_185.h],
[db=db; DBLIBS='-ldb2'; break])])
fi
# db 3 compatibility mode
if test "$db" = "none"
then
AC_CHECK_LIB(db3, __db185_open,
[AC_CHECK_HEADERS([db3/db_185.h db_185.h],
[db=db; DBLIBS='-ldb3'; break])])
fi
# db 4 compatibility mode
if test "$db" = "none"
then
AC_CHECK_LIB(db4, __db185_open,
[AC_CHECK_HEADERS([db4/db_185.h db_185.h],
[db=db; DBLIBS='-ldb4'; break])])
fi
if test "$db" = "none"
then
AC_MSG_ERROR(no supported data base library found)
fi
DBTYPE=$db
(....)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.