X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/36e42cb86393a7b9e333ecd7edfbdd16c7d9a1ac..976657583f419a6a204400ea90f9758d15243acb:/src/main.sml?ds=sidebyside diff --git a/src/main.sml b/src/main.sml index 734b10a..490f66d 100644 --- a/src/main.sml +++ b/src/main.sml @@ -53,7 +53,7 @@ fun basis () = loop files val files = loop [] - val files = Order.order files + val (_, files) = Order.order files in if !ErrorMsg.anyErrors then Env.empty @@ -138,10 +138,14 @@ fun request fname = val () = Acl.read Config.aclFile val () = Domain.setUser user + val _ = check fname + val uid = Posix.ProcEnv.getuid () + val user = Posix.SysDB.Passwd.name (Posix.SysDB.getpwuid uid) + val context = OpenSSL.context (Config.certDir ^ "/" ^ user ^ ".pem", - Config.keyDir ^ "/" ^ user ^ ".pem", + Config.keyDir ^ "/" ^ user ^ "/key.pem", Config.trustStore) val bio = OpenSSL.connect (context, dispatcher) @@ -208,21 +212,21 @@ fun service () = TextIO.closeOut outf; (eval outname; Msg.send (bio, MsgOk)) - handle ErrorMsg.Error => - (print "Compilation error\n"; - Msg.send (bio, - MsgError "Error during configuration evaluation")) - | OpenSSL.OpenSSL s => - (print "OpenSSL error\n"; - Msg.send (bio, - MsgError - ("Error during configuration evaluation: " - ^ s))); - OS.FileSys.remove outname; - (ignore (OpenSSL.readChar bio); - OpenSSL.close bio) - handle OpenSSL.OpenSSL _ => (); - loop () + handle ErrorMsg.Error => + (print "Compilation error\n"; + Msg.send (bio, + MsgError "Error during configuration evaluation")) + | OpenSSL.OpenSSL s => + (print "OpenSSL error\n"; + Msg.send (bio, + MsgError + ("Error during configuration evaluation: " + ^ s))); + OS.FileSys.remove outname; + (ignore (OpenSSL.readChar bio); + OpenSSL.close bio) + handle OpenSSL.OpenSSL _ => (); + loop () end | _ => (Msg.send (bio, MsgError "Unexpected command") @@ -233,7 +237,18 @@ fun service () = in cmdLoop () end + handle OpenSSL.OpenSSL s => + (print ("OpenSSL error: " ^ s ^ "\n"); + OpenSSL.close bio + handle OpenSSL.OpenSSL _ => (); + loop ()) + | OS.SysErr (s, _) => + (print ("System error: " ^ s ^ "\n"); + OpenSSL.close bio + handle OpenSSL.OpenSSL _ => (); + loop ()) in + print "Listening for connections....\n"; loop (); OpenSSL.shutdown sock end @@ -243,7 +258,7 @@ fun slave () = val host = hostname () val context = OpenSSL.context (Config.certDir ^ "/" ^ host ^ ".pem", - Config.keyDir ^ "/" ^ host ^ ".pem", + Config.keyDir ^ "/" ^ host ^ "/key.pem", Config.trustStore) val sock = OpenSSL.listen (context, Config.slavePort) @@ -277,10 +292,40 @@ fun slave () = OpenSSL.close bio; loop () end - end + end handle OpenSSL.OpenSSL s => + (print ("OpenSSL error: "^ s ^ "\n"); + OpenSSL.close bio + handle OpenSSL.OpenSSL _ => (); + loop ()) + | OS.SysErr (s, _) => + (print ("System error: "^ s ^ "\n"); + OpenSSL.close bio + handle OpenSSL.OpenSSL _ => (); + loop ()) in loop (); OpenSSL.shutdown sock end +fun autodocBasis outdir = + let + val dir = Posix.FileSys.opendir Config.libRoot + + fun loop files = + case Posix.FileSys.readdir dir of + NONE => (Posix.FileSys.closedir dir; + files) + | SOME fname => + if String.isSuffix ".dtl" fname then + loop (OS.Path.joinDirFile {dir = Config.libRoot, + file = fname} + :: files) + else + loop files + + val files = loop [] + in + Autodoc.autodoc {outdir = outdir, infiles = files} + end + end