X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/75585a67831244a20e460b7336d440d4cabe3b41..a95a01077068e27009d4240aa0fc0c8f58908c6b:/src/main.sml diff --git a/src/main.sml b/src/main.sml index 0ddc508..19fe40c 100644 --- a/src/main.sml +++ b/src/main.sml @@ -606,9 +606,13 @@ fun requestSmtpLog domain = fun requestApt {node, pkg} = let - val (_, bio) = requestBio (fn () => ()) + val (user, context) = requestContext (fn () => ()) + val bio = OpenSSL.connect (context, if node = Config.masterNode then + dispatcher + else + Domain.nodeIp node ^ ":" ^ Int.toString Config.slavePort) - val _ = Msg.send (bio, MsgApt pkg) + val _ = Msg.send (bio, MsgQuery (QApt pkg)) fun loop () = case Msg.recv bio of @@ -712,6 +716,14 @@ fun rmuser user = fun now () = Date.toString (Date.fromTimeUniv (Time.now ())) +fun answerQuery q = + case q of + QApt pkg => if Apt.installed pkg then MsgYes else MsgNo + +fun describeQuery q = + case q of + QApt pkg => "Requested installation status of package " ^ pkg + fun service () = let val () = Acl.read Config.aclFile @@ -1055,12 +1067,9 @@ fun service () = NONE))) (fn () => ()) - | MsgApt pkg => - doIt (fn () => (Msg.send (bio, if Apt.installed pkg then - MsgYes - else - MsgNo); - ("User requested installation status of package " ^ pkg, + | MsgQuery q => + doIt (fn () => (Msg.send (bio, answerQuery q); + (describeQuery q, NONE))) (fn () => ()) @@ -1134,9 +1143,14 @@ fun slave () = | _ => (OpenSSL.close bio; loop ()) else - (print "Not authorized!\n"; - OpenSSL.close bio; - loop ()) + case Msg.recv bio of + SOME (MsgQuery q) => (print (describeQuery q ^ "\n"); + Msg.send (bio, answerQuery q); + ignore (OpenSSL.readChar bio); + OpenSSL.close bio; + loop ()) + | _ => (OpenSSL.close bio; + loop ()) end handle OpenSSL.OpenSSL s => (print ("OpenSSL error: "^ s ^ "\n"); OpenSSL.close bio