Duplicates Discarded
When sendmail gathers its list of recipients, it views a program to run as just another recipient. Before performing any delivery, it sorts the list of recipients and discards any duplicates. Ordinarily, this is just the behavior that is desired, but discarding duplicate programs from the aliases(5) file[202] can cause some users to lose mail. To illustrate, consider a program that notifies the system administrator that mail has arrived for a retired user:
#!/bin/sh /usr/ucb/mail -s gone postmaster
This script reads everything (the mail message) from
its standard input and feeds what it reads to the
/usr/ucb/mail program. The
command-line arguments to mail
are a subject line of gone
and a recipient of postmaster
. Now consider
two aliases that use this program:
george: "|/usr/local/bin/gone" ben: "|/usr/local/bin/gone"
When mail is sent to both george
and ben
, sendmail
aliases each to the program |/usr/local/bin/gone
. But because both
of the addresses are identical,
sendmail discards one.
To avoid this problem, design all delivery programs to require at least one unique argument. For example, the previous program should be rewritten to require the user’s name as an argument:
#!/bin/sh if [ ${#} -ne 2 ]; then echo $0 needs a username. exit fi /usr/ucb/mail -s "$1 gone" postmaster
By requiring a username as an argument, the once-faulty aliases are made unique:
george: "|/usr/local/bin/gone george" ben: "|/usr/local/bin/gone ben"
Although the program paths are still the ...
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.