have dovecot give an error if maildir doesn't exist

0

This is contrary to what most users want, but how can I make dovecot give an error if the maildir doesn't exist, instead of silently automatically creating it itself?

Auth is pam-based and I'm using Maildir in a custom dir:

mail_location = maildir:/stor/mail/imap/%u:INDEX=/stor/mail/imap/indexes/%u

If I rm -rf /stor/mail/imap then I'd expect dovecot to complain when being started or at least when a user attempts to fetch. However, it starts just fine without creating any dir, then automatically creates /stor/mail/imap/foo when use foo logs in and fetches.

I'd like to fail to start if /stor/mail/imap doesn't exist, or failing that, to complain to the user when it attempts to fetch.

EDIT: I can chown root /stor/mail/imap; chmod 700 /stor/mail/imap. Dovecot still starts up fine (grrr). It does complain to the user upon fetch, though the error is "Login to server failed" which is innacurate, though better than silent.

I did try setting auto to no in the mailboxes defs, but to no avail. it seems you can't set auto for INBOX. I'm using the default dovecot config from Ubuntu 16.04.2 where conf.d/15-mailboxes.conf has:

# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }
  mailbox Sent {
    special_use = \Sent
  }
}

and conf.d/10-mail.conf has:

namespace inbox {
  # Namespace type: private, shared or public
  #type = private

  # Hierarchy separator to use. You should use the same separator for all
  # namespaces or some clients get confused. '/' is usually a good one.
  # The default however depends on the underlying mail storage format.
  #separator =.

  # Prefix required to access this namespace. This needs to be different for
  # all namespaces. For example "Public/".
  #prefix =.

  # Physical location of the mailbox. This is in same format as
  # mail_location, which is also the default for it.
  #location =

  # There can be only one INBOX, and this setting defines which namespace
  # has it.
  inbox = yes

  # If namespace is hidden, it's not advertised to clients via NAMESPACE
  # extension. You'll most likely also want to set list=no. This is mostly
  # useful when converting from another server with different namespaces which
  # you want to deprecate but still keep working. For example you can create
  # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
  #hidden = no

  # Show the mailboxes under this namespace with LIST command. This makes the
  # namespace visible for clients that don't support NAMESPACE extension.
  # "children" value lists child mailboxes, but hides the namespace prefix.
  #list = yes

  # Namespace handles its own subscriptions. If set to "no", the parent
  # namespace handles them (empty prefix should always have this as "yes")
  #subscriptions = yes

  # See 15-mailboxes.conf for definitions of special mailboxes.
}

Normadize

Posted 2017-03-25T20:38:16.097

Reputation: 151

1You could take away write permissions to the parent directory, so if Dovecot is running as dovecot user, then it doesn't belong to the group and doesn't have write permissions. You might also use SELinux to take away the attribute from Dovecot so it cannot write to user_t directories and therefore cannot create directories, but that is much harder. – Chloe – 2017-03-25T21:27:13.863

@Chloe I just came back to post that I've tried changing dir permissions. Gave you +1 nonetheless. Dovecot still starts fine even like this, but gives an error to the user when user attepts to fetch ... however, the error (as understood by Thunderbird at least) is "Login to server failed". This is innacurate, but still better than before. – Normadize – 2017-03-25T22:25:43.960

No answers