vmail interprets relative paths relatively to caller's home directory
authorAdam Chlipala <adamc@hcoop.net>
Sat, 27 Oct 2007 16:33:56 +0000 (16:33 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sat, 27 Oct 2007 16:33:56 +0000 (16:33 +0000)
src/domain.sml
src/main-vmail.sml
src/main.sml

index 01f7902..b2c0c5c 100644 (file)
@@ -1,5 +1,5 @@
 (* HCoop Domtool (http://hcoop.sourceforge.net/)
- * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2006-2007, Adam Chlipala
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
index 8acb845..2490d02 100644 (file)
@@ -35,10 +35,24 @@ val _ =
          | ["add", user, mailbox] =>
            (case Client.getpass () of
                 Client.Passwd passwd =>
-                Main.requestNewMailbox {domain = domain,
-                                        user = user,
-                                        passwd = passwd,
-                                        mailbox = mailbox}
+                let
+                    val mailbox = if size mailbox > 0
+                                     andalso String.sub (mailbox, 0) <> #"/" then
+                                      let
+                                          val uid = Posix.ProcEnv.getuid ()
+                                          val user = Posix.SysDB.getpwuid uid
+                                          val home = Posix.SysDB.Passwd.home user
+                                      in
+                                          home ^ "/" ^ mailbox
+                                      end
+                                  else
+                                      mailbox
+                in
+                    Main.requestNewMailbox {domain = domain,
+                                            user = user,
+                                            passwd = passwd,
+                                            mailbox = mailbox}
+                end
               | _ => ())
 
          | ["passwd", user] =>
index d57b867..8bec641 100644 (file)
@@ -1361,7 +1361,8 @@ fun service () =
                                               SOME "Invalid password; may only contain printable, non-space characters")
                                          else if not (Domain.yourPath mailbox) then
                                              ("User wasn't authorized to add a mailbox at " ^ mailbox,
-                                              SOME "You're not authorized to use that mailbox location.")
+                                              SOME ("You're not authorized to use that mailbox location. ("
+                                                    ^ mailbox ^ ")"))
                                          else
                                              case Vmail.add {requester = user,
                                                              domain = domain, user = emailUser,