Subject: locking problem in imap-2002b

From: Peter Ip <[email-masked]>
Date: Mon, 4 Oct 2004 16:40:18 -0400 (EDT)

Hi,

I'm running imap-2002b on RedHat AS3.

A user using Netscape Messenger couldn't compact his INBOX - imap said
the INBOX was read-only. When I looked on the server, another user
held the lock file in /tmp:

# ls -li INBOX
7094292 -rw-------    1 64763    mailusr    178262 Oct  4 16:31 INBOX

# ls -l /tmp/.*.6c4014
-rw-rw-rw-    1 23048    mailusr         5 Oct  4 06:52 /tmp/.891.6c4014

User 23048 had an imapd process:

# ps -uawx | grep 23048
#23048   27815  0.0  0.0  4656 1896 ?        S    06:52   0:00 imapd
root     30656  0.0  0.0  1616  496 pts/1    S    15:18   0:00 grep 27815

The INBOX for user 23048 had inode number 7094295. Is there a race 
condition that is being tickled? I looked in the RELNOTES for imap-2004a
but couldn't see anything relevant.

Peter

_____________________________________________________
Peter Ip, PhD
Computing and Network Services, University of Toronto
email: [email-masked]
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Frode Nordahl <[email-masked]>
Date: Tue, 5 Oct 2004 09:35:00 +0200

> I'm running imap-2002b on RedHat AS3.

Are you running with RedHat's RPM's or have you compiled your own 
version?

RedHat patches imap-uw, replacing imap-uw's locking functions (using 
fcntl).

In my experience, this causes things to lock agains eachother 
everywhere, and bypasses IMAP's kiss of death method, since the fcntl 
syscall is just restarted when it recieves the signal.

Mvh,
Frode Nordahl

---

From: Peter Ip <[email-masked]>
Date: Tue, 5 Oct 2004 09:34:44 -0400 (EDT)

Hi Frode,

No, we're not using RedHat's RPM's. I've compiled our own.

Thanks

Peter

On Tue, 5 Oct 2004, Frode Nordahl wrote:

> From: Frode Nordahl <[email-masked]>
> To: Peter Ip <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 5 Oct 2004 09:35:00 +0200
> Subject: Re: locking problem in imap-2002b
> 
> Are you running with RedHat's RPM's or have you compiled your own version?
>
> RedHat patches imap-uw, replacing imap-uw's locking functions (using fcntl).
>
> In my experience, this causes things to lock agains eachother everywhere, and 
> bypasses IMAP's kiss of death method, since the fcntl syscall is just 
> restarted when it recieves the signal.
>
> Mvh,
> Frode Nordahl
>

---

From: [email-masked]
Date: Tue, 5 Oct 2004 10:11:46 -0400

Quoting Peter Ip <[email-masked]>:

[...]

> held the lock file in /tmp:

Just to clarify, user 23048 held the lockfile for user 64763's INBOX?

[...]

--
Sahil Tandon

---

From: Peter Ip <[email-masked]>
Date: Tue, 5 Oct 2004 14:28:39 -0400 (EDT)

Hi,

On Tue, 5 Oct 2004 [email-masked] wrote:

> From: [email-masked]
> To: [email-masked]
> Date: Tue,  5 Oct 2004 10:11:46 -0400

Yes, that's correct.

Peter

---

From: [email-masked]
Date: Tue, 5 Oct 2004 17:09:17 -0400

Quoting Peter Ip <[email-masked]>:

[...]

> > Just to clarify, user 23048 held the lockfile for user 64763's INBOX?

Ok. :)  Now, how is that possible if 64763's INBOX is u+rw, with everyone else
(including those in the mailuser group) lacking permission?

[...]

--
Sahil Tandon

---

From: Peter Ip <[email-masked]>
Date: Wed, 6 Oct 2004 10:46:47 -0400 (EDT)

Hi Sahil,

On Tue, 5 Oct 2004 [email-masked] wrote:

> Date: Tue,  5 Oct 2004 17:09:17 -0400

Well, actually, user 23048 had his own INBOX opened, not 64763's. So it's 
not the permissions on the INBOXes that are the problem. It's that the 
lock file in /tmp had the inode of 64763's INBOX.

Could there be a race condition?

These are unix format inboxes. (We are slowly migrating to MBX format.)
Is there a situation where a temporary INBOX is created e.g. for expunge
and if two imapds are running at the same time that one imapd gets the
inode of another's temp file?

Peter

---

From: Mark Crispin <[email-masked]>
Date: Wed, 6 Oct 2004 11:44:14 -0700 (Pacific Daylight Time)

> inode of another's temp file?

Nothing like that happens in UW imapd, so whatever is going on is 
something else.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.

---

From: [email-masked]
Date: Wed, 6 Oct 2004 16:19:13 -0400

> These are unix format inboxes. (We are slowly migrating to MBX format.)

Really?  I noticed the filename was INBOX - looks MBXish to me; the traditional
UNIX mailbox format inbox is typically stored in /var/mail/$username.  Did you
modify the UW imapd source at all?  I don't think we're all on the same page
here.

> inode of another's temp file?

AFAIK, no.

--
Sahil Tandon

---

From: Peter Ip <[email-masked]>
Date: Wed, 6 Oct 2004 17:05:54 -0400 (EDT)

On Wed, 6 Oct 2004 [email-masked] wrote:

> Date: Wed,  6 Oct 2004 16:19:13 -0400

Yes we did modify the source, but only in the env_unix.c to change the 
location of the sysinbox and the homedirectory.

Peter

---

From: Peter Ip <[email-masked]>
Date: Thu, 7 Oct 2004 11:12:22 -0400 (EDT)

On Wed, 6 Oct 2004, Mark Crispin wrote:

> From: Mark Crispin <[email-masked]>
> To: Peter Ip <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Wed, 6 Oct 2004 11:44:14 -0700 (Pacific Daylight Time)
> Nothing like that happens in UW imapd, so whatever is going on is something 
> else.
>

I've found the culprit. It was a script I wrote. I didn't do proper 
locking of the INBOX.

Thanks anyway.

Peter