xref: /freebsd/usr.sbin/mountd/exports.5 (revision 1edb7116)
1.\" Copyright (c) 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd December 21, 2023
29.Dt EXPORTS 5
30.Os
31.Sh NAME
32.Nm exports
33.Nd define remote mount points for
34.Tn NFS
35mount requests
36.Sh SYNOPSIS
37.Nm
38.Sh DESCRIPTION
39The
40.Nm
41file specifies remote mount points for the
42.Tn NFS
43mount protocol per the
44.Tn NFS
45server specification; see
46.%T "Network File System Protocol Specification" ,
47RFC1094, Appendix A and
48.%T "NFS: Network File System Version 3 Specification" ,
49Appendix I.
50.Pp
51Each line in the file
52(other than comment lines that begin with a #)
53specifies the mount point(s) and export flags within one local server
54file system or the NFSv4 tree root for one or more hosts.
55A long line may be split over several lines by ending all but the
56last line with a backslash
57.Pq Ql \e .
58A host may be specified only once for each local file or the NFSv4 tree root on the
59server and there may be only one default entry for each server
60file system that applies to all other hosts.
61The latter exports the file system to the
62.Dq world
63and should
64be used only when the file system contains public information.
65.Pp
66In a mount entry,
67the first field(s) specify the directory path(s) within a server file system
68that can be mounted on by the corresponding client(s).
69There are three forms of this specification.
70The first is to list all mount points as absolute
71directory paths separated by whitespace.
72This list of directory paths should be considered an
73.Dq administrative control ,
74since it is only enforced by the
75.Xr mountd 8
76daemon and not the kernel.
77As such, it only applies to NFSv2 and NFSv3 mounts and only
78with respect to the client's use of the mount protocol.
79The second is to specify the pathname of the root of the file system
80followed by the
81.Fl alldirs
82flag;
83this form allows the host(s) to mount at any point within the file system,
84including regular files if the
85.Fl r
86option is used on
87.Xr mountd 8 .
88Because NFSv4 does not use the mount protocol,
89the
90.Dq administrative controls
91are not applied and all directories within this server
92file system are mountable via NFSv4 even if the
93.Fl alldirs
94flag has not been specified.
95The third form has the string ``V4:'' followed by a single absolute path
96name, to specify the NFSv4 tree root.
97This line does not export any file system, but simply marks where the root
98of the server's directory tree is for NFSv4 clients.
99The exported file systems for NFSv4 are specified via the other lines
100in the
101.Nm
102file in the same way as for NFSv2 and NFSv3.
103The pathnames must not have any symbolic links in them and should not have
104any
105.Dq Pa \&.
106or
107.Dq Pa ..
108components.
109Pathnames are decoded by
110.Xr strunvis 3
111allowing special characters to be included in the directory name(s).
112In particular, whitespace, such as embedded blanks in directory names
113can be handled.
114For example, a blank can be encoded as \(rs040.
115.Xr vis 1
116with the
117.Fl M
118option may be used to encode directory name(s) with embedded special
119characters.
120Mount points for a file system may appear on multiple lines each with
121different sets of hosts and export options.
122.Pp
123The second component of a line specifies how the file system is to be
124exported to the host set.
125The option flags specify whether the file system
126is exported read-only or read-write and how the client UID is mapped to
127user credentials on the server.
128For the NFSv4 tree root, the only options that can be specified in this
129section are ones related to security:
130.Fl sec ,
131.Fl tls ,
132.Fl tlscert
133and
134.Fl tlscertuser .
135.Pp
136Export options are specified as follows:
137.Pp
138.Sm off
139.Fl maproot Li = Sy user
140.Sm on
141The credential of the specified user is used for remote access by root.
142The credential includes all the groups to which the user is a member
143on the local machine (see
144.Xr id 1 ) .
145The user may be specified by name or number.
146The user string may be quoted, or use backslash escaping.
147.Pp
148.Sm off
149.Fl maproot Li = Sy user:group1:group2:...
150.Sm on
151The colon separated list is used to specify the precise credential
152to be used for remote access by root.
153The elements of the list may be either names or numbers.
154Note that user: should be used to distinguish a credential containing
155no groups from a complete credential for that user.
156The group names may be quoted, or use backslash escaping.
157.Pp
158.Sm off
159.Fl mapall Li = Sy user
160.Sm on
161or
162.Sm off
163.Fl mapall Li = Sy user:group1:group2:...
164.Sm on
165specifies a mapping for all client UIDs (including root)
166using the same semantics as
167.Fl maproot .
168.Pp
169The option
170.Fl r
171is a synonym for
172.Fl maproot
173in an effort to be backward compatible with older export file formats.
174.Pp
175In the absence of
176.Fl maproot
177and
178.Fl mapall
179options, remote accesses by root will result in using a credential of 65534:65533.
180All other users will be mapped to their remote credential.
181If a
182.Fl maproot
183option is given,
184remote access by root will be mapped to that credential instead of 65534:65533.
185If a
186.Fl mapall
187option is given,
188all users (including root) will be mapped to that credential in
189place of their own.
190.Pp
191.Sm off
192.Fl sec Li = Sy flavor1:flavor2...
193.Sm on
194specifies a colon separated list of acceptable security flavors to be
195used for remote access.
196Supported security flavors are sys, krb5, krb5i and krb5p.
197If multiple flavors are listed, they should be ordered with the most
198preferred flavor first.
199If this option is not present,
200the default security flavor list of just sys is used.
201.Pp
202The
203.Fl ro
204option specifies that the file system should be exported read-only
205(default read/write).
206The option
207.Fl o
208is a synonym for
209.Fl ro
210in an effort to be backward compatible with older export file formats.
211.Pp
212.Tn WebNFS
213exports strictly according to the spec (RFC 2054 and RFC 2055) can
214be done with the
215.Fl public
216flag.
217However, this flag in itself allows r/w access to all files in
218the file system, not requiring reserved ports and not remapping UIDs.
219It
220is only provided to conform to the spec, and should normally not be used.
221For a
222.Tn WebNFS
223export,
224use the
225.Fl webnfs
226flag, which implies
227.Fl public ,
228.Sm off
229.Fl mapall No = Sy nobody
230.Sm on
231and
232.Fl ro .
233Note that only one file system can be
234.Tn WebNFS
235exported on a server.
236.Pp
237A
238.Sm off
239.Fl index No = Pa file
240.Sm on
241option can be used to specify a file whose handle will be returned if
242a directory is looked up using the public filehandle
243.Pq Tn WebNFS .
244This is to mimic the behavior of URLs.
245If no
246.Fl index
247option is specified, a directory filehandle will be returned as usual.
248The
249.Fl index
250option only makes sense in combination with the
251.Fl public
252or
253.Fl webnfs
254flags.
255.Pp
256The
257.Fl tls ,
258.Fl tlscert
259and
260.Fl tlscertuser
261export options are used to require the client to use TLS for the mount(s)
262per RFC NNNN.
263For NFS mounts using TLS to work,
264.Xr rpc.tlsservd 8
265must be running on the server.
266.Bd -filled -offset indent
267.Fl tls
268requires that the client use TLS.
269.br
270.Fl tlscert
271requires that the client use TLS and provide a verifiable X.509 certificate
272during TLS handshake.
273.br
274.Fl tlscertuser
275requires that the client use TLS and provide a verifiable X.509 certificate.
276The otherName component of the certificate's subjAltName must have a
277an OID of 1.3.6.1.4.1.2238.1.1.1 and a UTF8 string of the form
278.Dq user@domain .
279.Dq user@domain
280will be translated to the credentials of the specified user in the same
281manner as
282.Xr nfsuserd 8 ,
283where
284.Dq user
285is normally a username is the server's password database and
286.Dq domain
287is the DNS domain name for the server.
288All RPCs will be performed using these credentials instead of the
289ones in the RPC header in a manner similar to
290.Sm off
291.Fl mapall Li = Sy user .
292.Sm on
293.Ed
294.Pp
295If none of these three flags are specified, TLS mounts are permitted but
296not required.
297.Pp
298Specifying the
299.Fl quiet
300option will inhibit some of the syslog diagnostics for bad lines in
301.Pa /etc/exports .
302This can be useful to avoid annoying error messages for known possible
303problems (see
304.Sx EXAMPLES
305below).
306.Pp
307The third component of a line specifies the host set to which the line applies.
308The set may be specified in three ways.
309The first way is to list the host name(s) separated by white space.
310(Standard Internet
311.Dq dot
312addresses may be used in place of names.)
313The second way is to specify a
314.Dq netgroup
315as defined in the
316.Pa netgroup
317file (see
318.Xr netgroup 5 ) .
319The third way is to specify an Internet subnetwork using a network and
320network mask that is defined as the set of all hosts with addresses within
321the subnetwork.
322This latter approach requires less overhead within the
323kernel and is recommended for cases where the export line refers to a
324large number of clients within an administrative subnet.
325.Pp
326The first two cases are specified by simply listing the name(s) separated
327by whitespace.
328All names are checked to see if they are
329.Dq netgroup
330names
331first and are assumed to be hostnames otherwise.
332Using the full domain specification for a hostname can normally
333circumvent the problem of a host that has the same name as a netgroup.
334The third case is specified by the flag
335.Sm off
336.Fl network Li = Sy netname Op Li / Ar prefixlength
337.Sm on
338and optionally
339.Sm off
340.Fl mask No = Sy netmask .
341.Sm on
342The netmask may be specified either by attaching a
343.Ar prefixlength
344to the
345.Fl network
346option, or by using a separate
347.Fl mask
348option.
349If the mask is not specified, it will default to the historical mask
350for that network class (A, B, or C; see
351.Xr inet 4 ) .
352This usage is deprecated, and will elicit a warning log message.
353See the
354.Sx EXAMPLES
355section below.
356.Pp
357Scoped IPv6 address must carry scope identifier as documented in
358.Xr inet6 4 .
359For example,
360.Dq Li fe80::%re2/10
361is used to specify
362.Li fe80::/10
363on
364.Li re2
365interface.
366.Pp
367For the third form which specifies the NFSv4 tree root, the directory path
368specifies the location within the server's file system tree which is the
369root of the NFSv4 tree.
370There can only be one NFSv4 root directory per server.
371As such, all entries of this form must specify the same directory path.
372For file systems other than ZFS,
373this location can be any directory and does not
374need to be within an exported file system.
375If it is not in an exported file system, a very limited set of operations
376are permitted, so that an NFSv4 client can traverse the tree to an
377exported file system.
378Although parts of the NFSv4 tree can be non-exported, the entire NFSv4 tree
379must consist of local file systems capable of being exported via NFS.
380All ZFS file systems in the subtree below the NFSv4 tree root must be
381exported.
382NFSv4 does not use the mount protocol and does permit clients to cross server
383mount point boundaries, although not all clients are capable of crossing the
384mount points.
385.Pp
386The
387.Fl sec
388option on these line(s) specifies what security flavors may be used for
389NFSv4 operations that do not use file handles.
390Since these operations (SetClientID, SetClientIDConfirm, Renew, DelegPurge
391and ReleaseLockOnwer) allocate/modify state in the server, it is possible
392to restrict some clients to the use of the krb5[ip] security flavors,
393via this option.
394See the
395.Sx EXAMPLES
396section below.
397This third form is meaningless for NFSv2 and NFSv3 and is ignored for them.
398.Pp
399The
400.Xr mountd 8
401utility can be made to re-read the
402.Nm
403file by sending it a hangup signal as follows:
404.Bd -literal -offset indent
405/etc/rc.d/mountd reload
406.Ed
407.Pp
408After sending the
409.Dv SIGHUP ,
410check the
411.Xr syslogd 8
412output to see whether
413.Xr mountd 8
414logged any parsing errors in the
415.Nm
416file.
417.Sh FILES
418.Bl -tag -width /etc/exports -compact
419.It Pa /etc/exports
420the default remote mount-point file
421.El
422.Sh EXAMPLES
423Given that
424.Pa /usr , /u , /a
425and
426.Pa /u2
427are
428local file system mount points, let's consider the following example:
429.Pp
430.Bd -literal -offset indent
431/usr /usr/local -maproot=0:10 friends
432/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16
433/usr -ro -mapall=nobody
434/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0
435/a -network 192.168.0/24
436/a -network 3ffe:1ce1:1:fe80::/64
437/u2 -maproot=root friends
438/u2 -alldirs -network cis-net -mask cis-mask
439/cdrom -alldirs,quiet,ro -network 192.168.33.0 -mask 255.255.255.0
440/private -sec=krb5i
441/secret -sec=krb5p
442V4: /	-sec=krb5:krb5i:krb5p -network 131.104.48 -mask 255.255.255.0
443V4: /	-sec=sys:krb5:krb5i:krb5p grumpy.cis.uoguelph.ca
444.Ed
445.Pp
446The file systems rooted at
447.Pa /usr
448and
449.Pa /usr/local
450are exported to hosts within the
451.Dq friends
452network group
453with users mapped to their remote credentials and
454root mapped to UID 0 and group 10.
455They are exported read-write and the hosts in
456.Dq friends .
457.Pp
458The file system rooted at
459.Pa /usr
460is exported to
461.Em 131.104.48.16
462and
463.Em grumpy.cis.uoguelph.ca
464with users mapped to their remote credentials and
465root mapped to the user and groups associated with
466.Dq daemon ;
467it is exported to the rest of the world as read-only with
468all users mapped to the user and groups associated with
469.Dq nobody .
470.Pp
471The file system rooted at
472.Pa /u
473is exported to all hosts on the subnetwork
474.Em 131.104.48
475with root mapped to the UID for
476.Dq bin
477and with no group access.
478.Pp
479The file system rooted at
480.Pa /u2
481is exported to the hosts in
482.Dq friends
483with root mapped to UID and groups
484associated with
485.Dq root ;
486it is exported to all hosts on network
487.Dq cis-net
488allowing mounts at any
489directory within /u2.
490.Pp
491The file system rooted at
492.Pa /a
493is exported to the network 192.168.0.0, with a netmask of 255.255.255.0.
494However, the netmask length in the entry for
495.Pa /a
496is not specified through a
497.Fl mask
498option, but through the
499.Li / Ns Ar prefix
500notation.
501.Pp
502The file system rooted at
503.Pa /a
504is also exported to the IPv6 network
505.Li 3ffe:1ce1:1:fe80::
506address, using the upper 64 bits as the prefix.
507Note that, unlike with IPv4 network addresses, the specified network
508address must be complete, and not just contain the upper bits.
509With IPv6 addresses, the
510.Fl mask
511option must not be used.
512.Pp
513The file system rooted at
514.Pa /cdrom
515will be exported read-only to the entire network 192.168.33.0/24, including
516all its subdirectories.
517Since
518.Pa /cdrom
519is the conventional mountpoint for a CD-ROM device, this export will
520fail if no CD-ROM medium is currently mounted there since that line
521would then attempt to export a subdirectory of the root file system
522with the
523.Fl alldirs
524option which is not allowed.
525The
526.Fl quiet
527option will then suppress the error message for this condition that
528would normally be syslogged.
529As soon as an actual CD-ROM is going to be mounted,
530.Xr mount 8
531will notify
532.Xr mountd 8
533about this situation, and the
534.Pa /cdrom
535file system will be exported as intended.
536Note that without using the
537.Fl alldirs
538option, the export would always succeed.
539While there is no CD-ROM medium mounted under
540.Pa /cdrom ,
541it would export the (normally empty) directory
542.Pa /cdrom
543of the root file system instead.
544.Pp
545The file system rooted at
546.Pa /private
547will be exported using Kerberos 5 authentication and will require
548integrity protected messages for all accesses.
549The file system rooted at
550.Pa /secret
551will also be exported using Kerberos 5 authentication and all messages
552used to access it will be encrypted.
553.Pp
554For the experimental server, the NFSv4 tree is rooted at ``/'',
555and any client within the 131.104.48 subnet is permitted to perform NFSv4 state
556operations on the server, so long as valid Kerberos credentials are provided.
557The machine grumpy.cis.uoguelph.ca is permitted to perform NFSv4 state
558operations on the server using AUTH_SYS credentials, as well as Kerberos ones.
559.Pp
560In the following example some directories are exported as NFSv3 and NFSv4:
561.Bd -literal -offset indent
562V4: /wingsdl/nfsv4
563/wingsdl/nfsv4/usr-ports -maproot=root -network 172.16.0.0 -mask 255.255.0.0
564/wingsdl/nfsv4/clasper   -maproot=root clasper
565.Ed
566.Pp
567Only one V4: line is needed or allowed to declare where NFSv4 is
568rooted.
569The other lines declare specific exported directories with
570their absolute paths given in /etc/exports.
571.Pp
572The exported directories' paths are used for both v3 and v4.
573However, they are interpreted differently for v3 and v4.
574A client mount command for usr-ports would use the server-absolute name when
575using nfsv3:
576.Bd -literal -offset indent
577mount server:/wingsdl/nfsv4/usr-ports /mnt/tmp
578.Ed
579.Pp
580A mount command using NFSv4 would use the path relative to the NFSv4
581root:
582.Bd -literal -offset indent
583mount server:/usr-ports /mnt/tmp
584.Ed
585.Pp
586This also differentiates which version you want if the client can do
587both v3 and v4.
588The former will only ever do a v3 mount and the latter will only ever
589do a v4 mount.
590.Pp
591Note that due to different mount behavior between NFSv3 and NFSv4 a
592NFSv4 mount request for a directory that the client does not have
593permission for will succeed and read/write access will fail
594afterwards, whereas NFSv3 rejects the mount request.
595.Sh SEE ALSO
596.Xr vis 1 ,
597.Xr strunvis 3 ,
598.Xr nfsv4 4 ,
599.Xr netgroup 5 ,
600.Xr mountd 8 ,
601.Xr nfsd 8 ,
602.Xr rpc.tlsservd 8 ,
603.Xr showmount 8
604.Sh STANDARDS
605The implementation is based on the following documents:
606.Bl -dash
607.It
608.Rs
609.%T "Network File System Protocol Specification, Appendix A, RFC 1094"
610.Re
611.It
612.Rs
613.%T "NFS: Network File System Version 3, Appendix I, RFC 1813"
614.Re
615.It
616.Rs
617.%T "Towards Remote Procedure Call Encryption By Default, RFC nnnn"
618.Re
619.El
620.Sh BUGS
621The export options are tied to the local mount points in the kernel and
622must be non-contradictory for any exported subdirectory of the local
623server mount point.
624It is recommended that all exported directories within the same server
625file system be specified on adjacent lines going down the tree.
626You cannot specify a hostname that is also the name of a netgroup.
627Specifying the full domain specification for a hostname can normally
628circumvent the problem.
629