Community Discussions and Support
Auto-reply still not working correctly in 4.51

Yup -- not ignoring the actual issue, i was just looking for a workaround as there has been no indication that this issue is in the queue for updating.

 

My thoughts/wishlist for the autoreply issue would be as follows:

1/ The length of time to suppress subsequent auto-replies be configurable.

2/ Then, for every account, simply keep a file where email addresses and a timestamp are kept on each line.

3/ Then, when a message comes into the account (and the account has autoreply set to on), the sending email address is checked in the file. If found, check the timestamp against the current time and send (or suppress) an auto-reply accordingly. Then update the timestamp in the file if an autoreply is sent. If the email address is not found in the file, append the email address and current timestamp to the file and send the autoreply message.

 

Seems fairly straightforward to me. :)

 

best, gw
<DIV>Yup -- not ignoring the actual issue, i was just looking for a workaround as there has been no indication that this issue is in the queue for updating.</DIV> <DIV> </DIV> <DIV>My thoughts/wishlist for the autoreply issue would be as follows:</DIV> <DIV>1/ The length of time to suppress subsequent auto-replies be configurable.</DIV> <DIV>2/ Then, for every account, simply keep a file where email addresses and a timestamp are kept on each line.</DIV> <DIV>3/ Then, when a message comes into the account (and the account has autoreply set to on), the sending email address is checked in the file. If found, check the timestamp against the current time and send (or suppress) an auto-reply accordingly. Then update the timestamp in the file if an autoreply is sent. If the email address is not found in the file, append the email address and current timestamp to the file and send the autoreply message.</DIV> <DIV> </DIV> <DIV>Seems fairly straightforward to me. :)</DIV> <DIV> </DIV> <DIV>best, gw</DIV>

Sadly it seems that the old problem with auto-replies being sent more than once to the same sender is still around in M/32 4.51. The problem, well documented by Troy Thompson on the Mercury mailing list May 3, 2005, is that the AREPLY.KFL file, that holds addresses to which auto-replies have been sent, gets deleted by the program. I quote Troy's post below for technical details.

In vacation times this is a source of annoyance for us and I'm sure a lot of other Mercury users, as well as a potential cause for mail storms. As the Mercury help file states:

To avoid the possibility of mail storms (which can happen when two accounts start auto-replying to each other, or when an autoreply is sent to a list server), Mercury remembers every address from which a message has been successfully delivered for the account in the last 48 hours; if more than one message comes in from the same address in any 48 hour period, Mercury will generate only one auto-reply. The auto-reply memory is stored in a file called AREPLY.KFL in the user's new mail directory.

/Rolf

 

<tt><b>Subject:</b></tt><tt> Mercury auto-reply : AREPLY.KFL killfile is getting destroyed/rewritten</tt>
<tt><b>From:</b></tt><tt> Troy Thompson &lt;tthompson@ENVISIONWARE.COM&gt;</tt>
<tt><b>Reply-To:</b></tt><tt>tthompson@envisionware.com</tt>
<tt><b>Date:</b></tt><tt>Tue, 3 May 2005 18:29:36 -0400</tt>
<tt><b>Content-Type:</b></tt><tt>text/plain</tt>

Ah HAH! I've finally caught this one "in the act" as it were. I've had
Sysinternals FileMon running for several days while one of our employees is
offsite.

His AREPLY.KFL file is getting repeatedly DELETED by mercury.exe.

The Sysinternals FileMon log contains the following columns:

line# Timestamp process-name:PID command path result

I'm sorry I can't format this any better; the lines are quite long. Try
maximizing on a hi-res screen perhaps to reduce line wrap.

Interesting lines from the capture log:

First message, and the KFL is created...
93438 4:24:35 AM mercury.exe:5656 DIRECTORY D:\MERCURY\MAIL\pdenig\ NO SUCH
FILE FileBothDirectoryInformation: AREPLY.KFL
93439 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
93440 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
93441 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
93442 4:24:35 AM mercury.exe:5656 CREATE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: OverwriteIf Access: All
93443 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
93444 4:24:35 AM mercury.exe:5656 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Offset: 0 Length: 18
93445 4:24:35 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS


Later, it gets updated...

93546 5:08:27 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: Open Access: All
93547 5:08:27 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: Open Access: All
93548 5:08:27 AM mercury.exe:5656 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileFsVolumeInformation
93549 5:08:27 AM mercury.exe:5656 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileInternalInformation
93550 5:08:27 AM mercury.exe:5656 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS Length: 18
93551 5:08:27 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS
93552 5:08:27 AM mercury.exe:5656 READ D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Offset: 0 Length: 512
93553 5:08:27 AM mercury.exe:5656 READ D:\MERCURY\MAIL\pdenig\AREPLY.KFL END
OF FILE Offset: 18 Length: 512
93554 5:08:27 AM mercury.exe:5656 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS Length: 18
93555 5:08:27 AM mercury.exe:5656 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Offset: 18 Length: 25
93556 5:08:27 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS

All is happy for a very long time, over 1600+ lines. Then Something
Happened...

Note the PID of mercury.exe changed. Did it crash and get restarted by the
loader.exe? It's not supposed to restart until 2AM local time...

95065 11:55:15 PM mercury.exe:2284 DIRECTORY D:\MERCURY\MAIL\pdenig\ SUCCESS
FileBothDirectoryInformation: AREPLY.KFL
95066 11:55:15 PM mercury.exe:2284 DIRECTORY D:\MERCURY\MAIL\pdenig\ SUCCESS
FileBothDirectoryInformation: AREPLY.KFL
95067 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: Open Access: All
95068 11:55:15 PM mercury.exe:2284 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileObjectIdInformation
95069 11:55:15 PM mercury.exe:2284 DELETE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS
95070 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS
95071 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
95072 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
95073 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
95074 11:55:15 PM mercury.exe:2284 CREATE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: OverwriteIf Access: All
95075 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
FILE NOT FOUND Options: Open Access: All
95076 11:55:15 PM mercury.exe:2284 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Offset: 0 Length: 23
95077 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS

Line 95069 really concerns me! DELETE? After that point, EVERY subsequent
open of his AREPLY.KFL gets a DELETE thrown in for good measure. The
AREPLY.KFL only shows one address line and will not grow beyond that point.

The KFL got up to 664 bytes apparently, then went goofy.

I renamed the "broken" KFL file and restarted Mercury; as of this moment,
it's happy again and is not DELETEing the KFL before it appends.

The server is a rather hefty Windows 2003 Server running Mercury/32 4.01b.
Other variables include Symantec AntiVirus Corporate Edition 9.03 in "file
system autoprotect" configuration only (no SMTP features).

