From 113e144dedbebb5bc659eadc7f329450bb374606 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <gray@gnu.org>
Date: Tue, 23 Jul 2019 11:08:04 +0300
Subject: Fix mandatory locking

* lib/manlock.c (mailbox_open_and_lock): Force proper locker if
a null locker is associated with the mailbox.
---
 lib/manlock.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/manlock.c b/lib/manlock.c
index 4a3b2be..392c581 100644
--- a/lib/manlock.c
+++ b/lib/manlock.c
@@ -126,6 +126,19 @@ mailbox_open_and_lock (mu_mailbox_t mbox, int flags)
       return MU_ERR_FAILURE;
     }
 
+  if (lock)
+    {
+      status = mu_locker_get_flags (lock, &flags);
+      if (status)
+	{
+	  mu_diag_funcall (MU_DIAG_ERROR, "mu_locker_get_flags", urlstr,
+			   status);
+	  return MU_ERR_FAILURE;
+	}
+      if (flags & MU_LOCKER_NULL)
+	lock = NULL;
+    }
+  
   if (!lock && manlock_mandatory_locking && manlock_lock_dir)
     {
       char *fname = NULL;
-- 
cgit v1.0-41-gc330

