vmailpasswd
authorAdam Chlipala <adamc@hcoop.net>
Tue, 25 Oct 2005 16:59:34 +0000 (16:59 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 25 Oct 2005 16:59:34 +0000 (16:59 +0000)
vmailpasswd/.cvsignore [new file with mode: 0644]
vmailpasswd/mlt.conf [new file with mode: 0644]
vmailpasswd/pass.sig [new file with mode: 0644]
vmailpasswd/pass.sml [new file with mode: 0644]
vmailpasswd/passwd.mlt [new file with mode: 0644]

diff --git a/vmailpasswd/.cvsignore b/vmailpasswd/.cvsignore
new file mode 100644 (file)
index 0000000..694c56c
--- /dev/null
@@ -0,0 +1 @@
+.cm
\ No newline at end of file
diff --git a/vmailpasswd/mlt.conf b/vmailpasswd/mlt.conf
new file mode 100644 (file)
index 0000000..ec2f7f8
--- /dev/null
@@ -0,0 +1,4 @@
+out    out
+pub    /home/hcoop/members/cgi
+
+cm     $/smlnj-lib.cm
diff --git a/vmailpasswd/pass.sig b/vmailpasswd/pass.sig
new file mode 100644 (file)
index 0000000..e1a0162
--- /dev/null
@@ -0,0 +1,5 @@
+signature PASS =
+sig
+    val validEmail : string -> bool
+    val change : string * string * string -> bool
+end
diff --git a/vmailpasswd/pass.sml b/vmailpasswd/pass.sml
new file mode 100644 (file)
index 0000000..c78c84b
--- /dev/null
@@ -0,0 +1,24 @@
+structure Pass :> PASS =
+struct
+
+fun validEmail email =
+    case String.fields (fn ch => ch = #"@") email of
+       [_, 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"]
+    in
+       OS.Process.isSuccess (OS.Process.system cmd)
+    end
+
+end
diff --git a/vmailpasswd/passwd.mlt b/vmailpasswd/passwd.mlt
new file mode 100644 (file)
index 0000000..a1c6aba
--- /dev/null
@@ -0,0 +1,36 @@
+<html><head>
+<title>Change virtual mailbox password</title>
+</head><body>
+
+<% if $"email" <> "" then
+       val email = $"email"
+       val old = $"old"
+       val new = $"new"
+       val new2 = $"new2"
+
+       if not (Pass.validEmail email) then
+               %><h2><b>That is not a valid virtual mailbox address!</b></h2><%
+       elseif new <> new2 then
+               %><h2><b>Your new passwords do not match.</b></h2><%
+       elseif not (Pass.change (email, old, new)) then
+               %><h2><b>Error changing password.  Did you enter the right e-mail address and current password?</b></h2><%
+       else
+               %><h2><b>Password changed!</b></h2><%
+       end
+end %>
+
+<h2><b>Change virtual mailbox password</b></h2>
+
+<form action="passwd" method="post">
+
+<table>
+<tr> <td align="right"><b>E-mail address</b>:</td> <td><input name="email" value="<% Web.html ($"email") %>"></td> </tr>
+<tr> <td align="right"><b>Old password</b>:</td> <td><input type="password" name="old"></td> </tr>
+<tr> <td align="right"><b>New password</b>:</td> <td><input type="password" name="new"></td> </tr>
+<tr> <td align="right"><b>Confirm new password</b>:</td> <td><input type="password" name="new2"></td> </tr>
+<tr> <td><input type="submit" value="Change"></td> </tr>
+</table>
+
+</form>
+
+</body></html>
\ No newline at end of file