-----
Troy Thompson
IT Manager, Envisionware, Inc
tthompson@envisionware.com
&lt;p&gt;Sadly it seems that the old problem with auto-replies being sent more than once to the same sender is still around in M/32 4.51. The problem, well documented by Troy Thompson on the Mercury mailing list May 3, 2005, is that the AREPLY.KFL file, that holds addresses to which auto-replies have been sent, gets deleted by the program. I quote Troy&#039;s post below for technical details.&lt;/p&gt;&lt;p&gt;In vacation times this is a source of annoyance for us and I&#039;m sure a lot of other Mercury users, as well as a potential cause for mail storms. As the Mercury help file states:&lt;/p&gt;&lt;blockquote&gt;&lt;i&gt;To avoid the possibility of mail storms (which can happen when two accounts start auto-replying to each other, or when an autoreply is sent to a list server), Mercury remembers every address from which a message has been successfully delivered for the account in the last 48 hours; if more than one message comes in from the same address in any 48 hour period, Mercury will generate only one auto-reply. The auto-reply memory is stored in a file called AREPLY.KFL in the user&#039;s new mail directory.&lt;/i&gt;&lt;/blockquote&gt;&lt;p&gt;/Rolf&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;blockquote&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;&lt;i&gt;&lt;tt&gt;&lt;b&gt;Subject:&lt;/b&gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;i&gt;&lt;tt&gt; Mercury auto-reply : AREPLY.KFL killfile is getting destroyed/rewritten&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;&lt;i&gt;&lt;tt&gt;&lt;b&gt;From:&lt;/b&gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;i&gt;&lt;tt&gt; Troy Thompson &amp;lt;tthompson@ENVISIONWARE.COM&amp;gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;&lt;i&gt;&lt;tt&gt;&lt;b&gt;Reply-To:&lt;/b&gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;i&gt;&lt;tt&gt;tthompson@envisionware.com&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;&lt;i&gt;&lt;tt&gt;&lt;b&gt;Date:&lt;/b&gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;i&gt;&lt;tt&gt;Tue, 3 May 2005 18:29:36 -0400&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td nowrap=&quot;nowrap&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;&lt;i&gt;&lt;tt&gt;&lt;b&gt;Content-Type:&lt;/b&gt;&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;i&gt;&lt;tt&gt;text/plain&lt;/tt&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;i&gt;Ah HAH! I&#039;ve finally caught this one &quot;in the act&quot; as it were. I&#039;ve had&lt;/i&gt; &lt;i&gt;Sysinternals FileMon running for several days while one of our employees is&lt;/i&gt; &lt;i&gt;offsite.&lt;/i&gt; &lt;i&gt;His AREPLY.KFL file is getting repeatedly DELETED by mercury.exe.&lt;/i&gt; &lt;i&gt;The Sysinternals FileMon log contains the following columns:&lt;/i&gt; &lt;i&gt;line# Timestamp process-name:PID command path result&lt;/i&gt; &lt;i&gt;I&#039;m sorry I can&#039;t format this any better; the lines are quite long. Try&lt;/i&gt; &lt;i&gt;maximizing on a hi-res screen perhaps to reduce line wrap.&lt;/i&gt; &lt;i&gt;Interesting lines from the capture log:&lt;/i&gt; &lt;i&gt;First message, and the KFL is created...&lt;/i&gt; &lt;i&gt;93438 4:24:35 AM mercury.exe:5656 DIRECTORY D:\MERCURY\MAIL\pdenig\ NO SUCH&lt;/i&gt; &lt;i&gt;FILE FileBothDirectoryInformation: AREPLY.KFL&lt;/i&gt; &lt;i&gt;93439 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;93440 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;93441 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;93442 4:24:35 AM mercury.exe:5656 CREATE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: OverwriteIf Access: All&lt;/i&gt; &lt;i&gt;93443 4:24:35 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;93444 4:24:35 AM mercury.exe:5656 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Offset: 0 Length: 18&lt;/i&gt; &lt;i&gt;93445 4:24:35 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;Later, it gets updated...&lt;/i&gt; &lt;i&gt;93546 5:08:27 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: Open Access: All&lt;/i&gt; &lt;i&gt;93547 5:08:27 AM mercury.exe:5656 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: Open Access: All&lt;/i&gt; &lt;i&gt;93548 5:08:27 AM mercury.exe:5656 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileFsVolumeInformation&lt;/i&gt; &lt;i&gt;93549 5:08:27 AM mercury.exe:5656 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileInternalInformation&lt;/i&gt; &lt;i&gt;93550 5:08:27 AM mercury.exe:5656 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS Length: 18&lt;/i&gt; &lt;i&gt;93551 5:08:27 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;93552 5:08:27 AM mercury.exe:5656 READ D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Offset: 0 Length: 512&lt;/i&gt; &lt;i&gt;93553 5:08:27 AM mercury.exe:5656 READ D:\MERCURY\MAIL\pdenig\AREPLY.KFL END&lt;/i&gt; &lt;i&gt;OF FILE Offset: 18 Length: 512&lt;/i&gt; &lt;i&gt;93554 5:08:27 AM mercury.exe:5656 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS Length: 18&lt;/i&gt; &lt;i&gt;93555 5:08:27 AM mercury.exe:5656 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Offset: 18 Length: 25&lt;/i&gt; &lt;i&gt;93556 5:08:27 AM mercury.exe:5656 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;All is happy for a very long time, over 1600+ lines. Then Something&lt;/i&gt; &lt;i&gt;Happened...&lt;/i&gt; &lt;i&gt;Note the PID of mercury.exe changed. Did it crash and get restarted by the&lt;/i&gt; &lt;i&gt;loader.exe? It&#039;s not supposed to restart until 2AM local time...&lt;/i&gt; &lt;i&gt;95065 11:55:15 PM mercury.exe:2284 DIRECTORY D:\MERCURY\MAIL\pdenig\ SUCCESS&lt;/i&gt; &lt;i&gt;FileBothDirectoryInformation: AREPLY.KFL&lt;/i&gt; &lt;i&gt;95066 11:55:15 PM mercury.exe:2284 DIRECTORY D:\MERCURY\MAIL\pdenig\ SUCCESS&lt;/i&gt; &lt;i&gt;FileBothDirectoryInformation: AREPLY.KFL&lt;/i&gt; &lt;i&gt;95067 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: Open Access: All&lt;/i&gt; &lt;i&gt;95068 11:55:15 PM mercury.exe:2284 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileObjectIdInformation&lt;/i&gt; &lt;i&gt;95069 11:55:15 PM mercury.exe:2284 DELETE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;95070 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;95071 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;95072 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;95073 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;95074 11:55:15 PM mercury.exe:2284 CREATE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: OverwriteIf Access: All&lt;/i&gt; &lt;i&gt;95075 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;FILE NOT FOUND Options: Open Access: All&lt;/i&gt; &lt;i&gt;95076 11:55:15 PM mercury.exe:2284 WRITE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Offset: 0 Length: 23&lt;/i&gt; &lt;i&gt;95077 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;Line 95069 really concerns me! DELETE? After that point, EVERY subsequent&lt;/i&gt; &lt;i&gt;open of his AREPLY.KFL gets a DELETE thrown in for good measure. The&lt;/i&gt; &lt;i&gt;AREPLY.KFL only shows one address line and will not grow beyond that point.&lt;/i&gt; &lt;i&gt;The KFL got up to 664 bytes apparently, then went goofy.&lt;/i&gt; &lt;i&gt;I renamed the &quot;broken&quot; KFL file and restarted Mercury; as of this moment,&lt;/i&gt; &lt;i&gt;it&#039;s happy again and is not DELETEing the KFL before it appends.&lt;/i&gt; &lt;i&gt;The server is a rather hefty Windows 2003 Server running Mercury/32 4.01b.&lt;/i&gt; &lt;i&gt;Other variables include Symantec AntiVirus Corporate Edition 9.03 in &quot;file&lt;/i&gt; &lt;i&gt;system autoprotect&quot; configuration only (no SMTP features).&lt;/i&gt; &lt;i&gt;-----&lt;/i&gt; &lt;i&gt;Troy Thompson&lt;/i&gt; &lt;i&gt;IT Manager, Envisionware, Inc&lt;/i&gt; &lt;i&gt;tthompson@envisionware.com&lt;/i&gt; &lt;/blockquote&gt;

