(* HCoop Domtool (http://hcoop.sourceforge.net/)
- * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2006-2007, Adam Chlipala
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
fun requestContext f =
let
- val uid = Posix.ProcEnv.getuid ()
- val user = Posix.SysDB.Passwd.name (Posix.SysDB.getpwuid uid)
+ 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
val () = Acl.read Config.aclFile
val () = Domain.setUser user
handle IO.Io _ => ()
| OS.SysErr (s, _) => print ("System error processing user " ^ user ^ ": " ^ s ^ "\n")
| ErrorMsg.Error => print ("User " ^ user ^ " had a compilation error.\n")
+ | _ => print "Unknown exception during regeneration!\n"
in
app contactNode Config.nodeIps;
Env.pre ();
OpenSSL.close bio
handle OpenSSL.OpenSSL _ => ();
loop ())
+ | _ =>
+ (print "Unknown exception in main loop!\n";
+ OpenSSL.close bio
+ handle OpenSSL.OpenSSL _ => ();
+ loop ())
in
print ("Domtool dispatcher starting up at " ^ now () ^ "\n");
print "Listening for connections....\n";
OpenSSL.close bio
handle OpenSSL.OpenSSL _ => ();
loop ())
- | OS.SysErr (s, _) =>
- (print ("System error: "^ s ^ "\n");
+ | e as OS.SysErr (s, _) =>
+ (app (fn s => print (s ^ "\n")) (SMLofNJ.exnHistory e);
+ print ("System error: "^ s ^ "\n");
OpenSSL.close bio
handle OpenSSL.OpenSSL _ => ();
loop ())