user

Look up local passwd information V8.7 and later

The user type is used to look up passwd(5) information using the method defined by the MailboxDatabase option (MailboxDatabase on page 1042). A password entry typically looks like this:

ftp:*:1092:255:File Transfer Protocol Program:/u/ftp:/bin/sh

Here, there are seven fields, each separated from the others by colon characters. The key is always compared to the first field. The value returned is (by default) the first field unless you specify another field with a -v switch:

Kname user -vfield

Here, field can be either a number 1 through 7, or one of the names name, passwd, uid, gid, gecos, dir, or shell, which correspond to the numbers. For example, to look up usernames and get the full name (GECOS) field returned, you could use something such as this:

Kgetgecos user -vgecos
...
R$-        $: $( getgecos $1 $)

Note that this returns the full GECOS field in its rawest form. It is not cleaned up to provide a reliable full name, as is the $x macro ($x on page 851).

The user database-map type can be used in conjunction with the Local_check_rcpt rule set (Local_check_rcpt and check_rcpt on page 257). In the following, for example, we check to see whether a recipient is a local user and, if so, reject the user if that user’s home directory is /home/retired/tars:

Kislocal user -vdir SLocal_check_rcpt R$* $: $>canonify $1 focus on host R$* <@ $+ > $* $: $1 discard host R$+ $: $1 $(islocal $1 $) R$- /home/retired/tars $#error $@ 5.1.3 $: 553 Sorry, $1 ...

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.