Commit | Line | Data |
---|---|---|
0e0442b0 CE |
1 | (* HCoop Domtool (http://hcoop.sourceforge.net/) |
2 | * Copyright (c) 2014, Clinton Ebadi <clinton@unknownlamer.org> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation; either version 2 | |
7 | * of the License, or (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | *) | |
18 | ||
19 | (* Portal helper utility. *) | |
20 | ||
21 | (* Duplicated from main-config.sml, should be put into a common module | |
22 | and all domtool commands should return proper exit codes instead of | |
23 | always succeeding *) | |
24 | ||
25 | fun println x = (print x; print "\n") | |
26 | fun printerr x = (TextIO.output (TextIO.stdErr, x); TextIO.flushOut TextIO.stdErr) | |
27 | fun die reason = (printerr reason; printerr "\n"; OS.Process.exit OS.Process.failure) | |
28 | ||
29 | val _ = | |
30 | case CommandLine.arguments () of | |
31 | ["vmailpasswd", domain, user] => | |
f391f15c CE |
32 | if (Client.hastty ()) |
33 | then | |
34 | (case Client.getpass () of | |
35 | Client.Passwd oldpasswd => | |
36 | (case Client.getpass () of | |
37 | Client.Passwd newpasswd => | |
38 | Main.requestPortalPasswdMailbox {domain = domain, | |
39 | user = user, | |
40 | oldpasswd = oldpasswd, | |
41 | newpasswd = newpasswd} | |
42 | | Client.Aborted => die "Aborted" | |
43 | | Client.Error => die "New passwords did not match") | |
44 | | _ => die "Error entering old password") | |
45 | else | |
46 | let | |
47 | val oldpasswd = TextIO.inputLine TextIO.stdIn | |
48 | val newpasswd = TextIO.inputLine TextIO.stdIn | |
49 | in | |
50 | case (oldpasswd, newpasswd) of | |
51 | (SOME oldpasswd, SOME newpasswd) => | |
53043cda CE |
52 | OS.Process.exit (Main.requestPortalPasswdMailbox {domain = domain, |
53 | user = user, | |
54 | oldpasswd = String.substring (oldpasswd, 0, size oldpasswd - 1), | |
55 | newpasswd = String.substring (newpasswd, 0, size newpasswd - 1)}) | |
f391f15c CE |
56 | | _ => die "Invalid input" |
57 | end | |
0e0442b0 CE |
58 | | _ => die "Invalid command-line arguments" |
59 |