From 70f3d7ca7d08c4774c330f808676e55faafc9f05 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 8 Oct 2013 21:29:06 -0700 Subject: [PATCH] Handle maildir-format dis under /var/spool/mail https://sourceforge.net/p/webadmin/bugs/4305/ --- mailboxes/boxes-lib.pl | 3 +++ mailboxes/mailboxes-lib.pl | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mailboxes/boxes-lib.pl b/mailboxes/boxes-lib.pl index f55806121..dd4f6215b 100755 --- a/mailboxes/boxes-lib.pl +++ b/mailboxes/boxes-lib.pl @@ -1659,6 +1659,9 @@ else { } # mail_file_style(user, basedir, style) +# Given a directory and username, returns the path to that user's mail file +# under the directory based on the style (which may force use of parts of +# the username). sub mail_file_style { if ($_[2] == 0) { diff --git a/mailboxes/mailboxes-lib.pl b/mailboxes/mailboxes-lib.pl index 171ff0cc5..113dae2b3 100755 --- a/mailboxes/mailboxes-lib.pl +++ b/mailboxes/mailboxes-lib.pl @@ -99,10 +99,12 @@ else { 'index' => scalar(@rv) } ); } - # Check for /var/mail/USERNAME file + # Check for /var/mail/USERNAME file or directory if ($dir) { + $dir =~ s/\/$//; # Trailing / means maildir format. + # Postfix sometimes does this. local $mf = &mail_file_style($uinfo[0], $dir, $style); - push(@rv, { 'type' => 0, + push(@rv, { 'type' => -d $mf ? 1 : 0, 'name' => $mf, 'file' => $mf, 'user' => $uinfo[0],