summaryrefslogtreecommitdiffstats
path: root/man5/nsswitch.conf.5
blob: 49b288ef550b6152d999e3c742959f507607c108 (plain)
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
.\" Copyright (c) 1998, 1999 Thorsten Kukuk (kukuk@vt.uni-paderborn.de)
.\" Copyright (c) 2011, Mark R. Bannister <cambridge@users.sourceforge.net>
.\"
.\" SPDX-License-Identifier: GPL-2.0-or-later
.\"
.TH nsswitch.conf 5 2023-05-03 "Linux man-pages 6.05.01"
.SH NAME
nsswitch.conf \- Name Service Switch configuration file
.SH DESCRIPTION
The Name Service Switch (NSS) configuration file,
.IR /etc/nsswitch.conf ,
is used by the GNU C Library and certain other applications to determine
the sources from which to obtain name-service information in
a range of categories,
and in what order.
Each category of information is identified by a database name.
.PP
The file is plain ASCII text, with columns separated by spaces or tab
characters.
The first column specifies the database name.
The remaining columns describe the order of sources to query and a
limited set of actions that can be performed by lookup result.
.PP
The following databases are understood by the GNU C Library:
.TP 12
.B aliases
Mail aliases, used by
.BR getaliasent (3)
and related functions.
.TP
.B ethers
Ethernet numbers.
.TP
.B group
Groups of users, used by
.BR getgrent (3)
and related functions.
.TP
.B hosts
Host names and numbers, used by
.BR gethostbyname (3)
and related functions.
.TP
.B initgroups
Supplementary group access list, used by
.BR getgrouplist (3)
function.
.TP
.B netgroup
Network-wide list of hosts and users, used for access rules.
C libraries before glibc 2.1 supported netgroups only over NIS.
.TP
.B networks
Network names and numbers, used by
.BR getnetent (3)
and related functions.
.TP
.B passwd
User passwords, used by
.BR getpwent (3)
and related functions.
.TP
.B protocols
Network protocols, used by
.BR getprotoent (3)
and related functions.
.TP
.B publickey
Public and secret keys for Secure_RPC used by NFS and NIS+.
.TP
.B rpc
Remote procedure call names and numbers, used by
.BR getrpcbyname (3)
and related functions.
.TP
.B services
Network services, used by
.BR getservent (3)
and related functions.
.TP
.B shadow
Shadow user passwords, used by
.BR getspnam (3)
and related functions.
.PP
The GNU C Library ignores databases with unknown names.
Some applications use this to implement special handling for their own
databases.
For example,
.BR sudo (8)
consults the
.B sudoers
database.
Delegation of subordinate user/group IDs
can be configured using the
.B subid
database.
Refer to
.BR subuid (5)
and
.BR subgid (5)
for more details.
.PP
Here is an example
.I /etc/nsswitch.conf
file:
.PP
.in +4n
.EX
passwd:         compat
group:          compat
shadow:         compat
\&
hosts:          dns [!UNAVAIL=return] files
networks:       nis [NOTFOUND=return] files
ethers:         nis [NOTFOUND=return] files
protocols:      nis [NOTFOUND=return] files
rpc:            nis [NOTFOUND=return] files
services:       nis [NOTFOUND=return] files
.EE
.in
.PP
The first column is the database name.
The remaining columns specify:
.IP \[bu] 3
One or more service specifications, for example, "files", "db", or "nis".
The order of the services on the line determines the order in which
those services will be queried, in turn, until a result is found.
.IP \[bu]
Optional actions to perform if a particular result is obtained
from the preceding service, for example, "[NOTFOUND=return]".
.PP
The service specifications supported on your system depend on the
presence of shared libraries, and are therefore extensible.
Libraries called
.IB /lib/libnss_SERVICE.so. X
will provide the named
.IR SERVICE .
On a standard installation, you can use
"files", "db", "nis", and "nisplus".
For the
.B hosts
database, you can additionally specify "dns".
For the
.BR passwd ,
.BR group ,
and
.B shadow
databases, you can additionally specify
"compat" (see
.B "Compatibility mode"
below).
The version number
.B X
may be 1 for glibc 2.0, or 2 for glibc 2.1 and later.
On systems with additional libraries installed, you may have access to
further services such as "hesiod", "ldap", "winbind", and "wins".
.PP
An action may also be specified following a service specification.
The action modifies the behavior following a result obtained
from the preceding data source.
Action items take the general form:
.PP
.RS 4
.RI [ STATUS = ACTION ]
.br
.RI [! STATUS = ACTION ]
.RE
.PP
where
.PP
.RS 4
.I STATUS
=>
.B success
|
.B notfound
|
.B unavail
|
.B tryagain
.br
.I ACTION
=>
.B return
|
.B continue
|
.B merge
.RE
.PP
The ! negates the test, matching all possible results except the
one specified.
The case of the keywords is not significant.
.PP
The
.I STATUS
value is matched against the result of the lookup function called by
the preceding service specification, and can be one of:
.RS 4
.TP 12
.B success
No error occurred and the requested entry is returned.
The default action for this condition is "return".
.TP
.B notfound
The lookup succeeded, but the requested entry was not found.
The default action for this condition is "continue".
.TP
.B unavail
The service is permanently unavailable.
This can mean either that the
required file cannot be read, or, for network services, that the server
is not available or does not allow queries.
The default action for this condition is "continue".
.TP
.B tryagain
The service is temporarily unavailable.
This could mean a file is
locked or a server currently cannot accept more connections.
The default action for this condition is "continue".
.RE
.PP
The
.I ACTION
value can be one of:
.RS 4
.TP 12
.B return
Return a result now.
Do not call any further lookup functions.
However, for compatibility reasons, if this is the selected action for the
.B group
database and the
.B notfound
status, and the configuration file does not contain the
.B initgroups
line, the next lookup function is always called,
without affecting the search result.
.TP
.B continue
Call the next lookup function.
.TP
.B merge
.I [SUCCESS=merge]
is used between two database entries.
When a group is located in the first of the two group entries,
processing will continue on to the next one.
If the group is also found in the next entry (and the group name and GID
are an exact match), the member list of the second entry will be added
to the group object to be returned.
Available since glibc 2.24.
Note that merging will not be done for
.BR getgrent (3)
nor will duplicate members be pruned when they occur in both entries
being merged.
.RE
.SS Compatibility mode (compat)
The NSS "compat" service is similar to "files" except that it
additionally permits special entries in corresponding files
for granting users or members of netgroups access to the system.
The following entries are valid in this mode:
.RS 4
.PP
For
.B passwd
and
.B shadow
databases:
.RS 4
.TP 12
.BI + user
Include the specified
.I user
from the NIS passwd/shadow map.
.TP
.BI +@ netgroup
Include all users in the given
.IR netgroup .
.TP
.BI \- user
Exclude the specified
.I user
from the NIS passwd/shadow map.
.TP
.BI \-@ netgroup
Exclude all users in the given
.IR netgroup .
.TP
.B +
Include every user, except previously excluded ones, from the
NIS passwd/shadow map.
.RE
.PP
For
.B group
database:
.RS 4
.TP 12
.BI + group
Include the specified
.I group
from the NIS group map.
.TP
.BI \- group
Exclude the specified
.I group
from the NIS group map.
.TP
.B +
Include every group, except previously excluded ones, from the
NIS group map.
.RE
.RE
.PP
By default, the source is "nis", but this may be
overridden by specifying any NSS service except "compat" itself
as the source for the pseudo-databases
.BR passwd_compat ,
.BR group_compat ,
and
.BR shadow_compat .
.SH FILES
A service named
.I SERVICE
is implemented by a shared object library named
.IB libnss_SERVICE.so. X
that resides in
.IR /lib .
.RS 4
.TP 25
.PD 0
.I /etc/nsswitch.conf
NSS configuration file.
.TP
.IB /lib/libnss_compat.so. X
implements "compat" source.
.TP
.IB /lib/libnss_db.so. X
implements "db" source.
.TP
.IB /lib/libnss_dns.so. X
implements "dns" source.
.TP
.IB /lib/libnss_files.so. X
implements "files" source.
.TP
.IB /lib/libnss_hesiod.so. X
implements "hesiod" source.
.TP
.IB /lib/libnss_nis.so. X
implements "nis" source.
.TP
.IB /lib/libnss_nisplus.so. X
implements "nisplus" source.
.PD
.RE
.PP
The following files are read when "files" source is specified
for respective databases:
.RS 4
.TP 12
.PD 0
.B aliases
.I /etc/aliases
.TP
.B ethers
.I /etc/ethers
.TP
.B group
.I /etc/group
.TP
.B hosts
.I /etc/hosts
.TP
.B initgroups
.I /etc/group
.TP
.B netgroup
.I /etc/netgroup
.TP
.B networks
.I /etc/networks
.TP
.B passwd
.I /etc/passwd
.TP
.B protocols
.I /etc/protocols
.TP
.B publickey
.I /etc/publickey
.TP
.B rpc
.I /etc/rpc
.TP
.B services
.I /etc/services
.TP
.B shadow
.I /etc/shadow
.PD
.RE
.SH NOTES
Starting with glibc 2.33,
.\" https://sourceware.org/bugzilla/show_bug.cgi?id=12459
.B nsswitch.conf
is automatically reloaded if the file is changed.
In earlier versions, the entire file was read only once within each process.
If the file was later changed,
the process would continue using the old configuration.
.PP
Traditionally, there was only a single source for service information,
often in the form of a single configuration
file (e.g., \fI/etc/passwd\fP).
However, as other name services, such as the Network Information
Service (NIS) and the Domain Name Service (DNS), became popular,
a method was needed
that would be more flexible than fixed search orders coded into
the C library.
The Name Service Switch mechanism,
which was based on the mechanism used by
Sun Microsystems in the Solaris 2 C library,
introduced a cleaner solution to the problem.
.SH SEE ALSO
.BR getent (1),
.BR nss (5)