I'll check on this, we have lots of autoreplies in the seasonal spinner now.

I&#039;ll check on this, we have lots of autoreplies in the seasonal spinner now.

Checked, and sadly yes, AREPLY.KFL is not according to plan - ie not holding the last addresses from the last 48 hours of messages.

Checked, and sadly yes, AREPLY.KFL is not according to plan - ie not holding the last addresses from the last 48 hours of messages.

Correction, the AREPLY.KFL file is deleted when it is 48 hours old. Then starting fresh. I've asked David if we can set this time limit differently.

Correction, the AREPLY.KFL file is deleted when it is 48 hours old. Then starting fresh. I&#039;ve asked David if we can set this time limit differently.

OK, could be that the first 48 hours after the file was created works correctly. However, after that point every attempt to update the file will cause it to be deleted according to my  experience. For instance, I sent several cc's to a colleague that's on vacation a few days ago, and received an autoreply for each (at 19.36, 19.52, and 20.10).

/Rolf 

&lt;p&gt;OK, could be that the first 48 hours after the file was created works correctly. However, after that point every attempt to update the file will cause it to be deleted according to my&amp;nbsp; experience. For instance, I sent several cc&#039;s to a colleague that&#039;s on vacation a few days ago, and received an autoreply for each (at 19.36, 19.52, and 20.10).&lt;/p&gt;&lt;p&gt;/Rolf&amp;nbsp;&lt;/p&gt;

[quote user="Rolf Lindby"]

OK, could be that the first 48 hours after the file was created works correctly. However, after that point every attempt to update the file will cause it to be deleted according to my  experience. For instance, I sent several cc's to a colleague that's on vacation a few days ago, and received an autoreply for each (at 19.36, 19.52, and 20.10).

[/quote]

A couple of other people have reported things like this, but I am unable to reproduce them. The only thing I can assume is that it is somehow tied either to access rights, or to some external process momentarily interfering with Mercury's access to the file. I am, however, *absolutely* confident that it is not a bug in Mercury per se.

