xref: /openbsd/usr.bin/getcap/getcap.1 (revision 09467b48)
1.\"	$OpenBSD: getcap.1,v 1.6 2019/09/02 21:18:41 deraadt Exp $
2.\"
3.\" Copyright (c) 2005 Todd C. Miller <millert@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 2 2019 $
18.Dt GETCAP 1
19.Os
20.Sh NAME
21.Nm getcap
22.Nd capability database access utility
23.Sh SYNOPSIS
24.Nm getcap
25.Oo
26.Fl b Ar boolean | Fl c Ar capability |
27.Fl n Ar number | Fl s Ar string
28.Oc
29.Fl f Ar path
30.Fl a | Ar record ...
31.Sh DESCRIPTION
32The
33.Nm
34utility provides a simple method for querying a capability database such as
35.Pa /etc/login.conf
36or
37.Pa /etc/printcap
38and as described by
39.Xr cgetent 3 .
40.Pp
41The following query types are supported:
42.Bl -tag -width "capability"
43.It boolean
44A boolean flag.
45For each matching record, the name of the boolean capability is printed
46(since there is no value per se).
47.It number
48A numeric capability (key#number).
49For each matching record, the value of the numeric capability is printed
50as a decimal number.
51To print a number in the same format as it is listed in the
52capabilities database (i.e. literally), use a
53.Dq raw
54query instead.
55.It string
56A string capability (key=value).
57Note that the value printed has escape sequences expanded: see
58.Xr cgetent 3
59for a list of valid escape sequences.
60To print the string exactly as it is listed in the
61capabilities database, use a
62.Dq raw
63query instead.
64.It raw
65A generic query where no interpretation of the data is done.
66Use this for querying capabilities with non-standard types or
67for getting the raw, unformatted entry from the database.
68.El
69.Pp
70.Nm
71prints the value associated with the given key.
72If more than one record is being searched, the value is prefixed
73with the record name (for records with multiple names, only the
74first is printed).
75If a key has no associated value and a boolean query is not being
76performed, a blank line will be printed.
77.Pp
78The options are as follows:
79.Bl -tag -width "-c capability"
80.It Fl a
81Query all records in the database.
82.It Fl b Ar boolean
83Return occurrences of
84.Ar boolean .
85.It Fl c Ar capability
86Return the raw value for the key
87.Ar capability ,
88which must include the type as the last character, e.g.\&
89.Dq foo=
90for the string
91.Sq foo .
92See
93.Xr cgetent 3
94for more information on capability types.
95.It Fl f Ar path
96A colon-separated list of database filenames to be searched for records.
97.It Fl n Ar number
98Return occurrences of
99.Ar number .
100.It Fl s Ar string
101Return occurrences of the string
102.Ar string .
103.El
104.Pp
105Only one of the
106.Fl b ,
107.Fl c ,
108.Fl n ,
109and
110.Fl s
111options may be specified.
112If none are specified, the record will be dumped from the database as is.
113.Sh FILES
114.Bl -tag -width "/etc/login.confXX" -compact
115.It Pa /etc/login.conf
116login configuration
117.It Pa /etc/printcap
118printer configuration
119.It Pa /etc/termcap
120terminal configuration
121.El
122.Sh EXAMPLES
123Find all
124.Xr login.conf 5
125entries with the
126.Dq ignorenologin
127capability:
128.Pp
129.Dl "$ getcap -f /etc/login.conf -a -b ignorenologin"
130.Pp
131Dump the
132.Dq default
133record in
134.Xr login.conf 5 :
135.Pp
136.Dl "$ getcap -f /etc/login.conf default"
137.Pp
138Print all
139.Xr login.conf 5
140records with the
141.Dq localcipher
142capability:
143.Pp
144.Dl "$ getcap -f /etc/login.conf -a -s localcipher"
145.Pp
146Print the
147.Dq datasize-max
148capability in the
149.Dq staff
150record in
151.Xr login.conf 5
152if it exists:
153.Pp
154.Dl "$ getcap -f /etc/login.conf -s datasize-max staff"
155.Pp
156Print all
157.Xr printcap 5
158entries that reference
159.Pa /dev/lp .
160Note that we are treating the entire string
161.Dq lp=/dev/lp
162as a boolean flag instead of a key/value pair.
163.Pp
164.Dl "$ getcap -f /etc/printcap -a -b lp=/dev/lp"
165.Sh SEE ALSO
166.Xr cap_mkdb 1 ,
167.Xr cgetent 3 ,
168.Xr login.conf 5 ,
169.Xr printcap 5 ,
170.Xr termcap 5
171.Sh HISTORY
172The
173.Nm
174command appeared in
175.Ox 3.7 .
176.Sh AUTHORS
177.An Todd C. Miller
178