Fix eventual memory overrun

* mail/mail.c (mail_mainloop): Check command length before
trying to access its last byte.
Fix the use of erad-only maildir folders. Imap4d improvements.

New imap4d statement "retain-groups" instructs it to retain the
named supplementary user groups when switching to the user
privileges (previously, imap4d just switched to <user>:mail).
Read-only mailboxes are handled graciously: SELECT succeeds on
such mailboxes, bug marks them explicitly as read-only.

* imap4d/imap4d.c (user_retain_groups): New global.
New config statement "retain-groups".
(mu_get_user_groups): New function.
(imap4d_session_setup0): Use mu_switch_to_privs instead of
just setuid.
* imap4d/list.c (imap4d_list): Fix handling of
  LIST "" "/path/to/mbox"
* imap4d/select.c (imap4d_select0): Retry opening in read-only
mode if failed to open for read-write.
* libproto/maildir/mbox.c (maildir_mkfilename)
(mk_info_filename): Change return value and signature. All uses
changed.
(maildir_scan0): Don't shuffle messages if mailbox is opened
read-only.
* libproto/maildir/folder.c: Update call to maildir_mkfilename.
* libproto/maildir/maildir.h (maildir_mkfilename): Change
prototype.
Improve diagnostics in maildir

* libmailutils/mailbox/fsfolder.c: Fix debugging categories
* libproto/maildir/mbox.c (maildir_opendir)
(maildir_msg_finish_delivery)
(maildir_scan0): Log errors.
(maildir_flush,maildir_deliver_new): Return EACCES if the mailbox is read-only.
New function mu_fgetpwent_r.

* libmailutils/base/fgetpwent.c: Rewrite from scratch.
* ChangeLog.amend: Update.
Fix alignment issues in fgetpwent_r

* libmailutils/base/fgetpwent.c: Place struct passwd at the
beginning of the buffer.  Account for eventual missing newline
at the end of file.