From: Adam Chlipala Date: Sun, 4 Nov 2007 21:21:15 +0000 (+0000) Subject: Putzing around with vmail X-Git-Tag: release_2010-11-19~167 X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/commitdiff_plain/dee1a22babf7a1eb1c938f716dc37ced3abfd4e4?ds=sidebyside Putzing around with vmail --- diff --git a/scripts/domtool-publish b/scripts/domtool-publish index fe111df..f3bd15d 100755 --- a/scripts/domtool-publish +++ b/scripts/domtool-publish @@ -56,6 +56,7 @@ case $1 in ;; courier) /usr/sbin/makeuserdb + /bin/chown -R domtool.domtool /etc/courier/userdb /bin/cat /etc/courier/userdb/* >/etc/courier/exim /bin/chmod o-r /etc/courier/exim /usr/sbin/exim_dbmbuild /etc/courier/exim /etc/courier/exim.dat diff --git a/src/mail/vmail.sml b/src/mail/vmail.sml index 60a3a35..cf36f9f 100644 --- a/src/mail/vmail.sml +++ b/src/mail/vmail.sml @@ -28,33 +28,41 @@ datatype listing = fun list domain = let - val inf = TextIO.openIn (OS.Path.joinDirFile {dir = Config.Courier.userdbDir, - file = domain}) - - fun loop users = - case TextIO.inputLine inf of - NONE => Listing (rev users) - | SOME line => - case String.tokens Char.isSpace line of - [addr, fields] => - (case String.fields (fn ch => ch = #"@") addr of - [user, _] => - let - fun parseFields fields = - case fields of - "mail" :: mailbox :: _ => loop ({user = user, mailbox = mailbox} :: users) - | _ :: _ :: rest => parseFields rest - | _ => Error "Invalid fields in database" - in - parseFields (String.fields (fn ch => ch = #"|" orelse ch = #"=") fields) - end - | _ => Error "Invalid e-mail address format in database") - | _ => Error "Invalid entry in database" + val file = OS.Path.joinDirFile {dir = Config.Courier.userdbDir, + file = domain} in - loop [] - before TextIO.closeIn inf + if Posix.FileSys.access (file, []) then + let + val inf = TextIO.openIn file + + fun loop users = + case TextIO.inputLine inf of + NONE => Listing (rev users) + | SOME line => + case String.tokens Char.isSpace line of + [addr, fields] => + (case String.fields (fn ch => ch = #"@") addr of + [user, _] => + let + fun parseFields fields = + case fields of + "mail" :: mailbox :: _ => loop ({user = user, mailbox = mailbox} :: users) + | _ :: _ :: rest => parseFields rest + | _ => Error "Invalid fields in database" + in + parseFields (String.fields (fn ch => ch = #"|" orelse ch = #"=") fields) + end + | _ => Error "Invalid e-mail address format in database") + | _ => Error "Invalid entry in database" + in + loop [] + before TextIO.closeIn inf + end + else + Listing [] end - handle IO.Io _ => Listing [] + handle IO.Io {name, function, ...} => + Error ("IO failure: " ^ name ^ ": " ^ function) fun mailboxExists {domain, user} = let diff --git a/src/mail/vmailpasswd.c b/src/mail/vmailpasswd.c index 13b38a9..c371645 100644 --- a/src/mail/vmailpasswd.c +++ b/src/mail/vmailpasswd.c @@ -117,5 +117,5 @@ main(int argc, char *argv[]) { return rc; } - return 0; + return system("/usr/local/bin/domtool-publish courier"); } diff --git a/src/main.sml b/src/main.sml index 8bec641..52dc753 100644 --- a/src/main.sml +++ b/src/main.sml @@ -576,7 +576,7 @@ fun requestListMailboxes domain = case m of MsgMailboxes users => (Msg.send (bio, MsgOk); Vmail.Listing users) - | MsgError s => Vmail.Error ("Creation failed: " ^ s) + | MsgError s => Vmail.Error ("Listing failed: " ^ s) | _ => Vmail.Error "Unexpected server reply.") before OpenSSL.close bio end