]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/exportfs/exports.man
2001-12-26 Chip Salzenberg <chip@pobox.com>
[nfs-utils.git] / utils / exportfs / exports.man
1 .TH EXPORTS 5 "28 October 1999"
2 .UC 5
3 .SH NAME
4 exports \- NFS file systems being exported (for Kernel based NFS)
5 .SH SYNOPSIS
6 .B /etc/exports
7 .SH DESCRIPTION
8 The file
9 .I /etc/exports
10 serves as the access control list for file systems which may be
11 exported to NFS clients.  It is used by
12 .IR exportfs (8)
13 to give information to
14 .IR mountd (8)
15 and to the kernel based NFS file server daemon
16 .IR nfsd (8).
17 .PP
18 The file format is similar to the SunOS
19 .I exports
20 file. Each line contains an export point and a whitespace-separated list
21 of clients allowed to mount the file system at that point. Each listed
22 client may be immediately followed by a parenthesized, comma-separated
23 list of export options for that client. No whitespace is permitted
24 between a client and its option list.
25 .PP
26 Blank lines are ignored.  A pound sign ("#") introduces a comment to the
27 end of the line. Entries may be continued across newlines using a
28 backslash. If an export name contains spaces it should be quoted using
29 double quotes. You can also specify spaces or other unusual character in
30 the export name using a backslash followed by the character code as three
31 octal digits.
32 .PP
33 .SS Machine Name Formats
34 NFS clients may be specified in a number of ways:
35 .IP "single host
36 This is the most common format. You may specify a host either by an
37 abbreviated name recognized be the resolver, the fully qualified domain
38 name, or an IP address.
39 .IP "netgroups
40 NIS netgroups may be given as
41 .IR @group .
42 Only the host part of each
43 netgroup members is consider in checking for membership.  Empty host
44 parts or those containing a single dash (\-) are ignored.
45 .IP "wildcards
46 Machine names may contain the wildcard characters \fI*\fR and \fI?\fR.
47 This can be used to make the \fIexports\fR file more compact; for instance,
48 \fI*.cs.foo.edu\fR matches all hosts in the domain \fIcs.foo.edu\fR. However,
49 these wildcard characters do not match the dots in a domain name, so the
50 above pattern does not include hosts such as \fIa.b.cs.foo.edu\fR.
51 .IP "IP networks
52 You can also export directories to all hosts on an IP (sub-) network
53 simultaneously. This is done by specifying an IP address and netmask pair
54 as
55 .IR address/netmask
56 where the netmask can be specified in dotted-decimal format, or as a
57 contiguous mask length (for example, either `/255.255.252.0' or `/22' appended
58 to the network base address result in identical subnetworks with 10 bits of
59 host). Wildcard characters generally do not work on IP addresses, though they
60 may work by accident when reverse DNS lookups fail.
61 .TP
62 '''.B =public
63 '''This is a special ``hostname'' that identifies the given directory name
64 '''as the public root directory (see the section on WebNFS in
65 '''.BR nfsd (8)
66 '''for a discussion of WebNFS and the public root handle). When using this
67 '''convention,
68 '''.B =public
69 '''must be the only entry on this line, and must have no export options
70 '''associated with it. Note that this does
71 '''.I not
72 '''actually export the named directory; you still have to set the exports
73 '''options in a separate entry.
74 '''.PP
75 '''The public root path can also be specified by invoking
76 '''.I nfsd
77 '''with the
78 '''.B \-\-public\-root
79 '''option. Multiple specifications of a public root will be ignored.
80 .PP
81 .SS General Options
82 .IR exportfs
83 understands the following export options:
84 .TP
85 .IR secure "\*d
86 This option requires that requests originate on an internet port less
87 than IPPORT_RESERVED (1024). This option is on by default. To turn it
88 off, specify
89 .IR insecure .
90 .TP
91 .IR rw
92 Allow both read and write requests on this NFS volume. The
93 default is to disallow any request which changes the filesystem.
94 This can also be made explicit by using
95 the
96 .IR ro " option.
97 .TP
98 .IR sync
99 This option requests that all file writes be committed to disc before
100 the write request completes.  This is required for complete safety of
101 data in the face of a server crash, but incurs a performance hit.
102 The default is to allow the server to write the data out whenever it
103 is ready.  This can be explicitly requested with the
104 .IR async " option.
105 .TP
106 .IR no_wdelay
107 This option only has effect if
108 .I sync
109 is also set.  The NFS server will normally delay committing a write request
110 to disc slightly if it suspects that another related write request may be in
111 progress or may arrive soon.  This allows multiple write requests to
112 be committed to disc with the one operation which can improve
113 performance.  If an NFS server received mainly small unrelated
114 requests, this behaviour could actually reduce performance, so
115 .IR no_wdelay
116 is available to turn it off.
117 The default can be explicitly requested with the
118 .IR wdelay " option.
119 .TP
120 .IR nohide
121 This option is based on the option of the same name provided in IRIX
122 NFS.  Normally, if a server exports two filesystems one of which is
123 mounted on the other, then the client will have to mount both
124 filesystems explicitly to get access to them.  If it just mounts the
125 parent, it will see an empty directory at the place where the other
126 filesystem is mounted.  That filesystem is "hidden".
127
128 Setting the
129 .I nohide
130 option on a filesystem causes it not to be hidden, and an
131 appropriately authorised client will be able to move from the parent to
132 that filesystem without noticing the change.
133
134 However, some NFS clients do not cope well with this situation as, for
135 instance, it is then possible for two files in the one apparent
136 filesystem to have the same inode number.
137
138 The
139 .I nohide
140 option is currently only effective on
141 .I "single host
142 exports.  It does not work reliably with netgroup, subnet, or wildcard
143 exports. 
144
145 This option can be very useful in some situations, but it should be
146 used with due care, and only after confirming that the client system
147 copes with the situation effectively.
148
149 The option can be explicitly disabled with
150 .IR hide .
151 .TP
152 .IR no_subtree_check
153 This option disables subtree checking, which has mild security
154 implications, but can improve reliability is some circumstances.
155
156 If a subdirectory of a filesystem is exported, but the whole
157 filesystem isn't then whenever a NFS request arrives, the server must
158 check not only that the accessed file is in the appropriate filesystem
159 (which is easy) but also that it is in the exported tree (which is
160 harder). This check is called the
161 .IR subtree_check .
162
163 In order to perform this check, the server must include some
164 information about the location of the file in the "filehandle" that is
165 given to the client.  This can cause problems with accessing files that
166 are renamed while a client has them open (though in many simple cases
167 it will still work).
168
169 subtree checking is also used to make sure that files inside
170 directories to which only root has access can only be accessed if the
171 filesystem is exported with
172 .I no_root_squash
173 (see below), even the file itself allows more general access.
174
175 As a general guide, a home directory filesystem, which is normally
176 exported at the root and may see lots of file renames, should be
177 exported with subtree checking disabled.  A filesystem which is mostly
178 readonly, and at least doesn't see many file renames (e.g. /usr or
179 /var) and for which subdirectories may be exported, should probably be
180 exported with subtree checks enabled.
181
182 The default of having subtree checks enabled, can be explicitly
183 requested with
184 .IR subtree_check .
185
186 .TP
187 .IR insecure_locks
188 .TP
189 .IR no_auth_nlm
190 This option (the two names are synonymous) tells the NFS server not to require authentication of
191 locking requests (i.e. requests which use the NLM protocol).  Normally
192 the NFS server will require a lock request to hold a credential for a
193 user who has read access to the file.  With this flag no access checks
194 will be performed.
195
196 Early NFS client implementations did not send credentials with lock
197 requests, and many current NFS clients still exist which are based on
198 the old implementations.  Use this flag if you find that you can only
199 lock files which are world readable.
200
201 The default behaviour of requiring authentication for NLM requests can
202 be explicitly requested with either of the synonymous
203 .IR auth_nlm ,
204 or
205 .IR secure_locks .
206
207 '''.TP
208 '''.I noaccess
209 '''This makes everything below the directory inaccessible for the named
210 '''client.  This is useful when you want to export a directory hierarchy to
211 '''a client, but exclude certain subdirectories. The client's view of a
212 '''directory flagged with noaccess is very limited; it is allowed to read
213 '''its attributes, and lookup `.' and `..'. These are also the only entries
214 '''returned by a readdir.
215 '''.TP
216 '''.IR link_relative
217 '''Convert absolute symbolic links (where the link contents start with a
218 '''slash) into relative links by prepending the necessary number of ../'s
219 '''to get from the directory containing the link to the root on the
220 '''server.  This has subtle, perhaps questionable, semantics when the file
221 '''hierarchy is not mounted at its root.
222 '''.TP
223 '''.IR link_absolute
224 '''Leave all symbolic link as they are. This is the default operation.
225 .SS User ID Mapping
226 .PP
227 .I nfsd
228 bases its access control to files on the server machine on the uid and
229 gid provided in each NFS RPC request. The normal behavior a user would
230 expect is that she can access her files on the server just as she would
231 on a normal file system. This requires that the same uids and gids are
232 used on the client and the server machine. This is not always true, nor
233 is it always desirable.
234 .PP
235 Very often, it is not desirable that the root user on a client machine
236 is also treated as root when accessing files on the NFS server. To this
237 end, uid 0 is normally mapped to a different id: the so-called
238 anonymous or
239 .I nobody
240 uid. This mode of operation (called `root squashing') is the default,
241 and can be turned off with
242 .IR no_root_squash .
243 .PP
244 By default,
245 '''.I nfsd
246 '''tries to obtain the anonymous uid and gid by looking up user
247 '''.I nobody
248 '''in the password file at startup time. If it isn't found, a uid and gid
249 .I exportfs
250 chooses a uid and gid
251 of -2 (i.e. 65534) for squashed access. These values can also be overridden by
252 the
253 .IR anonuid " and " anongid
254 options.
255 '''.PP
256 '''In addition to this, 
257 '''.I nfsd
258 '''lets you specify arbitrary uids and gids that should be mapped to user
259 '''nobody as well.
260 Finally, you can map all user requests to the
261 anonymous uid by specifying the
262 .IR all_squash " option.
263 '''.PP 
264 '''For the benefit of installations where uids differ between different
265 '''machines, 
266 '''.I nfsd
267 '''provides several mechanism to dynamically map server uids to client
268 '''uids and vice versa: static mapping files, NIS-based mapping, and
269 '''.IR ugidd -based
270 '''mapping.
271 '''.PP
272 '''.IR ugidd -based
273 '''mapping is enabled with the 
274 '''.I map_daemon
275 '''option, and uses the UGID RPC protocol. For this to work, you have to run
276 '''the
277 '''.IR ugidd (8)
278 '''mapping daemon on the client host. It is the least secure of the three methods,
279 '''because by running
280 '''.IR ugidd ,
281 '''everybody can query the client host for a list of valid user names. You
282 '''can protect yourself by restricting access to
283 '''.I ugidd
284 '''to valid hosts only. This can be done by entering the list of valid
285 '''hosts into the
286 '''.I hosts.allow
287 '''or 
288 '''.I hosts.deny
289 '''file. The service name is
290 '''.IR ugidd .
291 '''For a description of the file's syntax, please read
292 '''.IR hosts_access (5).
293 '''.PP
294 '''Static mapping is enabled by using the
295 '''.I map_static
296 '''option, which takes a file name as an argument that describes the mapping.
297 '''NIS-based mapping queries the client's NIS server to obtain a mapping from
298 '''user and group names on the server host to user and group names on the
299 '''client.
300 .PP
301 Here's the complete list of mapping options:
302 .TP
303 .IR root_squash
304 Map requests from uid/gid 0 to the anonymous uid/gid. Note that this does
305 not apply to any other uids that might be equally sensitive, such as user
306 .IR bin .
307 .TP
308 .IR no_root_squash
309 Turn off root squashing. This option is mainly useful for diskless clients.
310 '''.TP
311 '''.IR squash_uids " and " squash_gids
312 '''This option specifies a list of uids or gids that should be subject to
313 '''anonymous mapping. A valid list of ids looks like this:
314 '''.IP
315 '''.IR squash_uids=0-15,20,25-50
316 '''.IP
317 '''Usually, your squash lists will look a lot simpler.
318 .TP
319 .IR all_squash
320 Map all uids and gids to the anonymous user. Useful for NFS-exported
321 public FTP directories, news spool directories, etc. The opposite option
322 is 
323 .IR no_all_squash ,
324 which is the default setting.
325 '''.TP
326 '''.IR map_daemon
327 '''This option turns on dynamic uid/gid mapping. Each uid in an NFS request
328 '''will be translated to the equivalent server uid, and each uid in an
329 '''NFS reply will be mapped the other way round. This option requires that
330 '''.IR rpc.ugidd (8)
331 '''runs on the client host. The default setting is
332 '''.IR map_identity ,
333 '''which leaves all uids untouched. The normal squash options apply regardless
334 '''of whether dynamic mapping is requested or not.
335 '''.TP
336 '''.IR map_static
337 '''This option enables static mapping. It specifies the name of the file
338 '''that describes the uid/gid mapping, e.g.
339 '''.IP
340 '''.IR map_static=/etc/nfs/foobar.map
341 '''.IP
342 '''The file's format looks like this
343 '''.IP
344 '''.nf
345 '''.ta +3i
346 '''# Mapping for client foobar:
347 '''#    remote     local
348 '''uid  0-99       -       # squash these
349 '''uid  100-500    1000    # map 100-500 to 1000-1400
350 '''gid  0-49       -       # squash these
351 '''gid  50-100     700     # map 50-100 to 700-750
352 '''.fi
353 '''.TP
354 '''.IR map_nis
355 '''This option enables NIS-based uid/gid mapping. For instance, when
356 '''the server encounters the uid 123 on the server, it will obtain the
357 '''login name associated with it, and contact the NFS client's NIS server
358 '''to obtain the uid the client associates with the name.
359 '''.IP
360 '''In order to do this, the NFS server must know the client's NIS domain.
361 '''This is specified as an argument to the
362 '''.I map_nis
363 '''options, e.g.
364 '''.IP
365 '''.I map_nis=foo.com
366 '''.IP
367 '''Note that it may not be sufficient to simply specify the NIS domain
368 '''here; you may have to take additional actions before
369 '''.I nfsd
370 '''is actually able to contact the server. If your distribution uses
371 '''the NYS library, you can specify one or more NIS servers for the
372 '''client's domain in
373 '''.IR /etc/yp.conf .
374 '''If you are using a different NIS library, you may have to obtain a
375 '''special
376 '''.IR ypbind (8)
377 '''daemon that can be configured via
378 '''.IR yp.conf .
379 .TP
380 .IR anonuid " and " anongid
381 These options explicitly set the uid and gid of the anonymous account.
382 This option is primarily useful for PC/NFS clients, where you might want
383 all requests appear to be from one user. As an example, consider the
384 export entry for
385 .B /home/joe
386 in the example section below, which maps all requests to uid 150 (which
387 is supposedly that of user joe).
388 .IP
389 .SH EXAMPLE
390 .PP
391 .nf
392 .ta +3i
393 # sample /etc/exports file
394 /               master(rw) trusty(rw,no_root_squash)
395 /projects       proj*.local.domain(rw)
396 /usr            *.local.domain(ro) @trusted(rw)
397 /home/joe       pc001(rw,all_squash,anonuid=150,anongid=100)
398 /pub            (ro,insecure,all_squash)
399 '''/pub/private    (noaccess)
400 .fi
401 .PP
402 The first line exports the entire filesystem to machines master and trusty.
403 In addition to write access, all uid squashing is turned off for host
404 trusty. The second and third entry show examples for wildcard hostnames
405 and netgroups (this is the entry `@trusted'). The fourth line shows the
406 entry for the PC/NFS client discussed above. Line 5 exports the
407 public FTP directory to every host in the world, executing all requests
408 under the nobody account. The
409 .I insecure 
410 option in this entry also allows clients with NFS implementations that
411 don't use a reserved port for NFS.
412 ''' The last line denies all NFS clients
413 '''access to the private directory.
414 '''.SH CAVEATS
415 '''Unlike other NFS server implementations, this
416 '''.I nfsd
417 '''allows you to export both a directory and a subdirectory thereof to
418 '''the same host, for instance 
419 '''.IR /usr " and " /usr/X11R6 .
420 '''In this case, the mount options of the most specific entry apply. For
421 '''instance, when a user on the client host accesses a file in 
422 '''.IR /usr/X11R6 ,
423 '''the mount options given in the 
424 '''.I /usr/X11R6 
425 '''entry apply. This is also true when the latter is a wildcard or netgroup
426 '''entry.
427 .SH FILES
428 /etc/exports
429 '''.SH DIAGNOSTICS
430 '''An error parsing the file is reported using syslogd(8) as level NOTICE from
431 '''a DAEMON whenever nfsd(8) or mountd(8) is started up.  Any unknown
432 '''host is reported at that time, but often not all hosts are not yet known
433 '''to named(8) at boot time, thus as hosts are found they are reported
434 '''with the same syslogd(8) parameters.