Mercury handles AREPLY.KFL by attempting to open it for update (i.e, assume the file exists, open it, and append the information to the end). If this operation fails, it then tries opening the file from scratch (working on the assumption that it doesn't exist). If you can read C code, the C that Mercury uses looks a bit like this:

   fil = fopen (areply_fname, "r+b");
   if (fil == NULL) fil = fopen (areply_fname, "wb");


So what's happening in your case is that the first attempt to open the file is failing, even though the file exists, but the second attempt is not. The visible effect of this is that the file will get recreated each time it is changed.

Now, the real question is "Why is the append open failing?". The first reason might be that the the user whose rights Mercury is using does not have sufficient rights to see existing files, even though it might be able to create them (in NetWare terms, this would be like having the RWC rights in a directory, but not the F (Filescan) right). This one is purely speculative - I don't know if this is the way the Borland runtime library works or not.

The second, and more likely explanation, is that the Append Open attempt triggers an external process to examine the file - most likely a virus scanner of some kind. It locks the file while it's inspecting it, preventing Mercury from accessing it. By the time Mercury tries the create open, though, the process has released the file, allowing Mercury to overwrite it.

As I say above, I've never been able to reproduce this problem, but I am 100% certain that it is an external influence of some kind - the code is very simple and not subject to programmer error. Try disabling any background A/V scanner that is active on the user's mail directory and see if the problem persists.

It may be possible for me to find some way around this if it becomes apparent that this *is* yet another case of accursed A/V products screwing me around, but I would need a little more certainty about exactly what's causing the problem before I proceeded.

Cheers!

-- David --

[quote user=&quot;Rolf Lindby&quot;]&lt;p&gt;OK, could be that the first 48 hours after the file was created works correctly. However, after that point every attempt to update the file will cause it to be deleted according to my&amp;nbsp; experience. For instance, I sent several cc&#039;s to a colleague that&#039;s on vacation a few days ago, and received an autoreply for each (at 19.36, 19.52, and 20.10).&lt;/p&gt;&lt;p&gt;[/quote] A couple of other people have reported things like this, but I am unable to reproduce them. The only thing I can assume is that it is somehow tied either to access rights, or to some external process momentarily interfering with Mercury&#039;s access to the file. I am, however, *absolutely* confident that it is not a bug in Mercury per se. Mercury handles AREPLY.KFL by attempting to open it for update (i.e, assume the file exists, open it, and append the information to the end). If this operation fails, it then tries opening the file from scratch (working on the assumption that it doesn&#039;t exist). If you can read C code, the C that Mercury uses looks a bit like this: &lt;font face=&quot;courier new,courier&quot;&gt;&amp;nbsp;&amp;nbsp; fil = fopen (areply_fname, &quot;r+b&quot;); &amp;nbsp;&amp;nbsp; if (fil == NULL) fil = fopen (areply_fname, &quot;wb&quot;);&lt;/font&gt; So what&#039;s happening in your case is that the first attempt to open the file is failing, even though the file exists, but the second attempt is not. The visible effect of this is that the file will get recreated each time it is changed. Now, the real question is &quot;Why is the append open failing?&quot;. The first reason might be that the the user whose rights Mercury is using does not have sufficient rights to see existing files, even though it might be able to create them (in NetWare terms, this would be like having the RWC rights in a directory, but not the F (Filescan) right). This one is purely speculative - I don&#039;t know if this is the way the Borland runtime library works or not. The second, and more likely explanation, is that the Append Open attempt triggers an external process to examine the file - most likely a virus scanner of some kind. It locks the file while it&#039;s inspecting it, preventing Mercury from accessing it. By the time Mercury tries the create open, though, the process has released the file, allowing Mercury to overwrite it. As I say above, I&#039;ve never been able to reproduce this problem, but I am 100% certain that it is an external influence of some kind - the code is very simple and not subject to programmer error. Try disabling any background A/V scanner that is active on the user&#039;s mail directory and see if the problem persists. It may be possible for me to find some way around this if it becomes apparent that this *is* yet another case of accursed A/V products screwing me around, but I would need a little more certainty about exactly what&#039;s causing the problem before I proceeded. Cheers! -- David -- &lt;/p&gt;

In this case the program runs on a Windows 2000 Server under an account in the administrators group (which in itself may not be a brilliant idea, but at least rules out the possibility of insufficient user rights). It's been run on different hardware (and different disks) with the same result, so it's not likely to be due to disk problems or anything like that. There is no background A/V scanner running or installed, and this machine has no other roles than being a mail server, so I can't think of any process that would have a reason to access this file other than Mercury/32.

From the file access logs provided by Troy I'd say that the critical point is not the fopen call itself, but something happening shortly after that:

95067 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS Options: Open Access: All
95068 11:55:15 PM mercury.exe:2284 QUERY INFORMATION
D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileObjectIdInformation
95069 11:55:15 PM mercury.exe:2284 DELETE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS
95070 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL
SUCCESS

I read this as
- file found and opened for r/w
- file system information about the file requested and recieved
- delete command sent
- file closed
At this time the contents of the file have not been read at all, actually.

If there is anything I can do to test this further I'm at your disposal.

/Rolf

 

&lt;p&gt;In this case the program runs on a Windows 2000 Server under an account in the administrators group (which in itself may not be a brilliant idea, but at least rules out the possibility of insufficient user rights). It&#039;s been run on different hardware (and different disks) with the same result, so it&#039;s not likely to be due to disk problems or anything like that. There is no background A/V scanner running or installed, and this machine has no other roles than being a mail server, so I can&#039;t think of any process that would have a reason to access this file other than Mercury/32. &lt;/p&gt;&lt;p&gt;From the file access logs provided by Troy I&#039;d say that the critical point is not the fopen call itself, but something happening shortly after that:&lt;/p&gt;&lt;blockquote&gt;&lt;i&gt;95067 11:55:15 PM mercury.exe:2284 OPEN D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS Options: Open Access: All&lt;/i&gt; &lt;i&gt;95068 11:55:15 PM mercury.exe:2284 QUERY INFORMATION&lt;/i&gt; &lt;i&gt;D:\MERCURY\MAIL\pdenig\AREPLY.KFL SUCCESS FileObjectIdInformation&lt;/i&gt; &lt;i&gt;95069 11:55:15 PM mercury.exe:2284 DELETE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt; &lt;i&gt;95070 11:55:15 PM mercury.exe:2284 CLOSE D:\MERCURY\MAIL\pdenig\AREPLY.KFL&lt;/i&gt; &lt;i&gt;SUCCESS&lt;/i&gt;&lt;/blockquote&gt;&lt;p&gt;I read this as - file found and opened for r/w - file system information about the file requested and recieved - delete command sent - file closed At this time the contents of the file have not been read at all, actually.&lt;/p&gt;&lt;p&gt;If there is anything I can do to test this further I&#039;m at your disposal.&lt;/p&gt;&lt;p&gt;/Rolf&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

Stranger and stranger.

When Mercury checks AREPLY.KFS, it does the 48-hour check as part of the process... So, before examining the contents of AREPLY.KFS, it first checks the age of the file and removes it if it's too old. I'm fairly sure that this is what is leading to the sequence of log entries in Rolf's last post. Here's the actual code from Mercury that does this test:

   sprintf (fname, "%s\\AREPLY.KFL", newmaildir);
   if (check_existence (fname) != 0)
      if (stat (fname, &statblk) == 0)
         if ((time (NULL) - statblk.st_ctime) > killfile_lifetime)
            remove (fname);

It checks to see whether or not the file exists: if it does, it calls "stat" (a posix runtime library function) to get the file time information and checks to see whether the file's creation time is more than 48 hours ago: if it is, it deletes the file.

Now, the only way this can happen, is if the Operating System is returning an invalid value for the "ctime" member of "statblk". Note also that for the file to be deleted, the call to "stat" has to be successful, so the value of "ctime" *should* be correct.

What file system are you using? NTFS, FAT, FAT32 or something else? It sounds as though the OS is failing to return sensible values, yet it worked here just now when I tried it (XP+SP2 on an NTFS volume).

I may be able to rewrite this so it does its tests a different way, but I recall running into problems with the way file times are reported by the OS in the past, so it might not be as straightforward as simply calling a different function.

Rolf, send me your e-mail address offline please - I might write a five-line utility to see just what "stat" is actually returning on your system.

Cheers!

-- David --

&lt;p&gt;Stranger and stranger. When Mercury checks AREPLY.KFS, it does the 48-hour check as part of the process... So, before examining the contents of AREPLY.KFS, it first checks the age of the file and removes it if it&#039;s too old. I&#039;m fairly sure that this is what is leading to the sequence of log entries in Rolf&#039;s last post. Here&#039;s the actual code from Mercury that does this test: &lt;font face=&quot;courier new,courier&quot;&gt;&amp;nbsp;&amp;nbsp; sprintf (fname, &quot;%s\\AREPLY.KFL&quot;, newmaildir); &amp;nbsp;&amp;nbsp; if (check_existence (fname) != 0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (stat (fname, &amp;amp;statblk) == 0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((time (NULL) - statblk.st_ctime) &amp;gt; killfile_lifetime) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remove (fname); &lt;/font&gt; It checks to see whether or not the file exists: if it does, it calls &quot;stat&quot; (a posix runtime library function) to get the file time information and checks to see whether the file&#039;s creation time is more than 48 hours ago: if it is, it deletes the file. Now, the only way this can happen, is if the Operating System is returning an invalid value for the &quot;ctime&quot; member of &quot;statblk&quot;. Note also that for the file to be deleted, the call to &quot;stat&quot; has to be successful, so the value of &quot;ctime&quot; *should* be correct. What file system are you using? NTFS, FAT, FAT32 or something else? It sounds as though the OS is failing to return sensible values, yet it worked here just now when I tried it (XP+SP2 on an NTFS volume). I may be able to rewrite this so it does its tests a different way, but I recall running into problems with the way file times are reported by the OS in the past, so it might not be as straightforward as simply calling a different function. Rolf, send me your e-mail address offline please - I might write a five-line utility to see just what &quot;stat&quot; is actually returning on your system. Cheers! -- David -- &lt;/p&gt;

This installation runs on Windows 2000 Server sp4 with NTFS, so in theory it should behave the same as in your setup. Regional settings should probably not affect this, but anyhow it's the English OS version with Swedish locale selected. Troy wrote he used Windows 2003 Server, which most likely means that it was NTFS as well.

E-mail address is on it's way.

 /Rolf
 

 

 

&lt;p&gt;This installation runs on Windows 2000 Server sp4 with NTFS, so in theory it should behave the same as in your setup. Regional settings should probably not affect this, but anyhow it&#039;s the English OS version with Swedish locale selected. Troy wrote he used Windows 2003 Server, which most likely means that it was NTFS as well.&lt;/p&gt;&lt;p&gt;E-mail address is on it&#039;s way.&lt;/p&gt;&lt;p&gt;&amp;nbsp;/Rolf &amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

There must be something bogus about the background routines. We're using Windows Server 2003 Swedish Version with Swedish Locale, and we're having the same problem. Our locale reads dates and times as: YYYY-MM-DD HH:MM:SS with a 24 hour clock. The file system is NTFS on all servers. A matching of a file log with your routine, seems to work when the file create timestamp is within 48 hours, but otherwise all fails. Even the delete seems to fail, or heaven forbid, the create timestamp attribute is altered to the previous timestamp. A correct file open/compare procedure looks like this:

23:42:17 mercury.exe:3716 DIRECTORY D:\MAIL1\MAIL\m1016005\ SUCCESS FileBothDirectoryInformation: AREPLY.KFL 
23:42:17 mercury.exe:3716 DIRECTORY D:\MAIL1\MAIL\m1016005\ SUCCESS FileBothDirectoryInformation: AREPLY.KFL 
23:42:17 mercury.exe:3716 QUERY INFORMATION D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS Attributes: A
 
23:42:17 mercury.exe:3716 OPEN D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS Options: Open  Access: 0012019F 
23:42:17 mercury.exe:3716 READ  D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS Offset: 0 Length: 512 
23:42:17 mercury.exe:3716 READ D:\MAIL1\MAIL\m1016005\AREPLY.KFL END OF FILE Offset: 55 Length: 512 
23:42:17 mercury.exe:3716 QUERY INFORMATION D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS Length: 55 
23:42:17 mercury.exe:3716 WRITE  D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS Offset: 55 Length: 30 
23:42:17 mercury.exe:3716 CLOSE D:\MAIL1\MAIL\m1016005\AREPLY.KFL SUCCESS  

And an incorrect file/open query looks like this:

23:43:57 mercury.exe:3716 DIRECTORY D:\MAIL1\MAIL\m1016029\ SUCCESS FileBothDirectoryInformation: AREPLY.KFL 
23:43:57 mercury.exe:3716 DIRECTORY D:\MAIL1\MAIL\m1016029\ SUCCESS FileBothDirectoryInformation: AREPLY.KFL 
23:43:57 mercury.exe:3716 OPEN D:\MAIL1\MAIL\m1016029\AREPLY.KFL SUCCESS Options: Open  Access: 00010080
 
23:43:57 mercury.exe:3716 QUERY INFORMATION D:\MAIL1\MAIL\m1016029\AREPLY.KFL SUCCESS FileAttributeTagInformation 
23:43:57 mercury.exe:3716 DELETE  D:\MAIL1\MAIL\m1016029\AREPLY.KFL SUCCESS  
23:43:57 mercury.exe:3716 CLOSE D:\MAIL1\MAIL\m1016029\AREPLY.KFL SUCCESS  

&lt;P&gt;There must be something bogus about the background routines. We&#039;re using Windows Server 2003 Swedish Version with Swedish Locale, and we&#039;re having the same problem. Our locale reads dates and times as: YYYY-MM-DD HH:MM:SS with a 24 hour clock. The file system is NTFS on all servers. A matching of a file log with your routine, seems to work when the file create timestamp is within 48 hours, but otherwise all fails. Even the delete seems to fail, or heaven forbid, the create timestamp attribute is altered to the previous timestamp. A correct file open/compare procedure looks like this:&lt;/P&gt; &lt;P&gt;&lt;FONT color=#ff0000&gt;23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;DIRECTORY&amp;nbsp;D:\MAIL1\MAIL\m1016005\&amp;nbsp;SUCCESS&amp;nbsp;FileBothDirectoryInformation: AREPLY.KFL&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;DIRECTORY&amp;nbsp;D:\MAIL1\MAIL\m1016005\&amp;nbsp;SUCCESS&amp;nbsp;FileBothDirectoryInformation: AREPLY.KFL&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;QUERY INFORMATION&amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Attributes: A&lt;/FONT&gt;&lt;FONT color=#800000&gt;&amp;nbsp; &lt;/FONT&gt;23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;OPEN&amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Options: Open&amp;nbsp; Access: 0012019F&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;READ &amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Offset: 0 Length: 512&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;READ&amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;END OF FILE&amp;nbsp;Offset: 55 Length: 512&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;QUERY INFORMATION&amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Length: 55&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;WRITE &amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Offset: 55 Length: 30&amp;nbsp; 23:42:17&amp;nbsp;mercury.exe:3716&amp;nbsp;CLOSE&amp;nbsp;D:\MAIL1\MAIL\m1016005\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;&amp;nbsp; &lt;/P&gt; &lt;P&gt;And an incorrect file/open query looks like this:&lt;/P&gt; &lt;P&gt;&lt;FONT color=#ff0000&gt;23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;DIRECTORY&amp;nbsp;D:\MAIL1\MAIL\m1016029\&amp;nbsp;SUCCESS&amp;nbsp;FileBothDirectoryInformation: AREPLY.KFL&amp;nbsp; 23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;DIRECTORY&amp;nbsp;D:\MAIL1\MAIL\m1016029\&amp;nbsp;SUCCESS&amp;nbsp;FileBothDirectoryInformation: AREPLY.KFL&amp;nbsp; 23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;OPEN&amp;nbsp;D:\MAIL1\MAIL\m1016029\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;Options: Open&amp;nbsp; Access: 00010080&lt;/FONT&gt;&amp;nbsp; 23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;QUERY INFORMATION&amp;nbsp;D:\MAIL1\MAIL\m1016029\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;FileAttributeTagInformation&amp;nbsp; 23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;DELETE &amp;nbsp;D:\MAIL1\MAIL\m1016029\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;&amp;nbsp; 23:43:57&amp;nbsp;mercury.exe:3716&amp;nbsp;CLOSE&amp;nbsp;D:\MAIL1\MAIL\m1016029\AREPLY.KFL&amp;nbsp;SUCCESS&amp;nbsp;&amp;nbsp; &lt;/P&gt;

[quote user="David Harris"]

When Mercury checks AREPLY.KFS, it does the 48-hour check as part of the process... So, before examining the contents of AREPLY.KFS, it first checks the age of the file and removes it if it's too old. I'm fairly sure that this is what is leading to the sequence of log entries in Rolf's last post. Here's the actual code from Mercury that does this test:

   sprintf (fname, "%s\\AREPLY.KFL", newmaildir);
   if (check_existence (fname) != 0)
      if (stat (fname, &statblk) == 0)
         if ((time (NULL) - statblk.st_ctime) > killfile_lifetime)
            remove (fname);

It checks to see whether or not the file exists: if it does, it calls "stat" (a posix runtime library function) to get the file time information and checks to see whether the file's creation time is more than 48 hours ago: if it is, it deletes the file.

Now, the only way this can happen, is if the Operating System is returning an invalid value for the "ctime" member of "statblk". Note also that for the file to be deleted, the call to "stat" has to be successful, so the value of "ctime" *should* be correct.

[/quote]

Did you mean AREPLY.KFL, or .KFS in your comment?

At present, one of my users has this precise issue. The Created date returned by Windows (right-click, get Properties) for the AREPLY.KFS and AREPLY.KFL files for said user is December 2005!

I suspect the "implementation-defined" behavior of remove() vs. unlink() might be an issue on Win32's "sort of POSIX" behavior. The Mercury code logic looks fine. I suspect remove() is not really removing and recreating the file, but rather keeping its old file creation date due to a lingering handle.

https://www.securecoding.cert.org/confluence/display/seccode/FIO08-A.+Take+care+when+calling+remove()+on+an+open+file states:

Invoking <tt>remove()</tt> on an open file is implementation-defined. Removing an open file is sometimes recommended to hide the names of temporary files that may prone to attack (see [TMP30-C. Temporary files must be created with unique and unpredictable file names]).

In cases when an open file needs to be removed, a more strongly defined function, such as the POSIX <tt>unlink()</tt> function, should be considered. To be strictly conforming and portable, <tt>remove()</tt> should not be called on an open file.

Non-Compliant Code Example

The following non-compliant code example illustrates a case where a file is removed while it is still open.

FILE *file;

/* ... */

file = fopen("myfile", "w+");
if (fopen == NULL) {
/* Handle error condition */
}

/* ... */

remove("myfile");

/* ... */

Some implementations will not remove <tt>"myfile"</tt> because the stream is still open.

Implementation Details

Code compiled using Microsoft Visual Studio C++ 2005 and run on Microsoft Windows XP, prevents the <tt>remove()</tt> call from succeeding when the file is open, meaning that the file link will remain after execution completes.

Compliant Solution (POSIX)

This compliant solution uses the POSIX <tt>unlink()</tt> function to remove the file. The <tt>unlink()</tt>

function is guaranteed to unlink the file from the file system

hierarchy but keep the file on disk until all open instances of the

file are closed) is used [Open Group 04].

