fun context x =
(OpenSSL.context false x)
- handle e as OpenSSL.OpenSSL _ =>
+ handle e as OpenSSL.OpenSSL s =>
(print "Couldn't find your certificate.\nYou probably haven't been given any Domtool privileges.\n";
+ print ("Additional information: " ^ s ^ "\n");
raise e)
-fun requestContext f =
+fun setupUser () =
let
val user =
case Posix.ProcEnv.getenv "DOMTOOL_USER" of
Posix.SysDB.Passwd.name (Posix.SysDB.getpwuid uid)
end
| SOME user => user
-
- val () = Acl.read Config.aclFile
- val () = Domain.setUser user
+ in
+ Acl.read Config.aclFile;
+ Domain.setUser user;
+ user
+ end
+
+fun requestContext f =
+ let
+ val user = setupUser ()
val () = f ()
fun requestDir dname =
let
+ val _ = if Posix.FileSys.access (dname, []) then
+ ()
+ else
+ (print ("Can't access " ^ dname ^ ".\n");
+ print "Did you mean to run domtool on a specific file, instead of asking for all\n";
+ print "files in your ~/domtool directory?\n";
+ OS.Process.exit OS.Process.failure)
+
val _ = ErrorMsg.reset ()
val (user, bio) = requestBio (fn () => checkDir dname)
| _ => print ("Slave " ^ node
^ " returned unexpected command\n");
OpenSSL.close bio
- end
+ end
+ handle OpenSSL.OpenSSL s => print ("OpenSSL error: " ^ s ^ "\n")
fun doUser user =
let
(print msgLocal;
print "\n";
Msg.send (bio, MsgOk)))
- handle OpenSSL.OpenSSL _ =>
- print "OpenSSL error\n"
+ handle e as (OpenSSL.OpenSSL s) =>
+ (print ("OpenSSL error: " ^ s ^ "\n");
+ app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory e);
+ Msg.send (bio, MsgError ("OpenSSL error: " ^ s))
+ handle OpenSSL.OpenSSL _ => ())
| OS.SysErr (s, _) =>
(print "System error: ";
print s;
in
cmdLoop ()
end
- handle OpenSSL.OpenSSL s =>
+ handle e as (OpenSSL.OpenSSL s) =>
(print ("OpenSSL error: " ^ s ^ "\n");
+ app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory e);
OpenSSL.close bio
handle OpenSSL.OpenSSL _ => ();
loop ())