(* HCoop Domtool (http://hcoop.sourceforge.net/) * Copyright (c) 2014, Clinton Ebadi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) (* Portal helper utility. *) (* Duplicated from main-config.sml, should be put into a common module and all domtool commands should return proper exit codes instead of always succeeding *) fun println x = (print x; print "\n") fun printerr x = (TextIO.output (TextIO.stdErr, x); TextIO.flushOut TextIO.stdErr) fun die reason = (printerr reason; printerr "\n"; OS.Process.exit OS.Process.failure) val _ = case CommandLine.arguments () of ["vmailpasswd", domain, user] => if (Client.hastty ()) then (case Client.getpass () of Client.Passwd oldpasswd => (case Client.getpass () of Client.Passwd newpasswd => Main.requestPortalPasswdMailbox {domain = domain, user = user, oldpasswd = oldpasswd, newpasswd = newpasswd} | Client.Aborted => die "Aborted" | Client.Error => die "New passwords did not match") | _ => die "Error entering old password") else let val oldpasswd = TextIO.inputLine TextIO.stdIn val newpasswd = TextIO.inputLine TextIO.stdIn in case (oldpasswd, newpasswd) of (SOME oldpasswd, SOME newpasswd) => OS.Process.exit (Main.requestPortalPasswdMailbox {domain = domain, user = user, oldpasswd = String.substring (oldpasswd, 0, size oldpasswd - 1), newpasswd = String.substring (newpasswd, 0, size newpasswd - 1)}) | _ => die "Invalid input" end | _ => die "Invalid command-line arguments"