#include <unistd.h>

FILE *file;

/* ... */

file = fopen("myfile", "w+");
if (fopen == NULL) {
/* Handle error condition */
}
unlink("myfile");
fclose("myfile");

Risk Assessment

Calling <tt>remove()</tt> on an open file has different implications

for different implementations and may cause abnormal termination if the

closed file is written to or read from, or may result in unintended

information disclosure from not actually deleting a file as intended.

[quote user=&quot;David Harris&quot;] &lt;p&gt;When Mercury checks AREPLY.KFS, it does the 48-hour check as part of the process... So, before examining the contents of AREPLY.KFS, it first checks the age of the file and removes it if it&#039;s too old. I&#039;m fairly sure that this is what is leading to the sequence of log entries in Rolf&#039;s last post. Here&#039;s the actual code from Mercury that does this test: &lt;font face=&quot;courier new,courier&quot;&gt;&amp;nbsp;&amp;nbsp; sprintf (fname, &quot;%s\\AREPLY.KFL&quot;, newmaildir); &amp;nbsp;&amp;nbsp; if (check_existence (fname) != 0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (stat (fname, &amp;amp;statblk) == 0) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((time (NULL) - statblk.st_ctime) &amp;gt; killfile_lifetime) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; remove (fname); &lt;/font&gt; It checks to see whether or not the file exists: if it does, it calls &quot;stat&quot; (a posix runtime library function) to get the file time information and checks to see whether the file&#039;s creation time is more than 48 hours ago: if it is, it deletes the file. Now, the only way this can happen, is if the Operating System is returning an invalid value for the &quot;ctime&quot; member of &quot;statblk&quot;. Note also that for the file to be deleted, the call to &quot;stat&quot; has to be successful, so the value of &quot;ctime&quot; *should* be correct. &lt;/p&gt;&lt;p&gt;[/quote]&lt;/p&gt;&lt;p&gt;Did you mean AREPLY.KFL, or .KFS in your comment?&lt;/p&gt;&lt;p&gt;At present, one of my users has this precise issue. The Created date returned by Windows (right-click, get Properties) for the AREPLY.KFS and AREPLY.KFL files for said user is &lt;b&gt;December 2005!&lt;/b&gt;&lt;/p&gt;&lt;p&gt;I suspect the &quot;implementation-defined&quot; behavior of remove() vs. unlink() might be an issue on Win32&#039;s &quot;sort of POSIX&quot; behavior. The Mercury code logic looks fine. I suspect remove() is not really removing and recreating the file, but rather keeping its old file creation date due to a lingering handle. &lt;/p&gt;&lt;p&gt;https://www.securecoding.cert.org/confluence/display/seccode/FIO08-A.+Take+care+when+calling+remove()+on+an+open+file states:&lt;/p&gt;&lt;p&gt;Invoking &lt;tt&gt;remove()&lt;/tt&gt; on an open file is &lt;a href=&quot;https://www.securecoding.cert.org/confluence/display/seccode/BB.+Definitions#BB.Definitions-implementationdefinedbehavior&quot;&gt;implementation-defined&lt;/a&gt;. Removing an open file is sometimes recommended to hide the names of temporary files that may prone to attack (see [&lt;a href=&quot;https://www.securecoding.cert.org/confluence/display/seccode/TMP30-C.+Temporary+files+must+be+created+with+unique+and+unpredictable+file+names&quot; title=&quot;TMP30-C. Temporary files must be created with unique and unpredictable file names&quot;&gt;TMP30-C. Temporary files must be created with unique and unpredictable file names&lt;/a&gt;]).&lt;/p&gt; &lt;p&gt;In cases when an open file needs to be removed, a more strongly defined function, such as the POSIX &lt;tt&gt;unlink()&lt;/tt&gt; function, should be considered. To be strictly conforming and portable, &lt;tt&gt;remove()&lt;/tt&gt; should &lt;em&gt;not&lt;/em&gt; be called on an open file.&lt;/p&gt; &lt;h2&gt;&lt;a class=&quot;&quot; name=&quot;FIO08-A.Takecarewhencallingremove()onanopenfile-NonCompliantCodeExample&quot;&gt;&lt;/a&gt;Non-Compliant Code Example&lt;/h2&gt; &lt;p&gt;The following non-compliant code example illustrates a case where a file is removed while it is still open.&lt;/p&gt; &lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px; background-color: rgb(255, 204, 204);&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot; style=&quot;background-color: rgb(255, 204, 204);&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;FILE *file; /* ... */ file = fopen(&lt;span class=&quot;code-quote&quot;&gt;&quot;myfile&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;w+&quot;&lt;/span&gt;); &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (fopen == NULL) { /* Handle error condition */ } /* ... */ remove(&lt;span class=&quot;code-quote&quot;&gt;&quot;myfile&quot;&lt;/span&gt;); /* ... */&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;p&gt;Some &lt;a href=&quot;https://www.securecoding.cert.org/confluence/display/seccode/BB.+Definitions#BB.Definitions-implementation&quot;&gt;implementations&lt;/a&gt; will not remove &lt;tt&gt;&quot;myfile&quot;&lt;/tt&gt; because the stream is still open.&lt;/p&gt; &lt;h3&gt;&lt;a class=&quot;&quot; name=&quot;FIO08-A.Takecarewhencallingremove()onanopenfile-ImplementationDetails&quot;&gt;&lt;/a&gt;Implementation Details&lt;/h3&gt; &lt;p&gt;Code compiled using Microsoft Visual Studio C++ 2005 and run on Microsoft Windows XP, prevents the &lt;tt&gt;remove()&lt;/tt&gt; call from succeeding when the file is open, meaning that the file link will remain after execution completes.&lt;/p&gt; &lt;h2&gt;&lt;a class=&quot;&quot; name=&quot;FIO08-A.Takecarewhencallingremove()onanopenfile-CompliantSolution(POSIX)&quot;&gt;&lt;/a&gt;Compliant Solution (POSIX)&lt;/h2&gt; &lt;p&gt;This compliant solution uses the POSIX &lt;tt&gt;unlink()&lt;/tt&gt; function to remove the file. The &lt;tt&gt;unlink()&lt;/tt&gt; function is guaranteed to unlink the file from the file system hierarchy but keep the file on disk until all open instances of the file are closed) is used [&lt;a href=&quot;https://www.securecoding.cert.org/confluence/display/seccode/AA.+C+References#AA.CReferences-OpenGroup04&quot;&gt;Open Group 04&lt;/a&gt;].&lt;/p&gt; &lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px; background-color: rgb(204, 204, 255);&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot; style=&quot;background-color: rgb(204, 204, 255);&quot;&gt; &lt;pre class=&quot;code-java&quot;&gt;#include &amp;lt;unistd.h&amp;gt; FILE *file; /* ... */ file = fopen(&lt;span class=&quot;code-quote&quot;&gt;&quot;myfile&quot;&lt;/span&gt;, &lt;span class=&quot;code-quote&quot;&gt;&quot;w+&quot;&lt;/span&gt;); &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (fopen == NULL) { /* Handle error condition */ } unlink(&lt;span class=&quot;code-quote&quot;&gt;&quot;myfile&quot;&lt;/span&gt;); fclose(&lt;span class=&quot;code-quote&quot;&gt;&quot;myfile&quot;&lt;/span&gt;);&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;h2&gt;&lt;a class=&quot;&quot; name=&quot;FIO08-A.Takecarewhencallingremove()onanopenfile-RiskAssessment&quot;&gt;&lt;/a&gt;Risk Assessment&lt;/h2&gt; &lt;p&gt;Calling &lt;tt&gt;remove()&lt;/tt&gt; on an open file has different implications for different implementations and may cause abnormal termination if the closed file is written to or read from, or may result in unintended information disclosure from not actually deleting a file as intended.&lt;/p&gt;

