How to make sendmail re-read the configuration file

How to make sendmail re-read the configuration file

Post by David Ellio » Tue, 02 Jan 1990 15:10:00



In our environment, it is possible for the sendmail configuration file
to change much more frequently than a machine is rebooted.

I looked at the code for sendmail, and could only find one place where
it reads the configuration file (in main()), and no way to send a
signal or message saying "re-read the configuration file". This means
that we have to kill the daemon and restart it manually (or at best
by finding the pid using ps, killing it, and restarting it with the
right arguments).

I would like to modify sendmail to have it re-read the configuration
file on some given signal (HUP?), but I am worried that sendmail
can't handle this without modifications elsewhere. Is there anyone
with a lot of sendmail experience that can help me out?

                        David

 
 
 

How to make sendmail re-read the configuration file

Post by Bruce Isra » Tue, 02 Jan 1990 14:08:00



>In our environment, it is possible for the sendmail configuration file
>to change much more frequently than a machine is rebooted.

>I would like to modify sendmail to have it re-read the configuration
>file on some given signal (HUP?), but I am worried that sendmail
>can't handle this without modifications elsewhere. Is there anyone
>with a lot of sendmail experience that can help me out?

I've been wanting such a signal myself, but haven't looked into adding
one.  We also have tables that the sendmail.cf file uses that are updated
on a nightly basis.  As a result, what we do is have a line in crontab
that looks like:

30  2 * * *     root    cd /usr/lib/hostnames/bin; /usr/local/bin/user bin /bin/make; kill `ps aux | egrep '/usr/lib/sendmail -bd -q15m' | awk '{print $2}'`; /usr/lib/sendmail -bd -q15m &

It's ugly, but it works.  Every night at 2:30am, cron updates all
necessary tables then kills off and restarts the daemon.

Bruce Israel

University of Maryland, Computer Science Dept.


 
 
 

How to make sendmail re-read the configuration file

Post by Barry She » Tue, 02 Jan 1990 21:20:00


Re: making sendmail re-read cf file on signal...

Assuming it's a hard thing to add, how about just a 10 line C program
which fork/execs sendmail (in a process group) and waits for the signal.
When received kills its child and starts another fresh one.

Not entirely sure what the advantage is over just killing and
rerunning the sendmail unless you're worried about the small window in
which there is no daemon running. I guess the little hack above could
put its pid into a file or something making it easier to find
(mqueue/.pid). Maybe just teaching sendmail to re-exec itself on
receipt of a signal would be sufficient (or have it squirrel away
the change date of the .cf file and re-exec on that updating, have
it check as it starts each q run.)

Just thinking out loud.

        -Barry Shein, Boston University

 
 
 

How to make sendmail re-read the configuration file

Post by Paul Sutcliffe J » Tue, 02 Jan 1990 09:52:00



> I would like to modify sendmail to have it re-read the configuration
> file on some given signal (HUP?), but I am worried that sendmail
> can't handle this without modifications elsewhere. Is there anyone
> with a lot of sendmail experience that can help me out?

Why not do what cron(1) does.  Perform a stat() call on the file's fd
after it is first opened and save the st_mtime value somewhere (the
last modification time of the file).  Then have sendmail re-stat the
file every time it is awakened, compare the new st_mtime value with the
saved one, and if the new one is greater (the config file has been
modified since the original read), re-read the file.

-paul

--
Paul Sutcliffe, Jr.      UUCP: {seismo,ihnp4,allegra,rutgers}!cbmvax!devon!paul
Devon Computer Services  COMPUSERVE: 76176,502
Allentown, Penna.        "I love work ..."
+1 215 398 3776          "... I could sit and watch people do it all day!"

 
 
 

How to make sendmail re-read the configuration file

Post by King Abl » Tue, 02 Jan 1990 21:36:00


Quote:>> I would like to modify sendmail to have it re-read the configuration
> Why not do what cron(1) does.  Perform a stat() call on the file's fd
> after it is first opened and save the st_mtime value somewhere (the
> last modification time of the file).  Then have sendmail re-stat the
> file every time it is awakened, compare the new st_mtime value with the
> saved one, and if the new one is greater (the config file has been
> modified since the original read), re-read the file.

Ah-ha!  That's just solved a problem for me.  I've got a bunch of
diskless suns and rather than have a different crontab for all
the suns on a server, I have all clients crontabs point to the
real crontab file.  However, when I make a change, it doesn't seem
to take unless I kill the cron daemon.  I never even thought of
stat()!  Of course, it's stat()ing the symbolic link (which hasn't
changed!) and not the real file.

