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