Hi David & all,

 

Just thought i would toss in my hat, and to see where the bugfix for this is at. We are having similar issues and i am beginning to field complaints from users who are reporting this issue.

The current sever implementation is on Windows Server 2000 SP4, NTFS file volume with no A/V or any other external file monitor/processor of any kind.

 

Further - not sure about the logic of the kill-file in the first place. Theoretically, shouldn't each email address have a last sent time associated with it? If someone emails you at 9:00am on monday (say email1@domain.com), and another person emails you at 8:59am on Wednesday (email2@domain.com), well the 48 rule will expire and both email addresses will be reset at 9:00am on wednesday. Thus any subsequent email from email2@domain.com will result in an (erroneous) autoreply message.

 

More info: just took a peak in my own mail box and noticed that my areply.kfl file was created on sept 7, 2006 (last modified is today). Note that we are using canadian locale (ie D/M/Y) for our dates.

 

Thanks!

 Graham
&lt;DIV&gt;Hi David &amp;amp; all,&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;Just thought i would toss in my hat, and to see where the bugfix for this is at. We are having similar issues and i am beginning to field complaints from users who are reporting this issue.&lt;/DIV&gt; &lt;DIV&gt;The current sever implementation is on Windows Server 2000 SP4, NTFS file volume with no A/V or any other external file monitor/processor of any kind.&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;Further - not sure about the logic of the kill-file in the first place. Theoretically, shouldn&#039;t each email address have a last sent time associated with it? If someone emails you at 9:00am on monday (say &lt;A href=&quot;mailto:email1@domain.com&quot; mce_href=&quot;mailto:email1@domain.com&quot;&gt;email1@domain.com&lt;/A&gt;), and another person emails you at 8:59am on Wednesday (&lt;A href=&quot;mailto:email2@domain.com&quot; mce_href=&quot;mailto:email2@domain.com&quot;&gt;email2@domain.com&lt;/A&gt;), well the 48 rule will expire and both email addresses will be reset at 9:00am on wednesday. Thus any subsequent email from &lt;A href=&quot;mailto:email2@domain.com&quot; mce_href=&quot;mailto:email2@domain.com&quot;&gt;email2@domain.com&lt;/A&gt; will result in an (erroneous) autoreply message.&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;More info: just took a peak in my own mail box and noticed that my areply.kfl file was created on sept 7, 2006 (last modified is today). Note that we are using canadian locale (ie D/M/Y) for our dates.&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;Thanks!&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;Graham&lt;/DIV&gt;

