X-Git-Url: http://git.hcoop.net/hcoop/portal.git/blobdiff_plain/393a4193615314958a9550fe2d57d67fcad27f40..588a1662c076994dc4321f86da2619933b3a1e13:/vmailpasswd/pass.sml diff --git a/vmailpasswd/pass.sml b/vmailpasswd/pass.sml index c78c84b..30aef24 100644 --- a/vmailpasswd/pass.sml +++ b/vmailpasswd/pass.sml @@ -6,19 +6,26 @@ fun validEmail email = [_, dom] => dom <> "localhost" | _ => false -val vmp = "/usr/local/bin/vmailpasswd" - fun change (email, old, new) = let - val cmd = String.concat ["/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