1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright (C) 1999, Sun Microsystems, Inc. All Rights Reserved
.\" Copyright (c) 2014 Gary Mills
.\" Copyright (c) 2018 Peter Tribble
.\"
.Dd August 13, 2018
.Dt GETENT 1M
.Os
.Sh NAME
.Nm getent
.Nd get entries from administrative database
.Sh SYNOPSIS
.Nm
.Ar database
.Oo Ar key Oc Ns ...
.Sh DESCRIPTION
.Nm
gets a list of entries from the administrative database specified by
.Ar database .
The information generally comes from one or more of the sources that are
specified for the
.Ar database
in
.Pa /etc/nsswitch.conf .
.Pp
.Ar database
is the name of the database to be examined.
This can be
.Cm passwd ,
.Cm shadow ,
.Cm group ,
.Cm hosts ,
.Cm ipnodes ,
.Cm services ,
.Cm protocols ,
.Cm ethers ,
.Cm project ,
.Cm networks ,
.Cm netmasks ,
.Cm auth_attr ,
.Cm exec_attr ,
.Cm prof_attr ,
or
.Cm user_attr .
For each of these databases,
.Nm
uses the appropriate library routines described in
.Xr getpwnam 3C ,
.Xr getspnam 3C ,
.Xr getgrnam 3C ,
.Xr gethostbyaddr 3NSL ,
.Xr gethostbyname 3NSL ,
.Xr getipnodebyaddr 3SOCKET ,
.Xr getipnodebyname 3SOCKET ,
.Xr getservbyname 3SOCKET ,
.Xr getprotobyname 3SOCKET ,
.Xr ethers 3SOCKET ,
.Xr getprojbyname 3PROJECT ,
.Xr getnetbyname 3SOCKET ,
.Xr getauthattr 3SECDB ,
.Xr getexecattr 3SECDB ,
.Xr getprofattr 3SECDB ,
and
.Xr getuserattr 3SECDB
respectively.
.Pp
Each
.Ar key
must be in a format appropriate for searching on the respective database.
For example, it can be a username or numeric-uid for
.Cm passwd ;
hostname or IP address for
.Cm hosts ;
or service, service/protocol, port, or port/proto for
.Cm services .
.Pp
.Nm
prints out the database entries that match each of the supplied keys, one per
line, in the format of the matching administrative file:
.Xr passwd 4 ,
.Xr shadow 4 ,
.Xr group 4 ,
.Xr project 4 ,
.Xr hosts 4 ,
.Xr services 4 ,
.Xr protocols 4 ,
.Xr ethers 4 ,
.Xr networks 4 ,
.Xr netmasks 4 ,
.Xr auth_attr 4 ,
.Xr exec_attr 4 ,
.Xr prof_attr 4 ,
or
.Xr user_attr 4 .
If no key is given, all entries returned by the corresponding enumeration
library routine, for example,
.Xr getpwent 3C
or
.Xr gethostent 3NSL ,
are printed.
Enumeration is not supported on
.Cm ipnodes ,
.Cm ethers ,
or
.Cm netmasks .
.Ss Key Interpretation for passwd, group, and user_attr Databases
When
.Nm
is invoked with
.Ar database
set to
.Cm passwd ,
each key value is processed as follows:
.Bl -bullet
.It
If the key value consists only of numeric characters,
.Nm
assumes that the key value is a numeric user ID and searches the
.Cm passwd
database for a matching user ID.
.It
If the user ID is not found in the
.Cm passwd
database or if the key value contains any non-numeric characters,
.Nm
assumes the key value is a user name and searches the
.Cm passwd
database for a matching user name.
.El
.Pp
When
.Nm
is invoked with
.Ar database
set to
.Cm group ,
each key value is processed as follows:
.Bl -bullet
.It
If the key value consists only of numeric characters,
.Nm
assumes that the key value is a numeric group ID and searches the
.Cm group
database for a matching group ID.
.It
If the group ID is not found in the
.Cm group
database or if the key value contains any non-numeric characters,
.Nm
assumes the key value is a group name and searches the
.Cm group
database for a matching group name.
.El
.Pp
When
.Nm
is invoked with
.Ar database
set to
.Cm user_attr ,
each key value is processed as follows:
.Bl -bullet
.It
If the key value consists only of numeric characters,
.Nm
assumes that the key value is a numeric user ID and searches the
.Cm passwd
database for a matching user name, which is then used as the key for
.Cm user_attr .
.It
If the user ID is not found in the
.Cm passwd
database or if the key value contains any non-numeric characters,
.Nm
assumes the key value is a user name and searches the
.Cm user_attr
database for a matching entry.
.El
.Sh FILES
.Bl -tag -width Pa
.It Pa /etc/nsswitch.conf
name service switch configuration file
.It Pa /etc/passwd
password file
.It Pa /etc/shadow
shadowed password file
.It Pa /etc/group
group file
.It Pa /etc/inet/hosts
IPv4 and IPv6 host name database
.It Pa /etc/services
Internet services and aliases
.It Pa /etc/project
project file
.It Pa /etc/protocols
protocol name database
.It Pa /etc/ethers
Ethernet address to hostname database or domain
.It Pa /etc/networks
network name database
.It Pa /etc/netmasks
network mask database
.It Pa /etc/user_attr
extended user attributes database
.It Pa /etc/security/auth_attr
authorization description database
.It Pa /etc/security/exec_attr
execution profiles database
.It Pa /etc/security/prof_attr
profile description database
.El
.Sh EXIT STATUS
The following exit values are returned:
.Pp
.Bl -tag -width Ds -compact
.It Sy 0
Successful completion.
.It Sy 1
Command syntax was incorrect, an invalid option was used, or an internal error
occurred.
.It Sy 2
At least one of the specified entry names was not found in the database.
.It Sy 3
There is no support for enumeration on this database.
.El
.Sh SEE ALSO
.Xr getgrnam 3C ,
.Xr getpwnam 3C ,
.Xr getspnam 3C ,
.Xr gethostbyaddr 3NSL ,
.Xr gethostbyname 3NSL ,
.Xr gethostent 3NSL ,
.Xr getprojbyname 3PROJECT ,
.Xr getauthattr 3SECDB ,
.Xr getexecattr 3SECDB ,
.Xr getprofattr 3SECDB ,
.Xr getuserattr 3SECDB ,
.Xr ethers 3SOCKET ,
.Xr getipnodebyaddr 3SOCKET ,
.Xr getipnodebyname 3SOCKET ,
.Xr getnetbyname 3SOCKET ,
.Xr getprotobyname 3SOCKET ,
.Xr getservbyname 3SOCKET ,
.Xr auth_attr 4 ,
.Xr ethers 4 ,
.Xr exec_attr 4 ,
.Xr group 4 ,
.Xr hosts 4 ,
.Xr netmasks 4 ,
.Xr networks 4 ,
.Xr nsswitch.conf 4 ,
.Xr passwd 4 ,
.Xr prof_attr 4 ,
.Xr project 4 ,
.Xr protocols 4 ,
.Xr services 4 ,
.Xr shadow 4 ,
.Xr user_attr 4 ,
.Xr attributes 5
|