So here's a thought -- if the creation date of the kill-file read by Mercury is not in M/D/Y format, is it possible that the code will not work properly? It seems that the only people who are having difficulty with this feature are not using the US locale (or at least a locale whose date format is not M/D/Y).

 

This, of course, could be proven wrong by someone with US locale (or MDY format) who is also having this issue. Anyone? Anyone?

 

cheers,Graham
&lt;DIV&gt;So here&#039;s a thought -- if the creation date of the kill-file read by Mercury is not in M/D/Y format, is it possible that the code will not work properly? It seems that the only people who are having difficulty with this feature are not using the US locale (or at least a locale whose date format is not M/D/Y).&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;This, of course, could be proven wrong by someone with US locale (or MDY format) who is also having this issue. Anyone? Anyone?&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;cheers,Graham&lt;/DIV&gt;

Just thought i would see if i could get the discussion going again on this issue. It continues to bother my users. Has anyone considered the non-US date format as the possible issue?

 

Thanks,

Graham
&lt;DIV&gt;Just thought i would see if i could get the discussion going again on this issue. It continues to bother my users. Has anyone considered the non-US date format as the possible issue?&lt;/DIV&gt; &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt; &lt;DIV&gt;Thanks,&lt;/DIV&gt; &lt;DIV&gt;Graham&lt;/DIV&gt;

The st_ctime value returned by the stat call is just a 64 bit number, so it's not localized. The testing I've done seems to support Troy's theory. But why this occurs only on some computers (and unfortunately not David's) is still unclear.

/Rolf
 

&lt;p&gt;The st_ctime value returned by the stat call is just a 64 bit number, so it&#039;s not localized. The testing I&#039;ve done seems to support Troy&#039;s theory. But why this occurs only on some computers (and unfortunately not David&#039;s) is still unclear.&lt;/p&gt;&lt;p&gt;/Rolf &amp;nbsp;&lt;/p&gt;

I think we'll pursue this after 4.61 is out. I know David has worked a lot about findfirst/findnext issues, resolving many other glitches where file locking has been problematic. With the different nationale, there defenitely is a difference, but it is quite unclear why we here in Sweden have this issue, and David does not.

This approach ok by you Rolf?

&lt;P&gt;I think we&#039;ll pursue this after 4.61 is out. I know David has worked a lot about findfirst/findnext issues, resolving many other glitches where file locking has been problematic. With the different nationale, there defenitely is a difference, but it is quite unclear why we here in Sweden have this issue, and David does not.&lt;/P&gt; &lt;P&gt;This approach ok by you Rolf?&lt;/P&gt;

Any way it can be solved I'll be happy!

/Rolf
 

&lt;p&gt;Any way it can be solved I&#039;ll be happy!&lt;/p&gt;&lt;p&gt;/Rolf &amp;nbsp;&lt;/p&gt;

As a work-around until this has been fixed in the program I've written a small daemon that corrects the timestamp on the .kfl file in case it isn't updated. (The summer holiday season is starting and we really needed this to work!) This restores original functionality.

Anyone else that has this problem can download the daemon here.

/Rolf
&lt;p&gt;As a work-around until this has been fixed in the program I&#039;ve written a small daemon that corrects the timestamp on the .kfl file in case it isn&#039;t updated. (The summer holiday season is starting and we really needed this to work!) This restores original functionality. &lt;/p&gt;&lt;p&gt;Anyone else that has this problem can download the daemon &lt;a href=&quot;/files/folders/community_add-ons_for_mercury/entry9582.aspx&quot; target=&quot;_blank&quot; mce_href=&quot;/files/folders/community_add-ons_for_mercury/entry9582.aspx&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;/Rolf

