X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/95a9abd13a15eeb97c4bc925b74bc24b0612d244..d22c1f00ed619c221dc9891c86c5ced202a9ee77:/src/main.sml diff --git a/src/main.sml b/src/main.sml index b6b6d24..e106823 100644 --- a/src/main.sml +++ b/src/main.sml @@ -1,5 +1,5 @@ (* 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 @@ -170,6 +170,12 @@ val dispatcher = val self = "localhost:" ^ Int.toString Config.slavePort +fun context x = + (OpenSSL.context false x) + handle e as OpenSSL.OpenSSL _ => + (print "Couldn't find your certificate.\nYou probably haven't been given any Domtool privileges.\n"; + raise e) + fun requestContext f = let val user = @@ -187,9 +193,9 @@ fun requestContext f = val () = f () - val context = OpenSSL.context (Config.certDir ^ "/" ^ user ^ ".pem", - Config.keyDir ^ "/" ^ user ^ "/key.pem", - Config.trustStore) + val context = context (Config.certDir ^ "/" ^ user ^ ".pem", + Config.keyDir ^ "/" ^ user ^ "/key.pem", + Config.trustStore) in (user, context) end @@ -787,7 +793,13 @@ fun requestFirewall {node, uname} = fun regenerate context = let + val _ = ErrorMsg.reset () + val b = basis () + val _ = if Env.lookupType b "string" then + print "Still got it\n" + else + print "Don't got it\n" val () = Tycheck.disallowExterns () val () = Domain.resetGlobal () @@ -891,9 +903,9 @@ fun service () = let val () = Acl.read Config.aclFile - val context = OpenSSL.context (Config.serverCert, - Config.serverKey, - Config.trustStore) + val context = context (Config.serverCert, + Config.serverKey, + Config.trustStore) val _ = Domain.set_context context val sock = OpenSSL.listen (context, Config.dispatcherPort) @@ -1253,8 +1265,15 @@ fun service () = OpenSSL.close bio handle OpenSSL.OpenSSL _ => (); loop ()) - | _ => + | IO.Io {name, function, cause} => + (print ("IO error: " ^ function ^ " for " ^ name ^ "\n"); + app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory cause); + OpenSSL.close bio + handle OpenSSL.OpenSSL _ => (); + loop ()) + | e => (print "Unknown exception in main loop!\n"; + app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory e); OpenSSL.close bio handle OpenSSL.OpenSSL _ => (); loop ()) @@ -1269,9 +1288,9 @@ fun slave () = let val host = Slave.hostname () - val context = OpenSSL.context (Config.certDir ^ "/" ^ host ^ ".pem", - Config.keyDir ^ "/" ^ host ^ "/key.pem", - Config.trustStore) + val context = context (Config.certDir ^ "/" ^ host ^ ".pem", + Config.keyDir ^ "/" ^ host ^ "/key.pem", + Config.trustStore) val sock = OpenSSL.listen (context, Config.slavePort)