| SOME m =>
case m of
MsgDescription s => print s
- | MsgError s => print ("Describe failed: " ^ s ^ "\n")
+ | MsgError s => print ("Description failed: " ^ s ^ "\n")
| _ => print "Unexpected server reply.\n";
OpenSSL.close bio
end
+structure SS = StringSet
+
+fun domainList dname =
+ let
+ val dir = Posix.FileSys.opendir dname
+
+ fun visitNode dset =
+ case Posix.FileSys.readdir dir of
+ NONE => dset
+ | SOME node =>
+ let
+ val path = OS.Path.joinDirFile {dir = dname,
+ file = node}
+
+ fun visitDomains (path, bfor, dset) =
+ let
+ val dir = Posix.FileSys.opendir path
+
+ fun loop dset =
+ case Posix.FileSys.readdir dir of
+ NONE => dset
+ | SOME dname =>
+ let
+ val path = OS.Path.joinDirFile {dir = path,
+ file = dname}
+ in
+ if Posix.FileSys.ST.isDir (Posix.FileSys.stat path) then
+ let
+ val bfor = dname :: bfor
+ in
+ loop (visitDomains (path, bfor,
+ SS.add (dset,
+ String.concatWith "." bfor)))
+ end
+ else
+ loop dset
+ end
+ in
+ loop dset
+ before Posix.FileSys.closedir dir
+ end
+ in
+ visitNode (visitDomains (path, [], dset))
+ end
+ in
+ visitNode SS.empty
+ before Posix.FileSys.closedir dir
+ end
+
fun regenerateEither tc checker context =
let
+ val domainsBefore = domainList Config.resultRoot
+
fun ifReal f =
if tc then
()
val b = basis ()
val () = Tycheck.disallowExterns ()
- val () = ifReal Domain.resetGlobal
+ val () = ifReal (fn () =>
+ (ignore (OS.Process.system ("rm -rf " ^ Config.oldResultRoot ^ "/*"));
+ ignore (OS.Process.system ("cp -r " ^ Config.resultRoot
+ ^ "/* " ^ Config.oldResultRoot ^ "/"));
+ Domain.resetGlobal ()))
val ok = ref true
in
if !ErrorMsg.anyErrors then
(ErrorMsg.reset ();
- print ("User " ^ user ^ "'s configuration has errors!\n"))
+ print ("User " ^ user ^ "'s configuration has errors!\n");
+ ok := false)
else
app checker files
end
ifReal (fn () => (app contactNode Config.nodeIps;
Env.pre ()));
app doUser (Acl.users ());
- ifReal Env.post;
+ ifReal (fn () =>
+ let
+ val domainsAfter = domainList Config.resultRoot
+ val domainsGone = SS.difference (domainsBefore, domainsAfter)
+ in
+ if SS.isEmpty domainsGone then
+ ()
+ else
+ (print "Domains to kill:";
+ SS.app (fn s => (print " "; print s)) domainsGone;
+ print "\n";
+
+ Domain.rmdom' Config.oldResultRoot (SS.listItems domainsGone));
+
+ Env.post ()
+ end);
!ok
end
(fn () => ())
| MsgDescribe dom =>
- doIt (fn () => (if Domain.validDomain dom then
- (Msg.send (bio, MsgDescription (Domain.describe dom));
- ("Requested description of domain " ^ dom,
- NONE))
- else
- ("Requested description of invalid domain " ^ dom,
- SOME "Invalid domain name")))
+ doIt (fn () => if not (Domain.validDomain dom) then
+ ("Requested description of invalid domain " ^ dom,
+ SOME "Invalid domain name")
+ else if not (Domain.yourDomain dom
+ orelse Acl.query {user = user, class = "priv", value = "all"}) then
+ ("Requested description of " ^ dom ^ ", but not allowed access",
+ SOME "Access denied")
+ else
+ (Msg.send (bio, MsgDescription (Domain.describe dom));
+ ("Sent description of domain " ^ dom,
+ NONE)))
(fn () => ())
| _ =>