OpenBSD manual page server

Manual Page Search Parameters
GETCAP(1) General Commands Manual GETCAP(1)

getcapcapability database access utility

getcap [-b boolean | -c capability | -n number | -s string] -f path -a | record ...

The getcap utility provides a simple method for querying a capability database such as /etc/login.conf or /etc/printcap and as described by cgetent(3).

The following query types are supported:

boolean
A boolean flag. For each matching record, the name of the boolean capability is printed (since there is no value per se).
number
A numeric capability (key#number). For each matching record, the value of the numeric capability is printed as a decimal number. To print a number in the same format as it is listed in the capabilities database (i.e. literally), use a “raw” query instead.
string
A string capability (key=value). Note that the value printed has escape sequences expanded: see cgetent(3) for a list of valid escape sequences. To print the string exactly as it is listed in the capabilities database, use a “raw” query instead.
raw
A generic query where no interpretation of the data is done. Use this for querying capabilities with non-standard types or for getting the raw, unformatted entry from the database.

getcap prints the value associated with the given key. If more than one record is being searched, the value is prefixed with the record name (for records with multiple names, only the first is printed). If a key has no associated value and a boolean query is not being performed, a blank line will be printed.

The options are as follows:

Query all records in the database.
boolean
Return occurrences of boolean.
capability
Return the raw value for the key capability, which must include the type as the last character, e.g. “foo=” for the string ‘foo’. See cgetent(3) for more information on capability types.
path
A colon-separated list of database filenames to be searched for records.
number
Return occurrences of number.
string
Return occurrences of the string string.

Only one of the -b, -c, -n, and -s options may be specified. If none are specified, the record will be dumped from the database as is.

/etc/login.conf
login configuration
/etc/printcap
printer configuration
/etc/termcap
terminal configuration

Find all login.conf(5) entries with the “ignorenologin” capability:

$ getcap -f /etc/login.conf -a -b ignorenologin

Dump the “default” record in login.conf(5):

$ getcap -f /etc/login.conf default

Print all login.conf(5) records with the “localcipher” capability:

$ getcap -f /etc/login.conf -a -s localcipher

Print the “datasize-max” capability in the “staff” record in login.conf(5) if it exists:

$ getcap -f /etc/login.conf -s datasize-max staff

Print all printcap(5) entries that reference /dev/lp. Note that we are treating the entire string “lp=/dev/lp” as a boolean flag instead of a key/value pair.

$ getcap -f /etc/printcap -a -b lp=/dev/lp

cap_mkdb(1), cgetent(3), login.conf(5), printcap(5), termcap(5)

The getcap command appeared in OpenBSD 3.7.

Todd C. Miller

September 2, 2019 OpenBSD-current