Changes to support IMAP on hopper all compile but are not tested yet
authorAdam Chlipala <adamc@hcoop.net>
Sun, 27 Sep 2009 19:07:34 +0000 (19:07 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sun, 27 Sep 2009 19:07:34 +0000 (19:07 +0000)
12 files changed:
configDefault/courier.cfg
configDefault/courier.csg
configDefault/domtool.cfg
configDefault/exim.cfg
configDefault/mailman.cfg
src/domain.sig
src/domain.sml
src/mail/vmail.sig
src/mail/vmail.sml
src/main.sml
src/msg.sml
src/msgTypes.sml

index 09b6607..6e28db8 100644 (file)
@@ -15,4 +15,7 @@ val postReload = "/usr/bin/sudo /usr/local/sbin/domtool-publish courier"
 val logFile = "/var/log/exim4/mainlog"
 (* SMTP log *)
 
+val pushUserdb = "/usr/bin/rsync -r --delete /etc/courier/userdb /afs/hcoop.net/common/etc/domtool/email/userdb"
+val pullUserdb = "/usr/bin/rsync -r --delete /afs/hcoop.net/common/etc/domtool/email/userdb /etc/courier/userdb"
+
 end
index b1f544d..15b382e 100644 (file)
@@ -10,5 +10,8 @@ signature COURIER_CONFIG = sig
     val postReload : string
                     
     val logFile : string
+
+    val pushUserdb : string
+    val pullUserdb : string
                  
 end
index 906d7f4..61ac39f 100644 (file)
@@ -19,16 +19,16 @@ val defaultRetry = 1800
 val defaultExpiry = 1209600
 val defaultMinimum = 3600
 
-val nodeIps = [("deleuze", "69.90.123.67"), ("mire", "69.90.123.68"), ("outpost", "89.16.166.179")]
+val nodeIps = [("deleuze", "69.90.123.67"), ("mire", "69.90.123.68"), ("outpost", "89.16.166.179"), ("hopper", "69.90.123.74")]
 val defaultNode = "deleuze"
 
 val masterNode = "deleuze"
-val slaveNodes = ["mire", "outpost"]
+val slaveNodes = ["mire", "outpost", "hopper"]
 
 val dnsNodes_all = ["deleuze", "mire", "outpost"]
 val dnsNodes_admin = []
 
-val mailNodes_all = ["deleuze"]
+val mailNodes_all = ["deleuze", "hopper"]
 val mailNodes_admin = ["mire", "outpost"]
 
 val aclFile = "/afs/hcoop.net/common/etc/domtool/acl"
index a1ef37a..6118466 100644 (file)
@@ -7,7 +7,7 @@ val relayDomains = "/var/domtool/relay_domains.cfg"
 
 val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish exim"
 
-val aliasTo = ["deleuze"]
+val aliasTo = ["deleuze", "hopper"]
 
 val mainLog = "/var/log/exim4/mainlog"
 
index 090de39..5407b6d 100644 (file)
@@ -1,6 +1,6 @@
 structure Mailman :> MAILMAN_CONFIG = struct
 
-val node = "deleuze"
+val node = "hopper"
 
 val mapFile = "/var/domtool/mailman.map"
 val handleDomains = "/var/domtool/mailman_domains.cfg"
index 8d10fe0..9383a8e 100644 (file)
@@ -90,6 +90,7 @@ signature DOMAIN = sig
     val your_paths : unit -> DataStructures.StringSet.set
     (* UNIX users, groups, and paths the user may act with *)
 
+    val get_context : unit -> OpenSSL.context
     val set_context : OpenSSL.context -> unit
 
     val hasPriv : string -> bool
index ffa03c4..cdc3580 100644 (file)
@@ -27,6 +27,7 @@ structure SS = DataStructures.StringSet
 
 val ssl_context = ref (NONE : OpenSSL.context option)
 fun set_context ctx = ssl_context := SOME ctx
+fun get_context () = valOf (!ssl_context)
 
 val nodes = map #1 Config.nodeIps
 val nodeMap = foldl (fn ((node, ip), mp) => SM.insert (mp, node, ip))
index 4804911..4defa43 100644 (file)
@@ -38,6 +38,6 @@ signature VMAIL = sig
 
     val rm : {domain : string, user : string} -> string option
 
-
+    val doChanged : unit -> bool
 
 end
index cf36f9f..1d5262d 100644 (file)
@@ -1,5 +1,5 @@
 (* HCoop Domtool (http://hcoop.sourceforge.net/)
- * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2006-2009, Adam Chlipala
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 
 structure Vmail :> VMAIL = struct
 
-fun rebuild () = Slave.shell [Config.Courier.postReload]
+open MsgTypes
+
+fun rebuild () =
+    let
+       fun doNode (site, ok) =
+           (print ("New vmail data for node " ^ site ^ "\n");
+            if site = Config.defaultNode then
+                Slave.shell [Config.Courier.postReload] andalso ok
+            else let
+                    val bio = OpenSSL.connect true (Domain.get_context (),
+                                                    Domain.nodeIp site
+                                                    ^ ":"
+                                                    ^ Int.toString Config.slavePort)
+                in
+                    Msg.send (bio, MsgVmailChanged);
+                    (case Msg.recv bio of
+                         NONE => (print "Slave closed connection unexpectedly\n";
+                                  false)
+                       | SOME m =>
+                         case m of
+                             MsgOk => (print ("Slave " ^ site ^ " finished\n");
+                                       ok)
+                           | MsgError s => (print ("Slave " ^ site
+                                                   ^ " returned error: " ^
+                                                   s ^ "\n");
+                                            false)
+                           | _ => (print ("Slave " ^ site
+                                          ^ " returned unexpected command\n");
+                                   false))
+                    before OpenSSL.close bio
+                end)
+    in
+       Slave.shell [Config.Courier.pushUserdb]
+       andalso foldl doNode true Config.mailNodes_all
+    end
+
+fun doChanged () =
+    Slave.shell [Config.Courier.pullUserdb]
+    andalso Slave.shell [Config.Courier.postReload]
 
 datatype listing =
         Error of string
@@ -29,7 +67,7 @@ datatype listing =
 fun list domain =
     let
        val file = OS.Path.joinDirFile {dir = Config.Courier.userdbDir,
-                                                     file = domain}
+                                       file = domain}
     in
        if Posix.FileSys.access (file, []) then
            let
index be4191b..d46deac 100644 (file)
@@ -1701,6 +1701,10 @@ fun slave () =
                                                        Msg.send (bio, MsgOk))
                                       | MsgRegenerate => (Domain.resetLocal ();
                                                           Msg.send (bio, MsgOk))
+                                      | MsgVmailChanged => (if Vmail.doChanged () then
+                                                                Msg.send (bio, MsgOk)
+                                                            else
+                                                                Msg.send (bio, MsgError "userdb update failed"))
                                       | _ => (print "Dispatcher sent unexpected command\n";
                                               Msg.send (bio, MsgError "Unexpected command"))
                         in
index 3e028c1..a745f5c 100644 (file)
@@ -237,6 +237,7 @@ fun send (bio, m) =
       | MsgDescription s => (OpenSSL.writeInt (bio, 40);
                             OpenSSL.writeString (bio, s))
       | MsgReUsers => OpenSSL.writeInt (bio, 41)
+      | MsgVmailChanged => OpenSSL.writeInt (bio, 42)
 
 fun checkIt v =
     case v of
@@ -350,6 +351,7 @@ fun recv bio =
                   | 39 => Option.map MsgDescribe (OpenSSL.readString bio)
                   | 40 => Option.map MsgDescription (OpenSSL.readString bio)
                   | 41 => SOME MsgReUsers
+                  | 42 => SOME MsgVmailChanged
                   | _ => NONE)
         
 end
index ea3ea2c..45646a6 100644 (file)
@@ -126,5 +126,7 @@ datatype msg =
        (* Reply to MsgDescribe *)
        | MsgReUsers
        (* Rerun all callbacks for cases where the set of users has changed *)
+       | MsgVmailChanged
+       (* Server tells slave that vmail user information has changed *)
 
 end