program

program

Run an external program to look up the key V8.7 and above

The program type allows you to perform lookups via arbitrary external programs. The form for the declaration of this database-map type looks like this:

 K  name program  /path  arg1 arg2 ..  . 

The /path must be the full pathname to the program. Relative paths will not work, and attempts to use them will log the following error and cause the lookup to fail:

 NOQUEUE: SYSERR(  user)  :  relative name  : cannot exec: No such file or directory 

The program is run as the user and group specified by the DefaultUser option (DefaultUser), unless the RunAsUser option (RunAsUser) is declared, in which case it will run as the user and group declared by that latter option.

The arguments to the program always have the key to be looked up added as a final argument:

 K  name program  /path  arg1 arg2 ..  .   key added here  

This is the only way the key can be passed to the program. The key will specifically not be piped to the program's standard input.

The value (result of the lookup) is read from the program's standard output. Only the first MAXLINE-1 characters are read (where MAXLINE is defined in conf.h , currently as 2048). The read result is processed like an address and placed into the workspace (unless the -m switch is used with the K command).

To illustrate , consider the need to look up a user's preferred address in an external relational database:

 Kilook program /usr/sbin/ingres_lookup -d users.database 

This program has been custom-written to accept the key as its final argument. To prevent spurious errors, it exits with a zero value regardless of whether the key is found. Any system errors cause it to exit with a value selected from those defined in <sysexits.h > (those recognized by sendmail ). Error messages are printed to the standard error output, and the found value (if there was one) is printed to the standard output.

In general, it is better to use one of the database formats known to sendmail than to attempt to look up keys via external programs. The process of fork (2)ing and exec (2)ing the program can become expensive if it is done often, slowing down the handling of mail.

This type of database map employs only a small set of switches. They are listed in Table 23-23.

Table 23-23. The program database-map type K command switches

Switch

Description

-a

-a

Append tag on successful match

-D

-D

Don't use this database map if DeliveryMode= defer

-m

-m

Suppress replacement on match

-q

-q

Don't strip quotes from key

-S

-S

Space replacement character

-T

-T

Suffix to append on temporary failure

-t

-t

Ignore temporary errors



Sendmail
sendmail, 4th Edition
ISBN: 0596510292
EAN: 2147483647
Year: 2002
Pages: 1174

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net