fun requestMysqlFixperms () =
let
- val (_, bio) = requestBio (fn () => ())
+ val (_, context) = requestContext (fn () => ())
+ val bio = OpenSSL.connect true (context,
+ Config.Dbms.dbmsNode ^ ":" ^ Int.toString Config.slavePort)
in
Msg.send (bio, MsgMysqlFixperms);
case Msg.recv bio of
OpenSSL.close bio
end
+fun requestFirewallRegen node =
+ let
+ val (user, context) = requestContext (fn () => ())
+ val bio = OpenSSL.connect true (context, Domain.nodeIp node ^ ":" ^ Int.toString Config.slavePort)
+ (* Only supporting on slave nodes *)
+
+ val _ = Msg.send (bio, MsgFirewallRegen)
+
+ fun handleResult () =
+ case Msg.recv bio of
+ NONE => (print "Server closed connection unexpectedly.\n";
+ OS.Process.failure)
+ | SOME m =>
+ case m of
+ MsgOk => (print "Firewall regenerated.\n";
+ OS.Process.success)
+ | MsgError s => (print ("Firewall regeneration failed: " ^ s ^ "\n");
+ OS.Process.failure)
+ | _ => (print "Unexpected server reply.\n";
+ OS.Process.failure)
+ in
+ handleResult()
+ before OpenSSL.close bio
+ end
+
structure SS = StringSet
fun domainList dname =
(describeQuery q,
NONE)))
(fn () => ())
-
- | MsgMysqlFixperms =>
- (print "Starting mysql-fixperms\n";
- doIt (fn () => if OS.Process.isSuccess
- (OS.Process.system "/usr/bin/sudo -H /afs/hcoop.net/common/etc/scripts/mysql-grant-table-drop") then
- ("Requested mysql-fixperms",
- NONE)
- else
- ("Requested mysql-fixperms, but execution failed!",
- SOME "Script execution failed."))
- (fn () => ()))
-
| MsgDescribe dom =>
doIt (fn () => if not (Domain.validDomain dom) then
("Requested description of invalid domain " ^ dom,
("Invalid database name " ^ user ^ "_" ^ dbname,
SOME ("Invalid database name " ^ dbname)))
(fn () => ())
+ | MsgMysqlFixperms =>
+ (print "Starting mysql-fixperms\n";
+ doIt (fn () => if OS.Process.isSuccess
+ (OS.Process.system "/usr/bin/sudo -H /afs/hcoop.net/common/etc/scripts/mysql-grant-table-drop") then
+ ("Requested mysql-fixperms",
+ NONE)
+ else
+ ("Requested mysql-fixperms, but execution failed!",
+ SOME "Script execution failed."))
+ (fn () => ()))
+ | MsgFirewallRegen =>
+ doIt (fn () => if Acl.query {user = user, class = "priv", value = "all"} andalso List.exists (fn x => x = host) Config.Firewall.firewallNodes then
+ if (Firewall.generateFirewallConfig (Firewall.parseRules ()) andalso Firewall.publishConfig ())
+ then
+ ("Firewall rules regenerated.", NONE)
+ else
+ ("Rules regeneration failed!", SOME "Script execution failed.")
+ else
+ ("Not authorized to regenerate firewall.", SOME ("Unauthorized user " ^ user ^ "attempted to regenerated firewall")))
+ (fn () => ())
+
| _ => (OpenSSL.close bio;
loop ())
end