Previous Section Next Section

15.1 Alternative argv[0] Names

The sendmail program can exist in any of several places, depending on the version of the operating system you are running. Usually, it is located in the /usr/sbin directory and is called sendmail,[1] but it can alternatively be located in the /etc, /usr/lib, /usr/libexec, or /usr/etc directory. The location of the sendmail program can be found by examining the /etc/rc files for BSD Unix or the /etc/init.d files for Sys V Unix (Section 1.6.11). On some BSD-derived systems, the mailwrapper program and its /etc/mail/mailer.conf file define where sendmail is located.

[1] On SunOS 4.x systems you will find /usr/lib/sendmail.mx for use with the Domain Name System.

In addition to the name sendmail, other names (in other directories) can exist that alter the behavior of sendmail. Those alternative names are usually symbolic links to /usr/sbin/sendmail. On some systems they can be hard links, and in rare cases you might actually find them to be copies. The complete list of other names is shown in Table 15-1.

Table 15-1. Alternative names for sendmail

Name

§

Mode of operation

hoststat

Section 15.1.1

Print persistent host status (V8.8 and above)

mailq

Section 15.1.2

Print the queue contents

newaliases

Section 15.1.3

Rebuild the aliases file

purgestat

Section 15.1.4

Purge persistent host status (V8.8 and above)

smtpd

Section 15.1.5

Run in daemon mode

When sendmail looks for the name under which it is running, it strips any leading directory components from argv[0] and compares the result (in a case-sensitive fashion) to its internal list of alternative names. If a match is found, its mode of operation is changed to conform to that of the alternative name. If no match is found (if, say, a link is named Mailq, note the uppercase M), sendmail does not change its mode.

The name that is found is used to build an argument list for use with process listings. For example, if the name was sendmail.mx (from SunOS), a process listing produced with ps(1) would look something like this:

root  1247  620 p0 S  07:22 0:00 -AA15186 (sendmail.mx)

Here, the (sendmail.mx) shows that sendmail was run under the name sendmail.mx.

Prior to V8.10, the hardcoded name "sendmail" was used for logging purposes with syslog(3) (Section 14.3.1). Therefore, logged errors and warnings always appeared to come from sendmail, regardless of the name used to run it.

Beginning with V8.10, sendmail recognizes the -L command-line switch (-L) to set the name that will be logged with syslog(3). Note, however, that the default name is still "sendmail."

Finally, be aware that command-line switches are processed immediately after the name but before sendmail finalizes its mode of operation. Thus, the use of particular switches can completely cancel any special meaning given to a name.

15.1.1 hoststat (V8.8 and Above)

The hoststat command is a synonym for the -bh command-line switch. It causes sendmail to print its persistent host status and exit. Persistent host status is enabled with the HostStatusDirectory option (HostStatusDirectory).

The output produced by this command begins with a heading such as this:

-------------- Hostname --------------- How long ago ---------Results---------

Then for each host whose status it has saved, sendmail prints this information:

Hostname

This is the name of the host that was connected to. It might not be the hostname specified for the recipient. It could easily be an MX record instead. If a message has multiple recipients, a separate status line will be produced for each unique host that is tried. If this name is prefixed with an asterisk, the status file is locked and currently being updated.

How long ago

This shows how long ago this status record was updated. It is printed in the form:

DD+HH:MM:SS

Here, DD is the number of days. If the status were updated less than one day ago, the DD+ is omitted. The HH is hours, the MM is minutes, and the SS is seconds. The colons are literal.

Results

This shows the result of the last connection attempt, failure, or success. If no reason was stored, this prints as:

No status available

If a result was stored, it will print in two parts:

smtp msg

The smtp is the SMTP reply code. The msg is the text of the message generated by the other end or other program.

To illustrate, consider this output:

-------------- Hostname --------------- How long ago ---------Results---------
there.ufoa.edu                              00:00:51 250 f21IuJf8029510 Message acce
*books.orielly.com                          07:43:39 250 f21KGlGS029512 Message acce
progr.ammers.com                            06:55:08 No status available
fbi.dc.gov                                  03:28:53 Connection refused

Here, the previous connections to there.ufoa.edu and books.ora.com were successful. The status for books.ora.com is currently being updated, hence the asterisk showing it is locked. The host prog.ammers.com shows no status because connection to it could not be made. The last example shows that the connection to fbi.dc.gov was refused by that host.

Note that the results are limited to 27 characters unless the -v command-line switch (-v) is also used. In that case, results are limited to 79 characters, thus providing more complete information.

15.1.2 mailq

The name mailq (a synonym for the -bp command-line switch) causes sendmail to print the contents of its mail queues and then exit (Section 11.6).

Note that the location of the queues is set with the QueueDirectory option (QueueDirectory). That location can be overridden from the command line, but if it is, sendmail might give up its special privileges (unless it was run by root).

15.1.3 newaliases

The name newaliases (a synonym for the -bi command-line switch) causes sendmail to rebuild all the aliases database files, print summary information, and then immediately exit (Section 12.5.1). In this mode the -v command-line switch (-v) is automatically implied, and sendmail runs in verbose mode.

The location of the aliases file is given in the configuration file with the AliasFile option (Section 24.9). That location can be overridden from the command line, but if it is, sendmail gives up its special privileges (unless it was run by root).

15.1.4 purgestat (V8.8 and Above)

The name purgestat is a synonym for the V8.8 and above -bH command-line switch (-bH). It causes sendmail to clear (purge) all the host-status information that was being saved under the HostStatusDirectory option's directory (HostStatusDirectory). Clearing is done by removing all the directories under the HostStatusDirectory directory. Note that the HostStatusDirectory directory is not itself removed.

Beginning with V8.10, sendmail purges host-status information only for hosts that exceed the setting of the Timeout.hoststatus option (See this section).

15.1.5 smtpd

The name smtpd is a synonym for the -bd command-line switch (-bd). It causes sendmail to run in the background as a daemon, listening for incoming SMTP mail (Section 1.7.1.2). This mode of operation is usually combined with the -q command-line switch (Section 11.8.1), which causes sendmail to periodically process the queue.

    Previous Section Next Section