Subject: RE: Possible IMAP Bug Causes IMAP with PAM_KRB5 to rapidly deplete INODEs and DISK space

From: "Jason Sauve" <[email-masked]>
Date: Mon, 13 Sep 2004 10:15:59 -0400

Mark,

I've compiled the 2004a version currently available on the website
(md5sum 34d2c66271302cd2f926094fb5e8705d), and have also tested the
development version of 2004b. As per inspection, both versions DO
contain a logout hook built into src/osdep/unix/ckp_pam.c, but still do
not cleanup pam credentials properly (in this case kerberos tickets in
/tmp). Why this is I am not sure, but this appears to be a bug in the
code still.

Jason

-----Original Message-----
From: Mark Crispin [mailto:[email-masked]] 
Sent: Saturday, September 11, 2004 12:45 AM
To: Jason Sauve
Subject: RE: Possible IMAP Bug Causes IMAP with PAM_KRB5 to rapidly
deplete INODEs and DISK space

On Fri, 10 Sep 2004, Jason Sauve wrote:
> The source I downloaded and compiled with to test just a few hours ago

> today was actually from ftp://ftp.cac.washington.edu/mail/imap.tar.Z
> (2004.88).
> If it was 2004a that I downloaded, then the issue doesn't appear to be

> resolved in this version as upon logout or disconnect the PAM kerberos

> ticket is still left in /tmp.

Are you certain that you were actually running the 2004a version of
imapd? 
More than once, someone has said "it wasn't fixed by the new version"
when it turned out that they were still inadvertantly running the old
binary.

The routine which does the cleanup is checkpw_cleanup() in ckp_pam.c.
It is armed as the logout hook by checkpw() in the two mail_parameters()
calls near the end.

Since this is a software issue with the UW IMAP toolkit (c-client
library) instead of an IMAP protocol issue, any further discussion on
mailing lists should go to the [email-masked] mailing list
instead of [email-masked].  Thanks.

-- Mark --

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

---

From: "Jason Sauve" <[email-masked]>
Date: Tue, 14 Sep 2004 11:02:15 -0400

Your src/osdep/unix/env_unix.c patch in yesterday's DEV build absolutely
fixed the problem with the logout hook not being called.

Thanks a bunch.

Jason

-----Original Message-----
From: [email-masked] [mailto:[email-masked]]
On Behalf Of Mark Crispin
Sent: Monday, September 13, 2004 5:34 PM
To: Jason Sauve
Cc: [email-masked]
Subject: RE: Possible IMAP Bug Causes IMAP with PAM_KRB5 to rapidly
deplete INODEs and DISK space

Thank you for your investigation work; and in particular for your
information that the logout hook was not being called.

I believe that this problem is remedied in today's
 	ftp://ftp.cac.washington.edu/mail/imap-2004b.DEV.tar.Z

-- Mark --

---

From: "Jason Sauve" <[email-masked]>
Date: Wed, 22 Sep 2004 10:54:50 -0400

I'd be curious to find out what conditions cause this as well. I have
not had a single orphaned /tmp/krb5 ticket leftover since I've patched
2004a with the 2004b.DEV code.

I can't imagine why one would want to kill the process using any kind of
signals on a regular basis, but like you said that this was just yet
another way to create orphaned kerberos tickets under /tmp.

We're using Redhat Enterprise 3, which ships with 2002d (real old). So I
installed the 2002d SRPM redhat provides, and rebuilt the binary RPM
using 2004a with all the appropriate patches along the way.

If you're using RH I'd be happy to provide you with my binary RPM to try
out. I've yet to rebuild the SRPM because of all the manual patching I
had to do.

-----Original Message-----
From: David Lee [mailto:[email-masked]] 
Sent: Wednesday, September 22, 2004 5:05 AM
To: Mark Crispin
Cc: [email-masked]; Jason Sauve
Subject: RE: Possible IMAP Bug Causes IMAP with PAM_KRB5 to rapidly

On Tue, 14 Sep 2004, Jason Sauve wrote:

> Your src/osdep/unix/env_unix.c patch in yesterday's DEV build 
> absolutely fixed the problem with the logout hook not being called.
> [...]

I think I can further confirm that this fix is largely (order 90%)
effective.

History: A couple of years ago, we had massive quantities of /tmp/krb5*
files accumulating.  At the time, the code in "ckp_pam.c" had an "#if 0"
disabling code that would unlink these files at their creation; I
enabled this and it solved our problem.  (See also my email of 19 April
2004.)

Last week, I had installed vanilla imap-2004a: the "/tmp/krb5*" problem
reappeared with a vengeance, and we quickly had 20,000 (and rising) such
files.  I then extracted your "src/osdep/unix/env_unix.c" change from
"imap-2004b.DEV" and applied that to our "imap-2004a".  Things are now
vastly better.

However there is still a smaller-scale lurking problem causing some
/tmp/krb5* files to remain.  I don't know how the users precipate this
condition from email sessions, but I can reproduce something similar
(same?) "under the bonnet" within the server:

 o  A clean session (imap login/logout) is fine (the /tmp/krb5* file is
cleanly removed at session end).

 o  Sending a HUP to imapd (dies) is also fine (file cleanly removed).

 o  Sending a TERM or INT to imapd (dies) leaves the file hanging
around.

So that "imap-2004b.DEV" change has made a huge improvement, for which
many thanks.  But there remain some circumstances under which /tmp/krb5*
files can be left around (we are seeing a few thousand per day, so I
still need my tmp-flushing cron job).

Hope that helps.

-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham                :
:  Phone: +44 191 334 2752                  U.K.                  :