portal: return success/failure of changing vmail password
authorClinton Ebadi <clinton@unknownlamer.org>
Tue, 7 Oct 2014 03:17:40 +0000 (23:17 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Tue, 7 Oct 2014 03:17:40 +0000 (23:17 -0400)
I hear it's useful to tell the difference between failure and success.

src/main-portal.sml
src/main.sig
src/main.sml

index 068d16c..bed2064 100644 (file)
@@ -49,10 +49,10 @@ val _ =
            in
                case (oldpasswd, newpasswd) of
                    (SOME oldpasswd, SOME newpasswd) => 
-                   Main.requestPortalPasswdMailbox {domain = domain,
-                                                    user = user,
-                                                    oldpasswd = String.substring (oldpasswd, 0, size oldpasswd - 1),
-                                                    newpasswd = String.substring (newpasswd, 0, size newpasswd - 2)}
+                   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"
index fa4d398..bea8247 100644 (file)
@@ -69,7 +69,7 @@ signature MAIN = sig
     val requestPasswdMailbox : {domain : string, user : string, passwd : string}
                               -> unit
     val requestPortalPasswdMailbox : {domain : string, user : string, oldpasswd : string, newpasswd : string}
-                                    -> unit
+                                    -> OS.Process.status
     val requestRmMailbox : {domain : string, user : string} -> unit
 
     val requestSaQuery : string -> unit
index 475d1aa..fcbcafe 100644 (file)
@@ -672,16 +672,17 @@ fun requestPortalPasswdMailbox p =
     let
        val (_, bio) = requestBio (fn () => ())
     in
-       Msg.send (bio, MsgPortalPasswdMailbox p);
-       case Msg.recv bio of
-           NONE => print "Server closed connection unexpectedly.\n"
-         | SOME m =>
-           case m of
-               MsgOk => print ("The password for " ^ #user p ^ "@" ^ #domain p ^ " has been changed.\n")
-             | MsgError s => print ("Set failed: " ^ s ^ "\n")
-             | _ => print "Unexpected server reply.\n";
-       OpenSSL.close bio
-    end
+       (Msg.send (bio, MsgPortalPasswdMailbox p);
+        case Msg.recv bio of
+            NONE => (print "Server closed connection unexpectedly.\n"; OS.Process.failure)
+          | SOME m =>
+            case m of
+                MsgOk => (print ("The password for " ^ #user p ^ "@" ^ #domain p ^ " has been changed.\n");
+                          OS.Process.success)
+              | MsgError s => (print ("Set failed: " ^ s ^ "\n"); OS.Process.failure)
+              | _ => (print "Unexpected server reply.\n"; OS.Process.failure))
+       before OpenSSL.close bio
+    end 
 
 fun requestRmMailbox p =
     let