Mailman shortcut working
[hcoop/domtool2.git] / src / plugins / apache.sml
index 4e07e4e..f36bfa4 100644 (file)
@@ -22,12 +22,14 @@ structure Apache :> APACHE = struct
 
 open Ast
 
 
 open Ast
 
+fun webNode node =
+    List.exists (fn (x, _) => x = node) Config.Apache.webNodes_all
+    orelse (Domain.hasPriv "www"
+           andalso List.exists (fn (x, _) => x = node) Config.Apache.webNodes_admin)
+
 val _ = Env.type_one "web_node"
        Env.string
 val _ = Env.type_one "web_node"
        Env.string
-       (fn node =>
-           List.exists (fn (x, _) => x = node) Config.Apache.webNodes_all
-           orelse (Domain.hasPriv "www"
-                   andalso List.exists (fn (x, _) => x = node) Config.Apache.webNodes_admin))
+       webNode
 
 val _ = Env.registerFunction ("web_node_to_node",
                              fn [e] => SOME e
 
 val _ = Env.registerFunction ("web_node_to_node",
                              fn [e] => SOME e
@@ -256,10 +258,12 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                            file = #file spl}
 
                                                   val user = findVhostUser (#file fs)
                                                                            file = #file spl}
 
                                                   val user = findVhostUser (#file fs)
-                                                  val oldUser = findVhostUser realVhostFile
+                                                  val oldUser = case #action fs of
+                                                                    Slave.Delete false => user
+                                                                  | _ => findVhostUser realVhostFile
                                               in
                                                   if (oldUser = NONE andalso #action fs <> Slave.Add)
                                               in
                                                   if (oldUser = NONE andalso #action fs <> Slave.Add)
-                                                     orelse (user = NONE andalso #action fs <> Slave.Delete) then
+                                                     orelse (user = NONE andalso not (Slave.isDelete (#action fs))) then
                                                       print ("Can't find user in " ^ #file fs ^ " or " ^ realVhostFile ^ "!  Taking no action.\n")
                                                   else
                                                       let
                                                       print ("Can't find user in " ^ #file fs ^ " or " ^ realVhostFile ^ "!  Taking no action.\n")
                                                   else
                                                       let
@@ -281,7 +285,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                       in
                                                           vhostsChanged := true;
                                                           case #action fs of
                                                       in
                                                           vhostsChanged := true;
                                                           case #action fs of
-                                                              Slave.Delete =>
+                                                              Slave.Delete =>
                                                               let
                                                                   val ldir = realLogDir oldUser
                                                               in
                                                               let
                                                                   val ldir = realLogDir oldUser
                                                               in
@@ -379,6 +383,9 @@ fun registerPost f =
        post := (fn () => (old (); f ()))
     end
 
        post := (fn () => (old (); f ()))
     end
 
+fun doPre x = !pre x
+fun doPost () = !post ()
+
 val aliaser = ref (fn _ : string => ())
 fun registerAliaser f =
     let
 val aliaser = ref (fn _ : string => ())
 fun registerAliaser f =
     let