+fun setpassword {domain, user, passwd} =
+ let
+ val proc = Unix.execute ("/bin/sh", ["-c",
+ String.concat [Config.Vmail.userdbpw, " | ", Config.Vmail.userdb,
+ " -f ", Config.Vmail.userDatabase, "/", domain,
+ " \"", user, "@", domain, "\" set systempw"]])
+ val outf = Unix.textOutstreamOf proc
+ in
+ TextIO.output (outf, String.concat [passwd, "\n", passwd, "\n"]);
+ TextIO.closeOut outf;
+ OS.Process.isSuccess (Unix.reap proc)
+ end
+
+
+fun checkpassword {domain, user, passwd} =
+ let
+ val proc = Unix.execute (Config.installPrefix ^ "/sbin/domtool-vmailpasswd", [])
+ val outf = Unix.textOutstreamOf proc
+ val db = readUserdb domain
+ in
+ case SM.find (db, user) of
+ SOME fields =>
+ (case SM.find (fields, "systempw") of
+ SOME systempw =>
+ (TextIO.output (outf, systempw ^ "\n");
+ TextIO.output (outf, passwd ^ "\n");
+ TextIO.closeOut outf;
+ OS.Process.isSuccess (Unix.reap proc))
+ | NONE => raise Userdb ("systempw not found for user " ^ user ^ "@" ^ domain))
+ | NONE => raise Userdb ("User " ^ user ^ " not found in vmail userdb for domain " ^ domain)
+ end
+
+fun deluser {domain, user} =
+ Slave.run (Config.Vmail.userdb, ["-f", Config.Vmail.userDatabase ^ "/" ^ domain,
+ user ^ "@" ^ domain, "del"])
+