fun change (email, old, new) =
let
- val cmd = String.concat ["/usr/bin/sudo /usr/local/bin/vmailpasswd \"",
- String.toString email,
- "\" \"",
- String.toString old,
- "\" \"",
- String.toString new,
- "\" >/dev/null 2>/dev/null"]
+ val [user, dom] = String.fields (fn ch => ch = #"@") email
+ val proc = Unix.executeInEnv ("/usr/local/sbin/domtool-portal", ["vmailpasswd", dom, user],
+ ["DOMTOOL_USER=hcoop.daemon"])
+ val out = Unix.textOutstreamOf proc
+
+ fun eatinput inf =
+ case TextIO.inputLine inf of
+ NONE => ()
+ | SOME line => eatinput inf
in
- OS.Process.isSuccess (OS.Process.system cmd)
+ TextIO.output (out, old ^ "\n");
+ TextIO.output (out, new ^ "\n");
+ TextIO.flushOut out;
+
+ eatinput (Unix.textInstreamOf proc);
+ TextIO.closeOut out;
+
+ OS.Process.isSuccess (Unix.reap proc)
end
end