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