aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mountd
Commit message (Collapse)AuthorAgeFilesLines
* fix typo: duplicate 'the' in OP_NOTROOT commentFelipe Matarazzo2026-04-301-1/+1
| | | | | | Signed-off-by: Felipe Matarazzo <felipemps@protonmail.com> Reviewed-by: ngie Pull-Request: https://github.com/freebsd/freebsd-src/pull/2174
* exports.5: Typo: "auomatically" => "automatically"Olivier Certner2025-11-271-1/+1
| | | | | | Fixes: 9d975e47d5a3 ("exports.5: Clarify that exported dirs should be local mount points") MFC after: 3 days Sponsored by: The FreeBSD Foundation
* exports.5: Add a paragraph clarifying the use of "V4:"Rick Macklem2025-08-261-1/+14
| | | | | | | | | | | | | | | | The exports.5 man page is a bit of a monster. One place of common confusion is the use of the "V4:" line(s) for defining the location of the root of the NFSv4 export subtree. This patch adds a paragraph in an attempt to clarify this. This is a content change. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D52141
* mountd, showmount: move to the nfs packageLexi Winter2025-05-051-0/+1
| | | | | | | | while here, alphabetise ${NFS}. Reviewed by: des, emaste, rmacklem Approved by: des (mentor) Differential Revision: https://reviews.freebsd.org/D50169
* mountd: Fix updating the network/host(s) for an exports lineRick Macklem2025-05-011-1/+43
| | | | | | | | | | | | | | | | | Mountd reloads the exports(5) file(s) when it receives a SIGHUP and then compares the old and new exports, updating any ones that have changed in the kernel. Without this patch, mountd failed to recognize that a network/host(s) had changed, if there was no other change to the exports line. As such, the change of network/hosts(s) did not take effect until the mountd daemon was (re)started. This patch fixes the code so that it checks for changes in the network/host(s) list for an exports line. PR: 286260 MFC after: 3 days
* mountd: use free_iovec for build_iovec cleanupBrooks Davis2025-04-251-25/+2
| | | | | | | | | | Remove the handrolled cleanups and use free_iovec instead. No functional change intended. Logically, the change does remove one dead store to iovlen in get_exportlist(). Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D49953
* Search for mntopts.h globally, not locallyBrooks Davis2025-04-221-1/+1
| | | | | | | | | Change the include directives to use <mntopts.h> instead of "mntopts.h" now that it's installed by libutil (the latter option was dubious regardless since a -I${SRCTOP}/sbin/mount was required anyway). Reviewed by: olce, imp, dim, emaste Differential Revision: https://reviews.freebsd.org/D49952
* Move mntopts(3) suppport into libutilBrooks Davis2025-04-221-5/+0
| | | | | | | | | | | | | | | | | Many programs use this functionality so it should be available centrally rather than compiled into each program independently. This has the modest downside of adding libutil dependencies to some mount_<foo> programs, but many (plus mount(8)) already have those depndencies so this shouldn't be a major imposition. In commit 906c312bbf74, Kirk said this could be done once the change was merged to FreeBSD 13. That happened in commit 668dfa016698 in 2023. While here perform related tidying including removing SRCS where the only entry is ${PROG}.c rendering it unnecessary. Reviewed by: olce, dim, emaste Differential Revision: https://reviews.freebsd.org/D49951
* mountd: Promote missing netmask log to LOG_ERREd Maste2025-02-041-1/+1
| | | | | | | | | | | Historical network classes are deprecated, but currently still supported in mountd with a LOG_WARNING-priority message added by Mike Karels in 2021. Upgrade the log to LOG_ERR well in advance of this becoming a fatal error. Reviewed by: rmacklem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48795
* exports.5: Document the current behavior of -alldirsRick Macklem2024-12-281-4/+19
| | | | | | | | | | | | | | | | | | | | | | Commit 07cd69e272da adds a new "-a" mountd option, which changes the behavior of mountd when file systems are exported via -alldirs. This patch updates the man page to reflect the actual behavior when -alldirs is used when mountd is started with/without -a. Prior to the above commit, exports(5) documented that, when -alldirs was specified, the exports line would fail unless the directory was a server file system mount point. This behavior was only documented in the Examples section and has not been implemented since a change between FreeBSD 1 and FreeBSD 2 was done. This is a contents change. PR: 282995 Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D48139
* mound.8: Document the new -a command line optionRick Macklem2024-12-281-3/+15
| | | | | | | | | | | | | Commit 07cd69e272da adds a new "-a" mountd option. This patch updates the man page for it. This is a content change. PR: 282995 Reviewed by: gbe (manpages) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D48138
* mountd.c: Define a new -a command line optionRick Macklem2024-12-281-18/+33
| | | | | | | | | | | | | | | | | | | | | | Bugzilla PR#282995 reported that, when a file system was exported with the "-alldirs" flag, the export succeeded even if the directory path was not a server file system mount point. This behaviour for "-alldirs" was only documented in the Example section of exports(5) and had not been enforced since FreeBSD2. (A patch applied between FreeBSD1 and FreeBSD2 broke the check for file system mount point.) Since the behaviour of allowing the export has existed since FreeBSD2, the concensus on a mailing list was that it would be a POLA violation to change it now. Therefore, this patch adds a new "-a" mountd command line option to enforce a check for the exported directory being a server file system mount point. PR: 282995 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D48137
* mountd(8): Allow to pass {NGROUPS_MAX} + 1 groupsOlivier Certner2024-12-161-33/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NGROUPS_MAX is just the minimum maximum of the number of allowed supplementary groups. The actual runtime value may be greater. Allow more groups to be specified accordingly (now that, a few commits ago, nmount(2) has been changed similarly). To this end, we just allocate once and for all a static array called 'tmp_groups' big enough to hold {NGROUPS_MAX} + 1 groups (the maximum number of supplementary groups plus the effective GID, which we store in a variable named 'tngroups_max' to avoid confusion with the kernel variable 'ngroups_max' holding only the maximum number of *supplementary* groups) in main() and use this temporary space in get_exportlist_one(), do_opt() and parsecred(). Doing so in passing fixes a (benign) memory leak in case "-maproot" and/or "-mapall" were specified multiple times and the first option comprised more than SMALLNGROUPS. parsecred() does not use 'cr_smallgrps' anymore, but we have kept 'cr_smallgrps'/SMALLNGROUPS as 'struct expcred' is also included in 'struct exportlist' and 'struct grouplist', and thus this preallocated field still results in an optimization for the common case of small number of groups (although its real impact is probably negligible and arguably was not worth the trouble). While here, in do_mount(), remove some unnecessary groups array allocation and copying. Reviewed by: rmacklem (older version) Approved by: markj (mentor) MFC after: 2 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47016
* mountd(8): parsecred(): Re-order operations for clarityOlivier Certner2024-12-161-26/+27
| | | | | | | | | | No functional change (intended). Reviewed by: rmacklem (older version) Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47015
* mountd(8): parsecred(): Remove comment on non-existent bugOlivier Certner2024-12-161-1/+0
| | | | | | | | | | | 'name' can never be NULL, as it is equal to 'names' and 'namelist', which was passed by do_cred() only if the actual parameter wasn't NULL. Reviewed by: rmacklem Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47014
* mountd(8): parsecred(): Groups limit: NGROUPS_MAX => NGROUPS_MAX + 1Olivier Certner2024-12-161-3/+1
| | | | | | | | | Lift this unnecessary limitation. Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46921
* exports(5): -maproot, -mapall: Explain the fallback on no groupOlivier Certner2024-12-161-3/+18
| | | | | | | | Reviewed by: rmacklem (older version) Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47012
* mountd(8): parsecred(): Fallback to "nogroup" or GID_NOGROUPOlivier Certner2024-12-161-2/+25
| | | | | | | | | | | | | | | | | | | | In the 'uid:gid:gid:...' case (for '-maproot' or '-mapall'), if no GID is specified at all (i.e., input is of the form 'uid:', with the colon at the end), mountd(8) would pass credentials with an empty array of groups to the kernel. For security reasons, we have put in place a kernel fallback a while ago, which is to use the single group GID_NOGROUP (see commits cfbe7a62dc62 ("nfs, rpc: Ensure kernel credentials have at least one group") and 5169d4307eb9 ("nfs: Fallback to GID_NOGROUP on no groups")). Here, as we are in userland, we first try to find the GID number corresponding to "nogroup", and only then fall back to GID_NOGROUP, as nfsuserd(8) does. Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47011
* mountd(8): parsecred(): Remove "duplicate compression"Olivier Certner2024-12-161-13/+1
| | | | | | | | | | | | | | | | | | | | | | | No functional change (intended). This code dates back to 4.4BSD, became wrong after some getgrouplist() (nssswitch-related) change in 2007, was fixed only in 2020 and since then underwent cosmetic changes. It is likely that in fact it never served any useful purpose in FreeBSD, except perhaps at the very beginning. It's most probably not the case today: NFS credentials are normally only used to check for file accesses, whose group is checked against all groups of a credentials indiscriminately (except for the real GID). Consequently, having a single duplicate, which the code would actually remove only if in the first supplementary group slot, doesn't change behavior. Moreover, we are going to regain one slot in a subsequent commit. Discussed with: rmacklem Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46920
* mountd(8): parsecred(): uid:gid:... loop: Simplify a bitOlivier Certner2024-12-161-5/+10
| | | | | | | | | | No functional change intended. Reviewed by: rmacklem (older version) Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46919
* mountd: Add check for "=" after exports(5) optionsRick Macklem2024-09-061-4/+40
| | | | | | | | | | | | | | | Some exports(5) options take a "=arg" component that provides an argument value for the option. Others do not. Without this patch, if "=arg" was provided for an option that did not take an argument value, the "=arg" was simply ignored. This could result in confusion w.r.t. what was being exported, as noted by the Problem Report. This patch adds a check for "=arg" for the options that do not take an argument value and fails the exports line if one is found. PR: 281003 MFC after: 2 weeks
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* mountd.8: Update the man page for -N and -sJoyu Liao2024-07-111-2/+13
| | | | | | | | | | Commit 7c2901b08b4e added new command line options "-N" and "-s". This patch updates the man page for this. This is a content change. Reviewed by: Alexander Ziaee <concussious.bugzilla@runbox.com> (manpages) Differential Revision: https://reviews.freebsd.org/D45118
* mountd: Add options to disable daemon mode and setting localhostJoyu Liao2024-07-111-5/+16
| | | | | | | | | | | In our products, we need those options to support our features. Add daemon mode option for mountd, nfsd. Add skip local host binding option for rpcd. Add skip local host binding option for mountd. Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D45118
* exports.5: Clarify that exported dirs should be local mount pointsMark Johnston2024-04-161-4/+24
| | | | | | | | | | If not, then in general the entire filesystem containing the exported directory is accessiable. This may be surprising, so try to make it more clear. Reviewed by: rmacklem, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44614
* exports.5: Update an example to use service(8)Mark Johnston2024-04-161-1/+2
| | | | MFC after: 1 week
* mountd.8: Document the new -A mountd optionRick Macklem2024-04-091-2/+12
| | | | | | | | | | | | | | | | | Commit fefb7c399b39 added warning messages noting that administrative controls that exported directories that are not local server file system mount points actually export the entire local server file system. This commit also added a new command line option "-A' that silences these warnings. This patch documents the new "-A' mountd option. This is a content change. Reviewed by: markj, pauamma_gundo.com (manpages) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44692
* exports.5: Add RFC number for NFS over TLSRick Macklem2024-04-071-3/+3
| | | | | | This is a content change. MFC after: 1 week
* mountd.c: Add warning messages for administrative controlsRick Macklem2024-03-311-5/+24
| | | | | | | | | | | | | | | | | | When "administrative controls" (which are exports of subdirectories within a NFS server's local file system) are used, they export the entire local server file system. (The subdirectory only applies to the Mount protocol used for NFSv3 mounts.) To minimize the risk that this causes confusion w.r.t. what is exported to NFS client(s), this patch generates warning messages for these. Only one message is generated for each server local file system. The messages can be silenced via a new "-A" command line option. The mountd.8 man page will be patched via a separate commit. Reviewed by: emaste, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44502
* mountd: Update exports.5 for commit 7c5146da1286Rick Macklem2023-12-221-1/+14
| | | | | | | | | | | | | | | Commit 7c5146da1286 modified mountd so that it uses strunvis(3) to decode directory names in exports lines. This allows special characters, such as blanks, to be encoded in the directory names. This patch updates the exports.5 man page for this change. This is a content change. Reviewed by: karels, pauamma_gundo.com (manpages) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42163
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-10/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.sbin: Remove ancient SCCS tags.Warner Losh2023-11-276-12/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* mountd: Add support for spaces in exported directoriesDan Mcgregor2023-11-041-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The previous code would correctly parse strings including quotation marks (") or backslash (/), but the tests when creating the export includes them in the final string. This prevents exporting paths with embedded spaces, for example "/exports/with space". Trying results in log lines resembling: mountd[1337]: bad exports list line '/exports/with\ space': /exports/with\ space: lstat() failed: No such file or directory. Turns out that when creating its exports list, zfs escapes strings in a format compatible with vis(3). Since I expect that zfs sharenfs is the dominating use case for generating an exports list, use strunvis(3) to parse the export path. The result is lines like the following allowing spaces: /exports/with\040space -network 192.168.0 -mask 255.255.255.0 A man page update will be done as a separate commit. MFC after: 1 month Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D42432
* mountd: do not warn about using class mask with -maskMike Karels2023-09-081-4/+8
| | | | | | | | | | | | | The previous code would warn that the mask was being defaulted to an obsolete class mask even if -mask was present after -network. Import a fix from Peter Much with a little tweaking, deferring the warning until after all parameters are processed. PR: 263011 Obtained from: pmc at citilink.dinoex.sub.org MFC after: 3 days Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D41774
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* mountd: Fix type of signal variableRick Macklem2023-08-101-1/+1
| | | | | | | | | | | | | Without this patch got_sighup(), which is the SIGHUP handler, would set a variable of type int. This would appear to be incorrect, although it has worked reliably. This patch changes the type to "_Atomic(int)", which appears to be all that is needed to correct it. Reported by: pen@lysator.lui.se Reviewed by: theraven, karels (prev version), kevans (prev version) Differential Revision: https://reviews.freebsd.org/D41265
* mountd: Fix typosElyes Haouas2023-06-021-1/+1
| | | | | | Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/653
* mountd: Improve error message for exports linesAlexander Motin2023-05-061-15/+72
| | | | | | | | | | | | Currently mountd print error message "symbolic link in export path or statfs failed" in case some path component in an exports line fails validation. This revision improves the error message by giving more information about the precise error as well as the path component that caused the issue. Submitted by: Andrew Walker <awalker@ixsystems.com> Reviewed by: mav, rmacklem Differential Revision: https://reviews.freebsd.org/D39840
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* mountd.8: Update for mountd running in jailsRick Macklem2023-03-201-2/+27
| | | | | | | | | | | | | | Mountd can now be run in an appropriately configured vnet jail. This man page update adds some information for this case. This is a content change. Reviewed by: markj MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D39168
* mountd(8): Fix a typo in a source code commentGordon Bergling2023-01-191-1/+1
| | | | | | - s/ingore/ignore/ MFC after: 3 days
* exports.5: Clean up EXAMPLES and STANDARDSMateusz Piotrowski2022-08-161-19/+29
| | | | | | | | | | | There was a missing sentence in the description of the second mount entry in the example. Fix that and some other bits in the EXAMPLES section. Also, make the STANDARDS section a bit more readable. MFC after: 1 week Sponsored by: Klara Inc.
* mountd: Fix handling of usernames that start with a digitRick Macklem2021-11-181-11/+16
| | | | | | | | | | | | | | | yocalebo_gmail.com submitted a patch for mountd.c that fixes the case where a username starts with a digit. Without this patch, the username that starts with a digit is misinterpreted as a numeric uid. With this patch, any string that does not entirely convert to a decimal number via strtoul() is considered a user/group name. Submitted by: yocalebo_gmail.com Reviewed by: rmacklem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D32993
* mountd: deprecate exports to a network without maskMike Karels2021-11-092-4/+8
| | | | | | | | | | | | The exports file format allows export to a network using an explicit mask or prefix length (CIDR). It also allows a network with just a dotted address, in which case the historical mask was used. Deprecate this usage, and warn when it is used. Document that this is deprecated. MFC after: 1 month Reviewed by: rmacklem, bcr, #manpages Differential Revision: https://reviews.freebsd.org/D32713
* mountd(8): generate a syslog message when the "V4:" line is missingRick Macklem2021-03-091-1/+17
| | | | | | | | | | | | | | | | | | | Daniel reported that NFSv4 mounts were not working despite having set "nfsv4_server_enable=YES" in /etc/rc.conf. Mountd was logging a message that there was no /etc/exports file. He noted that creating a /etc/exports file with a "V4:" line in it was needed make NFSv4 mounts work. At least one "V4:" line in one of the exports(5) file(s) is needed to make NFSv4 mounts work. This patch fixes mountd.c so that it logs a message indicting that there is no "V4:" line in any exports(5) file when NFSv4 mounts are enabled. To avoid this message being generated erroneously, /etc/rc.d/mountd is updated to make sure vfs.nfsd.server_max_nfsvers is properly set before mountd(8) is started. Reported by: debdrup PR: 253901 MFC after: 2 weeks
* Update man page for new TLS export options.Rick Macklem2020-11-201-4/+58
| | | | | | | | | | | | | | NFS over TLS uses three new export options, added by r364979. This patch updates the exports.5 man page for these new options. Once assigned by IETF, "NNNN" will be replaced with the RFC number. This is a content change. Reviewed by: gbe Differential Revision: https://review.freebsd.org/D26241 Notes: svn path=/head/; revision=367912
* Update man page for -R option added by r376026.Rick Macklem2020-10-241-2/+13
| | | | | | | | | | | This is a content change. Reviewed by: bcr MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26746 Notes: svn path=/head/; revision=367027