When I first started reading this thread my first thought was "Why would you delete the file at all?"  You should never delete the file until auto reply is turned off for the user.  Everyone is wasting their time debating creation date/time problems with various flavors of the operating system and locales while losing sight of the real problem.

When I read the post by Graham (airyt - 2008-03-31) questioning the logic of deleting the file in the first place, I thought "Finally, someone has pointed out the real problem!" and that I wouldn't have to reply.  Then everyone, including Graham, ignored that and kept concentrating on the creation date/time problem.

In my opinon, Graham is correct in that the file should not be deleted and the date/time stamp of a given sender's auto reply should be kept in the file with the sender's address.  Pardon me, but I thought that this was rather obvious.

Think of the following scenario:

  1. Auto reply is turned on for a user
  2. Sender01 sends an email to the user
  3. Mercury creates the AREPLY.KFL file
  4. Mercury sends an auto reply to Sender01
  5. Mercury adds Sender01's address and the current date/time stamp to AREPLY.KFL
  6. A few minutes later Sender02 sends an email to the user
  7. Mercury checks the AREPLY.KFL file and doesn't find Sender02
  8. Mercury sends an auto reply to Sender02
  9. Mercury adds Sender02's address and the current date/time stamp to AREPLY.KFL
  10. A few minutes later Sender01 sends an email to the user
  11. Mercury checks the AREPLY.KFL file and finds Sender01
  12. It is within 48 hours since the last auto reply was sent to Sender01, so Mercury doesn't send an auto reply
  13. In the next 47 hours or so, 73 more senders (Sender03 through Sender75) send one or more emails to the user, with each sender receiving only one auto reply
  14. 47 hours and 58 minutes after the AREPLY.KFL file was created, Sender76 sends an email to the user
  15. Mercury checks the AREPLY.KFL file and doesn't find Sender76
  16. Mercury sends an auto reply to Sender76
  17. Mercury adds Sender76's address and the current date/time stamp to AREPLY.KFL
  18. 48 hours and 2 minutes after the AREPLY.KFL file was created, Sender76 sends an email to the user
  19. In the current implementation, Mercury deletes and recreates the AREPLY.KFL file because it is over 48 hours old
  20. Mercury sends an auto reply to Sender76 (the second one in a period of 4 minutes)
  21. Mercury adds Sender76's address and the current date/time stamp to AREPLY.KFL

As you can see, step 19 should never happen, as the age of the file is meaningless.  By deleting the file, relatively new senders will get a second auto reply in a short period of time.  The file should never be deleted unless auto reply is turned off for the user.  If a message comes in from a sender whose last auto reply was over 48 hours ago, Mercury should send an auto reply and update the date/time stamp for the sender in the AREPLY.KFL fle.

 

&lt;P&gt;When I first started reading this thread my first thought was &quot;Why would you delete the file at all?&quot;&amp;nbsp; You should never delete the file until auto reply is turned off for the user.&amp;nbsp; Everyone is wasting their time debating creation date/time problems with various flavors of the operating system and locales while losing sight of the real problem.&lt;/P&gt; &lt;P&gt;When I read the post by Graham (airyt - 2008-03-31) questioning the logic of deleting the file in the first place, I thought &quot;Finally, someone has pointed out the real problem!&quot; and that I wouldn&#039;t have to reply.&amp;nbsp; Then everyone, including Graham, ignored that and kept concentrating on the creation date/time problem.&lt;/P&gt; &lt;P&gt;In my opinon, Graham is correct in that the file should not be deleted and the date/time stamp of a given sender&#039;s auto reply should be kept in the file with the sender&#039;s address.&amp;nbsp; Pardon me, but I thought that this was rather obvious.&lt;/P&gt; &lt;P&gt;Think of the following scenario:&lt;/P&gt; &lt;OL&gt; &lt;LI&gt;Auto reply is turned on for a user&lt;/LI&gt; &lt;LI&gt;Sender01 sends an email&amp;nbsp;to the user&lt;/LI&gt; &lt;LI&gt;Mercury creates the AREPLY.KFL file&lt;/LI&gt; &lt;LI&gt;Mercury sends an auto reply to Sender01&lt;/LI&gt; &lt;LI&gt;Mercury adds Sender01&#039;s address and the current date/time stamp to AREPLY.KFL&lt;/LI&gt; &lt;LI&gt;A few minutes later Sender02 sends an email to the user&lt;/LI&gt; &lt;LI&gt;Mercury checks the AREPLY.KFL file and doesn&#039;t find&amp;nbsp;Sender02&lt;/LI&gt; &lt;LI&gt;Mercury sends&amp;nbsp;an auto reply to Sender02&lt;/LI&gt; &lt;LI&gt;Mercury adds Sender02&#039;s address and the current date/time stamp to AREPLY.KFL&lt;/LI&gt; &lt;LI&gt;A few minutes later Sender01 sends an email to the user&lt;/LI&gt; &lt;LI&gt;Mercury checks the AREPLY.KFL file and finds Sender01&lt;/LI&gt; &lt;LI&gt;It is within 48 hours since the last auto reply was sent to Sender01, so Mercury doesn&#039;t send an auto reply&lt;/LI&gt; &lt;LI&gt;In the next 47 hours or so, 73 more senders (Sender03 through Sender75)&amp;nbsp;send one or more emails to the user, with each sender receiving only one auto reply&lt;/LI&gt; &lt;LI&gt;47 hours and 58 minutes after the AREPLY.KFL file was created, Sender76 sends an email to the user&lt;/LI&gt; &lt;LI&gt;Mercury checks the AREPLY.KFL file and doesn&#039;t find Sender76&lt;/LI&gt; &lt;LI&gt;Mercury sends an auto reply to Sender76&lt;/LI&gt; &lt;LI&gt;Mercury adds Sender76&#039;s address and the current date/time stamp to AREPLY.KFL&lt;/LI&gt; &lt;LI&gt;48 hours and 2 minutes after the AREPLY.KFL file was created, Sender76 sends an email to the user&lt;/LI&gt; &lt;LI&gt;In the current implementation, Mercury deletes and recreates the AREPLY.KFL file because it is over 48 hours old&lt;/LI&gt; &lt;LI&gt;Mercury sends an auto reply to Sender76 (the second one in a period of 4 minutes)&lt;/LI&gt; &lt;LI&gt;Mercury adds Sender76&#039;s address and the current date/time stamp to AREPLY.KFL&lt;/LI&gt;&lt;/OL&gt; &lt;P&gt;As you can see, step 19 should never happen, as the age of the file is meaningless.&amp;nbsp; By deleting the&amp;nbsp;file, relatively new senders will get a second auto reply in a short period of time.&amp;nbsp; The file should never be deleted unless auto reply is turned off for the user.&amp;nbsp; If a message comes in from a sender whose last auto reply was over 48 hours ago, Mercury should send an auto reply and update the date/time stamp for the sender in the AREPLY.KFL fle.&lt;/P&gt; &lt;P mce_keep=&quot;true&quot;&gt;&amp;nbsp;&lt;/P&gt;
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft