Commit e192fdc4 e192fdc478dabf22e2b0aa29e5014d3f6bae8960 by Sergey Poznyakoff

imap4d: uniformly use mailbox name and record for opening mailboxes

This avoids problems with escaping pathnames that contain characters
specific for URLs

* imap4d/select.c (imap4d_select0): Don't use mailbox URL.
* lib/manlock.c (manlock_open_mailbox_from_record): New function.
* lib/muaux.h (manlock_open_mailbox_from_record): New proto.
1 parent 588c225b
......@@ -38,6 +38,7 @@ imap4d_select0 (struct imap4d_command *command, const char *mboxname,
{
int status;
char *mailbox_name;
mu_record_t record;
/* FIXME: Check state. */
......@@ -59,24 +60,25 @@ imap4d_select0 (struct imap4d_command *command, const char *mboxname,
if (strcmp (mboxname, "INBOX") == 0)
flags |= MU_STREAM_CREAT;
mailbox_name = namespace_translate_name (mboxname, 1, NULL);
mailbox_name = namespace_get_name (mboxname, &record, NULL);
if (!mailbox_name)
return io_completion_response (command, RESP_NO, "Couldn't open mailbox");
if (flags & MU_STREAM_WRITE)
{
status = manlock_open_mailbox (&mbox, mailbox_name, 1, flags);
status = manlock_open_mailbox_from_record (&mbox, record,
mailbox_name, flags);
if (status)
flags &= ~MU_STREAM_WRITE;
}
if (!(flags & MU_STREAM_WRITE))
{
status = mu_mailbox_create_default (&mbox, mailbox_name);
status = mu_mailbox_create_from_record (&mbox, record, mailbox_name);
if (status)
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create_default",
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create_from_record",
mailbox_name,
status);
else
......
......@@ -183,6 +183,31 @@ manlock_open_mailbox (mu_mailbox_t *pmbox, const char *mailbox_name, int def,
return status;
}
int
manlock_open_mailbox_from_record (mu_mailbox_t *pmbox, mu_record_t record,
const char *mailbox_name, int flags)
{
mu_mailbox_t mbox;
int status;
status = mu_mailbox_create_from_record (&mbox, record, mailbox_name);
if (status)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_create_from_record",
mailbox_name,
status);
return 1;
}
status = mailbox_open_and_lock (mbox, flags);
if (status == 0)
*pmbox = mbox;
else
mu_mailbox_destroy (&mbox);
return status;
}
struct mu_cfg_param manlock_param[] = {
{ "enable", mu_c_bool, &manlock_mandatory_locking, 0, NULL,
......
......@@ -24,6 +24,9 @@ extern char *manlock_lock_dir;
int manlock_open_mailbox (mu_mailbox_t *pmbox, const char *mailbox_name,
int def, int flags);
int manlock_open_mailbox_from_record (mu_mailbox_t *pmbox, mu_record_t record,
const char *mailbox_name, int flags);
int manlock_lock (mu_mailbox_t mbox);
int manlock_touchlock (mu_mailbox_t mbox);
int manlock_unlock (mu_mailbox_t mbox);
......