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