Adding Apache SetEnv
[hcoop/domtool2.git] / src / domain.sml
index ea3d70a..c097128 100644 (file)
@@ -114,10 +114,10 @@ val validGroup = validUser
 
 val _ = Env.type_one "no_spaces"
                     Env.string
-                    (CharVector.all (fn ch => not (Char.isSpace ch)))
+                    (CharVector.all (fn ch => not (Char.isSpace ch) andalso ch <> #"\"" andalso ch <> #"'"))
 val _ = Env.type_one "no_newlines"
                     Env.string
-                    (CharVector.all (fn ch => ch <> #"\n" andalso ch <> #"\r"))
+                    (CharVector.all (fn ch => ch <> #"\n" andalso ch <> #"\r" andalso ch <> #"\"" andalso ch <> #"'"))
 
 val _ = Env.type_one "ip"
        Env.string
@@ -538,7 +538,7 @@ val _ = Env.containerV_one "domain"
                                           close ()
                                       end
 
-                                  fun saveNamed (kind, soa : soa, masterIp) node =
+                                  fun saveNamed (kind, soa : soa, masterIp, slaveIps) node =
                                       if dom = "localhost" then
                                           ()
                                       else let
@@ -546,7 +546,7 @@ val _ = Env.containerV_one "domain"
                                           in
                                               write "\nzone \"";
                                               writeDom ();
-                                              write "\" IN {\n\ttype ";
+                                              write "\" {\n\ttype ";
                                               write kind;
                                               write ";\n\tfile \"";
                                               write Config.Bind.zonePath_real;
@@ -554,7 +554,11 @@ val _ = Env.containerV_one "domain"
                                               writeDom ();
                                               write ".zone\";\n";
                                               case kind of
-                                                  "master" => write "\tallow-update { none; };\n"
+                                                  "master" => (write "\tallow-transfer {\n";
+                                                               app (fn ip => (write "\t\t";
+                                                                              write ip;
+                                                                              write ";\n")) slaveIps;
+                                                               write "\t};\n")
                                                 | _ => (write "\tmasters { ";
                                                         write masterIp;
                                                         write "; };\n");
@@ -568,19 +572,21 @@ val _ = Env.containerV_one "domain"
                                       let
                                           val masterIp =
                                               case #master dns of
-                                                  InternalMaster node => valOf (SM.find (nodeMap, node))
+                                                  InternalMaster node => nodeIp node
                                                 | ExternalMaster ip => ip
+
+                                          val slaveIps = map nodeIp (#slaves dns)
                                       in
                                           app (saveSoa ("slave", #soa dns)) (#slaves dns);
-                                          app (saveNamed ("slave", #soa dns, masterIp)) (#slaves dns);
+                                          app (saveNamed ("slave", #soa dns, masterIp, slaveIps)) (#slaves dns);
                                           case #master dns of
                                               InternalMaster node =>
                                               (masterNode := SOME node;
                                                saveSoa ("master", #soa dns) node;
-                                               saveNamed ("master", #soa dns, masterIp) node)
-                                            | _ => masterNode := NONE;
-                                          !befores dom
-                                      end
+                                               saveNamed ("master", #soa dns, masterIp, slaveIps) node)
+                                            | _ => masterNode := NONE
+                                      end;
+                                  !befores dom
                               end,
                            fn () => !afters (!current))