Now, the question I have is why would you ever NOT want stat()
to resolve the link and stat the actual disk file rather than the
link???  And is there a way I can solve my problem short of
killing cron on all suns and restarting it or removing the link
and making a new one in its place (which would, of course, have
today's date)?  I tried a touch on the link, but of course,
touch resolves the link and touches the real file!!  **arghh!!**

-King

UUCP: {gatech,ihnp4,nbires,seismo,ucb-vax}!ut-sally!im4u!milano!mcc-pp!ables
-------
Michael: Women!
Larry:   Yeah.  Can't live with 'em... can't stuff 'em in a sack!

 
 
 

How to make sendmail re-read the configuration file

Post by Chris Tor » Tue, 02 Jan 1990 08:44:00


<... I've got a bunch of diskless suns and rather than have a
<different crontab for all the suns on a server, I have all clients
<crontabs point to the real crontab file.  However, when I make a
<change, it doesn't seem to take unless I kill the cron daemon.
<I never even thought of stat()!  Of course, it's stat()ing the
<symbolic link (which hasn't changed!) and not the real file.

That is rather strange if it is.

<Now, the question I have is why would you ever NOT want stat()
<to resolve the link and stat the actual disk file rather than the
<link???

Why?  Suppose you want to find out about the link.  In this case,
use lstat(), which does not follow the link.  The stat() call does
indeed follow symbolic links `and stat the actual disk file'.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)

 
 
 

How to make sendmail re-read the configuration file

Post by Eduardo Kre » Tue, 02 Jan 1990 11:16:00



>Now, the question I have is why would you ever NOT want stat()
>to resolve the link and stat the actual disk file rather than the
>link???

stat() always follows symbolic links; lstat() does not. You need lstat()
to see what the permissions are on (and who owns) a link, for instance.

Unless programs use lstat(), they will follow symbolic links and will be
unaware of their existence.
--

    Eduardo Krell                   AT&T Bell Laboratories, Murray Hill

    {ihnp4,seismo,ucbvax}!ulysses!ekrell

 
 
 

How to make sendmail re-read the configuration file

Post by Andrew Klossn » Tue, 02 Jan 1990 18:07:00


[]

        "I've got a bunch of diskless suns and rather than have a
        different crontab for all the suns on a server, I have all
        clients crontabs point to the real crontab file.  However, when
        I make a change, it doesn't seem to take unless I kill the cron
        daemon.  I never even thought of stat()!  Of course, it's
        stat()ing the symbolic link (which hasn't changed!) and not the
        real file.  Now, the question I have is why would you ever NOT
        want stat() to resolve the link and stat the actual disk file
        rather than the link???"

Something's wrong.  The 4.2BSD definition of stat(2) says that it gives
the status of the file to which the symlink points.  The lstat(2) call
gives the status of the symlink itself.

  -=- Andrew Klossner   (decvax!tektronix!tekecs!andrew)       [UUCP]

 
 
 

How to make sendmail re-read the configuration file

Post by Curtis Genero » Tue, 02 Jan 1990 16:04:00



>I would like to modify sendmail to have it re-read the configuration
>file on some given signal (HUP?), but I am worried that sendmail
>can't handle this without modifications elsewhere. Is there anyone
>with a lot of sendmail experience that can help me out?

I don't acknowlegde knowing very much about sendmail, but on our machine
(a VAX 780, running 4.2BSD), sendmail can be forced to read the
configuration file by performing the following steps:

       cp /dev/null /usr/lib/sendmail.fc  # erase old frozen configuration
       /usr/lib/sendmail -bz              # which reads the new configuration

-curtis-

Curtis C. Generous
Lawrence Livermore National Labs

...!{seismo,vrdxhq}!dgis!generous

 
 
 

How to make sendmail re-read the configuration file

Post by da.. » Tue, 02 Jan 1990 22:05:00


Re: making sendmail re-read cf file on signal...

I wrote a script which sits in a loop doing a ps and waiting for the
sendmail daemon to go idle.  Then it kills and restarts it.  There's
still a race condition, of course.  (Between the ps that shows an
idle sendmail and when the script executes the kill command.)

    Dave Lennert                ucbvax!hpda!davel               [UUCP]
    Hewlett-Packard - 47UX      ihnp4!hplabs!hpda!davel         [UUCP]

    Cupertino, CA  95014        (408) 447-6325                  [AT&T]

 
 
 

How to make sendmail re-read the configuration file

Post by Chris Tor » Tue, 02 Jan 1990 13:46:00



>... sendmail can be forced to read the configuration file by performing
>the following steps:

>    cp /dev/null /usr/lib/sendmail.fc  # erase old frozen configuration
>    /usr/lib/sendmail -bz              # which reads the new configuration

This tells sendmail to *rebuild* the frozen configuration file, which
affects any new `sendmail's run.  Alas, the background daemon that
periodically scans queued mail and that accepts incoming SMTP mail
never notices the change.

Adding a stat() call and rereading the configuration would be quite
tricky, as the frozen configuration is simply a memory dump of the
entire data segment.  There are only a few places where it is safe
to read this.  Easier would be to have sendmail exec itself, somehow
telling itself which file descriptor is the SMTP socket.  The
biggest problem with the method we use here (kill the daemon nightly
and then start a new one) is that, due to vagaries of TCP, sendmail
sometimes has trouble re-acquiring the SMTP port.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)

 
 
 

How to make sendmail re-read the configuration file

Post by m.. » Tue, 02 Jan 1990 21:31:00


As for the original question, the folks at ulysses run /usr/lib/sendmail -bs
from inetd.  You then need to put calls to /usr/lib/sendmail -q
in crontab, but this isn't such a bad idea anyway, since for some
reason it results in far fewer hung sendmail processes compared to
sendmail -bd -qxxxm.


shared crontab, I think the problem may be due to the caching in ND.
(I'm presuming that the shared copy is in /pub, not in an NFS
partition; we have the same problem with our shared /usr/lib/aliases,
which lives in ND rather than NFS so that we can control access to
it).  Modifying cron so it doesn't keep /usr/lib/crontab open all the
time, and periodically flushing the clients' disk caches should help.
We've found "du /pub" - we have several thousand files in our /pub -
and a couple "umount /pub"'s (umount will fail, of course,
but it does what we want) usually flush the cache.

        Mark Plotnick
        allegra!mp

 
 
 

