structure SpamAssassin :> SPAM_ASSASSIN_CONFIG = struct
+val addrsDb = ConfigCore.sharedRoot ^ "/email/spamassassin/addrs"
val addrsDir = "/etc/spamassassin/addrs"
+val postReload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish spamassassin"
+
end
signature SPAM_ASSASSIN_CONFIG = sig
val addrsDir : string
+ val addrsDb : string
+
+ val postReload : string
end
/bin/chgrp mail /etc/courier/exim.dat
/bin/chmod o-r /etc/courier/exim.dat
;;
+ spamassassin)
+ SHAREDROOT=`domtool-config -path shared-root`
+ /usr/bin/rsync -r --delete ${SHAREDROOT}/email/spamassassin/addrs/ /etc/spamassassin/addrs
+ ;;
smtplog)
/bin/grep $2 /var/log/exim4/mainlog
;;
(* HCoop Domtool (http://hcoop.sourceforge.net/)
* Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
val query : address -> bool
val set : address * bool -> unit
+ val rebuild : unit -> bool
end
(* HCoop Domtool (http://hcoop.sourceforge.net/)
* Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
structure SetSA :> SET_SA = struct
+open MsgTypes
+
datatype address =
User of string
| Email of string
fun address (User s) = s ^ "@localhost"
| address (Email s) = s
-fun file addr = OS.Path.joinDirFile {dir = Config.SpamAssassin.addrsDir,
+fun file addr = OS.Path.joinDirFile {dir = Config.SpamAssassin.addrsDb,
file = address addr}
fun query addr = Posix.FileSys.access (file addr, [])
else
OS.FileSys.remove (file addr)
+fun rebuild () =
+ let
+ fun doNode (site, ok) =
+ (print ("New spamassassin data for node " ^ site ^ "\n");
+ Connect.commandWorker (Domain.get_context (), site, MsgSaChanged))
+ in
+ foldl doNode true Config.mailNodes_all
+ end
+
end
NONE => ("User tried to set SA filtering for " ^ addr,
SOME "You aren't allowed to configure SA filtering for that recipient.")
| SOME addr' => (SetSA.set (addr', b);
+ SetSA.rebuild ();
Msg.send (bio, MsgOk);
("Set SA filtering status for " ^ addr ^ " to "
^ (if b then "ON" else "OFF"),
Msg.send (bio, MsgOk)
else
Msg.send (bio, MsgError "userdb update failed"))
+ | MsgSaChanged => (if Slave.shell [Config.SpamAssassin.postReload] then
+ Msg.send (bio, MsgOk)
+ else
+ Msg.send (bio, MsgError "Error reloading SpamAssassin addresses"))
| _ => (print "Dispatcher sent unexpected command\n";
Msg.send (bio, MsgError "Unexpected command"))
in
| MsgAptQuery {section, description} => (OpenSSL.writeInt (bio, 44);
OpenSSL.writeString (bio, section);
OpenSSL.writeString (bio, description))
+ | MsgSaChanged => OpenSSL.writeInt (bio, 45)
fun checkIt v =
case v of
| 44 => (case (OpenSSL.readString bio, OpenSSL.readString bio) of
(SOME section, SOME description) => SOME (MsgAptQuery {section = section, description = description})
| _ => NONE)
+ | 45 => SOME MsgSaChanged
| _ => NONE)
end
(* Response to MsgSaQuery *)
| MsgSaSet of string * bool
(* Set the filtering status of a user or e-mail address *)
+ | MsgSaChanged
+ (* Reload spamassassin addrs *)
| MsgSmtpLogReq of string
(* Request all current SMTP log lines about a domain *)
| MsgSmtpLogRes of string