summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-12-01 11:11:44 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-12-01 11:11:44 +0200
commited04bc837e353e61e4c43f6bdbd9a67859c61f61 (patch)
tree249cfbc3e5b08dd455d3eadd53a91e9912163482
parent1186b695bc7c105b19e36bff4c7c9dc04fe30d8f (diff)
downloadmailutils-ed04bc837e353e61e4c43f6bdbd9a67859c61f61.tar.gz
mailutils-ed04bc837e353e61e4c43f6bdbd9a67859c61f61.tar.bz2
Fix delivery to MH and Maildir mailboxes
After successful delivery, maidag would switch back to root privileges too early, due to which the mailbox would be closed when running with root UID. I the property file (.mu-prop) did not exist, it would therefore be created by root. Subsequent attempts to open it by user would fail. One of consequences is that the UIDVALIDITY value would be recalculated each time the mailbox is opened. This would force imap4 clients to rescan mailboxes infinitely, as each scan would change the UIDVALIDITY again. This patch fixes the initialization of UIDVALIDITY and fixes maidag to switch back to root privileges only after closing the mailbox. It also makes sure MH and Maildir mailboxes write .mu-prop upon closing, not upon destroying the mailbox. * libmailutils/base/amd.c (amd_close): Save property. (_amd_scan0): Use mailbox modification time as initial uidvalidity value. * maidag/deliver.c (deliver_to_mailbox): Remove uselsess UID/GID transitions.
-rw-r--r--libmailutils/base/amd.c4
-rw-r--r--maidag/deliver.c3
2 files changed, 4 insertions, 3 deletions
diff --git a/libmailutils/base/amd.c b/libmailutils/base/amd.c
index 95a6f0182..8060f9657 100644
--- a/libmailutils/base/amd.c
+++ b/libmailutils/base/amd.c
@@ -519,6 +519,8 @@ amd_close (mu_mailbox_t mailbox)
free (amd->msg_array);
amd->msg_array = NULL;
+ mu_property_save (amd->prop);
+
amd->msg_count = 0; /* number of messages in the list */
amd->msg_max = 0; /* maximum message buffer capacity */
@@ -675,7 +677,7 @@ _amd_scan0 (struct _amd_data *amd, size_t msgno, size_t *pcount,
_amd_prop_fetch_ulong (amd, _MU_AMD_PROP_UIDVALIDITY, &uidval) ||
!uidval)
{
- uidval = (unsigned long)time (NULL);
+ uidval = (unsigned long) amd->mtime;
_amd_prop_store_off (amd, _MU_AMD_PROP_UIDVALIDITY, uidval);
}
return 0;
diff --git a/maidag/deliver.c b/maidag/deliver.c
index 043d4bf1d..d27b37e2f 100644
--- a/maidag/deliver.c
+++ b/maidag/deliver.c
@@ -225,7 +225,7 @@ deliver_to_mailbox (mu_mailbox_t mbox, mu_message_t msg,
}
#endif
- if (!failed && switch_user_id (auth, 1) == 0)
+ if (!failed)
{
status = mu_mailbox_append_message (mbox, msg);
if (status)
@@ -244,7 +244,6 @@ deliver_to_mailbox (mu_mailbox_t mbox, mu_message_t msg,
failed++;
}
}
- switch_user_id (auth, 0);
}
mu_mailbox_close (mbox);

Return to:

Send suggestions and report system problems to the System administrator.