How to make sendmail re-read the configuration file

Post by mo.. » Fri, 02 Feb 1990 21:14:00




> shared crontab, I think the problem may be due to the caching in ND.
> [...] and periodically flushing the clients' disk caches should help.
> We've found "du /pub" - we have several thousand files in our /pub -
> and a couple "umount /pub"'s (umount will fail, of course, but it
> does what we want) usually flush the cache.

Doesn't `sync' work?  There's a syscall sync() to flush the buffer
cache, and there's a program /etc/sync which calls it.

                                        der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse

 
 
 

How to make sendmail re-read the configuration file

Post by g.. » Fri, 02 Feb 1990 19:39:00


Quote:>> shared crontab, I think the problem may be due to the caching in ND.
>Doesn't `sync' work?  There's a syscall sync() to flush the buffer
>cache, and there's a program /etc/sync which calls it.

Umm, err...  having a writable ND partition available to more than
one machine is an error.  Would you take a vanilla UNIX kernel, put
in a driver for a dual-ported disk, and have a file system writable
by one machine and accessible to another machine, and expect it to
work?  I thought not.  Think of an ND partition as residing on a
multi-ported disk; it was not intended to be used in this fashion,
and has no "cache invalidate" operation to enable an ND client to
invalidate other ND clients' caches, so in that sense you still have
a vanilla UNIX kernel.

If you do a "sync" on a machine that has the disk mounted read-only,
it does nothing for you.  If you do it on a machine that has it
mounted read-write, it will push any unwritten blocks to the disk but
will *NOT* invalidate any copies of those blocks in any other
machine's cache.

 
 
 

1. How to have Linux re-read all the configuration file without reboot?

I read that to have Linux re-read all the configuration
files, initab, all the init files, etc, use the "telinit"
command.

Is this the proper way?

Is this sort of like rebooting the system without having
to use the "shutdown" command?

Are there things one should watch out for and are there
other things to do before issuing "telinit"?

Thanks
Stephen

2. remote oepnboot

3. How to re-read /etc/profile file at ksh without logout

4. US: OR: Portland: AIX Administrator

5. How to re-read Partition Table ??

6. Preventing unathorized TCP connections?

7. Re-read httpd.conf in Apache??

8. NE2000 compat. ISA card with UMC UM9003AF: opinions wanted..

9. [6/6] Always re-read vendor for each function

10. Problems with ftape-0.9.6: cannot re-read

11. re-read inittab?

12. Getting system to re-read conf.modules

13. 2.4.18: Re-read table failed with error 16: Device or resource busy - error