String.sub (s, 0) <> #"."
andalso CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"." orelse ch = #"_" orelse ch = #"-") s
-fun checkDir dname =
+fun setupUser () =
+ let
+ val user =
+ case Posix.ProcEnv.getenv "DOMTOOL_USER" of
+ NONE =>
+ let
+ val uid = Posix.ProcEnv.getuid ()
+ in
+ Posix.SysDB.Passwd.name (Posix.SysDB.getpwuid uid)
+ end
+ | SOME user => user
+ in
+ Acl.read Config.aclFile;
+ Domain.setUser user;
+ user
+ end
+
+fun checkDir' dname =
let
val b = basis ()
())
end
+fun checkDir dname =
+ (setupUser ();
+ checkDir' dname)
+
fun reduce fname =
let
val (G, body) = check fname
print ("Additional information: " ^ s ^ "\n");
raise e)
-fun setupUser () =
- let
- val user =
- case Posix.ProcEnv.getenv "DOMTOOL_USER" of
- NONE =>
- let
- val uid = Posix.ProcEnv.getuid ()
- in
- Posix.SysDB.Passwd.name (Posix.SysDB.getpwuid uid)
- end
- | SOME user => user
- in
- Acl.read Config.aclFile;
- Domain.setUser user;
- user
- end
-
fun requestContext f =
let
val user = setupUser ()
val _ = ErrorMsg.reset ()
- val (user, bio) = requestBio (fn () => checkDir dname)
+ val (user, bio) = requestBio (fn () => checkDir' dname)
val b = basis ()
before OpenSSL.close bio
end
+fun requestDescribe dom =
+ let
+ val (_, bio) = requestBio (fn () => ())
+ in
+ Msg.send (bio, MsgDescribe dom);
+ case Msg.recv bio of
+ NONE => print "Server closed connection unexpectedly.\n"
+ | SOME m =>
+ case m of
+ MsgDescription s => print s
+ | MsgError s => print ("Description failed: " ^ s ^ "\n")
+ | _ => print "Unexpected server reply.\n";
+ OpenSSL.close bio
+ end
+
fun regenerateEither tc checker context =
let
fun ifReal f =
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
SOME "Script execution failed."))
(fn () => ())
+ | MsgDescribe dom =>
+ 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 () => ())
+
| _ =>
doIt (fn () => ("Unexpected command",
SOME "Unexpected command"))
OpenSSL.close bio
handle OpenSSL.OpenSSL _ => ();
loop ())
+ | OS.Path.InvalidArc =>
+ (print "Invalid arc\n";
+ OpenSSL.close bio
+ handle OpenSSL.OpenSSL _ => ();
+ loop ())
| e =>
(print "Unknown exception in main loop!\n";
app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory e);