Subject: Possible bug in smap

From: Andreas Lamprecht <[email-masked]>
Date: Thu, 14 Dec 2000 15:07:29 +0100 (MET)

[To be removed from this list send the message "unsubscribe fwtk-users" in the
BODY of a mail message to [email-masked].]

Hello!

I'm new to this list so please forgive me if this is an old and known
problem.

I use fwtk for many years now and especially the smap/smapd is used here
in combination with procmail/sendmail and a virus scanner on our main mail
machine for about 7000 Mails/hour. This combo runs for over two years now
without main problems but recently people were complaining about lost
mails. I was scanning through the source of smap and found the line

  if (link(tmpf, p) && (errno != EEXIST))

where smap links the received mail from filename xmaXXXXXX which is
generated through mkstemp to the same filename, first char changed to "s".
And, thats the nasty bit, if this file is already existent, ignores the
error and deletes the xmaXXXXXX file, so the mail is gone.
The tricky thing is in the mkstemp function which generates a filename
with the calling pid and on my solaris box. And since im running smap
through inet, the chance of getting the same pid after a short time is
very high, especially on a high loaded machine.
So i have changed the above line to a piece of code which tries to find a
unused filename and links to it. Seems to work so far ...

Any comments?

Greetings from Austria

---

From: Ted Keller <[email-masked]>
Date: Thu, 14 Dec 2000 13:52:52 -0500 (EST)

Andreas,

I noted that a few years ago and agree with your assessment.  I modified
the smap/smapd routines to create smaXXXXX files directly - and making
them available for delivery based on the permissions going to 700.  Thgis
way, mkstemp always recates a unique file.

I think there are other race conditions also in the way smap was
originally implmeneted.  These are corrected also.

ted keller

---

From: Joseph S D Yao <[email-masked]>
Date: Thu, 14 Dec 2000 16:40:52 -0500

On Thu, Dec 14, 2000 at 03:07:29PM +0100, Andreas Lamprecht wrote:
...
> unused filename and links to it. Seems to work so far ...

This is probably a good change.  Could you submit a patch in 'diff -c'
format?

What is the original version from which you started?

Note that the code above is changed by some of the other patches on
www.fwtk.org ...

-- 
Joe Yao				[email-masked] - Joseph S. D. Yao
COSPO/OSIS Computer Support					EMT-B
-----------------------------------------------------------------------
This message is not an official statement of COSPO policies.