Re: [EXIM] A solution to POP-before-relay!

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Doug S
CC: exim-users
Subject: Re: [EXIM] A solution to POP-before-relay!
On Thu, 30 Jul 1998, Doug S wrote:

> It involves 4 scripts, the first three run at boot-time and the fourth
> from root's crontab:
>
> - one to watch the syslog to get host names and IP's
> - one to update a file referred to in exim's configure file
> - one to clean up old authorizations
> - one that kills and restarts the first script after the syslog is rotated


You might (if you want to) be able to dispense with the fourth one.
Eximon handles this by checking the inode number of the log file to see
if it has changed, using the code below.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.



/*                   
The test for a changed log file is to look up the inode of the file by name and
compare it with the saved inode of the file we currently are processing. This
accords with the usual interpretation of POSIX and other Unix specs that imply
"one file, one inode". However, it appears that on some Digital systems, if an
open file is unlinked, a new file may be created with the same inode while the
old file remains in existence. This can happen if the old log file is renamed,
processed in some way, and then deleted. To work round this, also test for a
link count of zero on the currently open file. */


if (LOG == NULL ||
    (fstat(fileno(LOG), &statdata) == 0 && statdata.st_nlink == 0) ||
    (stat(log_file, &statdata) == 0 && log_inode != statdata.st_ino)) 
  {                                                             
  FILE *TEST;                                                        


/* Experiment shows that sometimes you can't immediately open
the new log file - presumably immediately after the old one
is renamed and before the new one exists. Therefore do a
trial open first to be sure. */

  if ((TEST = fopen(log_file, "r")) != NULL)
    {
    if (LOG != NULL) fclose(LOG);                       
    LOG = TEST;             
    fstat(fileno(LOG), &statdata);
    log_inode = statdata.st_ino;                     
    }          
  }




--
*** Exim information can be found at http://www.exim.org/ ***