CVS commit: src/usr.sbin/mountd

2024-03-29 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Mar 29 22:50:27 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): mark up the list of groups to --maproot  as optional


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-29 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Mar 29 22:50:27 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): mark up the list of groups to --maproot  as optional


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.38 src/usr.sbin/mountd/exports.5:1.39
--- src/usr.sbin/mountd/exports.5:1.38	Fri Mar 29 14:15:02 2024
+++ src/usr.sbin/mountd/exports.5	Fri Mar 29 22:50:27 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.38 2024/03/29 14:15:02 riastradh Exp $
+.\"	$NetBSD: exports.5,v 1.39 2024/03/29 22:50:27 uwe Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -155,7 +155,7 @@ on the local machine
 .Pc .
 The user may be specified by name or number.
 .Sm off
-.It Fl maproot Li = Ar user\^ Li \&: Ar group1\^ Li \&: group2\^ Li \&: Ar ...
+.It Fl maproot Li = Ar user\^ Li \&: Op Ar group1\^ Li \&: group2\^ Li \&: Ar ...
 .Sm on
 The colon separated list is used to specify the precise credential
 to be used for remote access by root.
@@ -167,13 +167,13 @@ should be used to distinguish a credenti
 complete credential for that user.
 .Sm off
 .It Fl mapall Li = Ar user
-.It Fl mapall Li = Ar user\^ Li \&: Ar group1\^ Li \&: Ar group2\^ Li \&: Ar ...
+.It Fl mapall Li = Ar user\^ Li \&: Op Ar group1\^ Li \&: Ar group2\^ Li \&: Ar ...
 .Sm on
 Mapping for all client uids (including root)
 using the same semantics as
 .Fl maproot .
 .It Fl r Ar user
-.It Fl r Ar user\^ Ns Li \&: Ns Ar group1\^ Ns Li \&: Ns Ar group2\^ Ns Li \&: Ns Ar ...
+.It Fl r Ar user\^ Ns Li \&: Ns Op Ar group1\^ Ns Li \&: Ns Ar group2\^ Ns Li \&: Ns Ar ...
 Synonym for
 .Fl maproot ,
 for compatibility with older export file formats.



CVS commit: src/usr.sbin/mountd

2024-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 29 14:15:02 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Tiny punctuation fix in man page.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.37 src/usr.sbin/mountd/exports.5:1.38
--- src/usr.sbin/mountd/exports.5:1.37	Fri Mar 29 00:23:05 2024
+++ src/usr.sbin/mountd/exports.5	Fri Mar 29 14:15:02 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.37 2024/03/29 00:23:05 snj Exp $
+.\"	$NetBSD: exports.5,v 1.38 2024/03/29 14:15:02 riastradh Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -408,7 +408,7 @@ directory within
 .Pa /u2
 and mapping all uids to credentials for the principal
 that is authenticated by a Kerberos ticket.
-.Pq Sy Kerberos not implemented .
+.Pq Sy Kerberos not implemented.
 .It Pa /a
 is exported to the network
 .Ql 192.168.0.0 ,



CVS commit: src/usr.sbin/mountd

2024-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 29 14:15:02 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Tiny punctuation fix in man page.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Mar 29 00:23:06 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
pick some nits


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.36 src/usr.sbin/mountd/exports.5:1.37
--- src/usr.sbin/mountd/exports.5:1.36	Wed Mar 27 13:11:14 2024
+++ src/usr.sbin/mountd/exports.5	Fri Mar 29 00:23:05 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.36 2024/03/27 13:11:14 uwe Exp $
+.\"	$NetBSD: exports.5,v 1.37 2024/03/29 00:23:05 snj Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -70,7 +70,7 @@ or
 Warning:
 Exporting a directory exposes the
 .Em entire
-content of the filesystem that the directory lives in to
+contents of the filesystem that the directory lives in to
 .Tn NFS
 clients.
 .Ef
@@ -312,7 +312,7 @@ A, B or C; see
 .Xr inet 4
 .Pc .
 .Pp
-Scoped IPv6 address must carry scope identifier as documented in
+Scoped IPv6 address must carry a scope identifier as documented in
 .Xr inet6 4 .
 For example,
 .Ql fe80::%ne2/10
@@ -338,11 +338,11 @@ The default remote mount-point file.
 .Pp
 If you have modified the
 .Pa /etc/exports
-file, send the mountd a
+file, send the mountd process a
 .Dv SIGHUP
 to make it re-read it:
 .Pp
-.Dl "kill -HUP $(cat /var/run/mountd.pid)" .
+.Dl "kill -HUP $(cat /var/run/mountd.pid)"
 .Sh EXAMPLES
 .Bd -literal -offset indent
 /usr /usr/local -maproot=0:10 friends



CVS commit: src/usr.sbin/mountd

2024-03-28 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Mar 29 00:23:06 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
pick some nits


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-27 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 27 13:11:14 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): improve mark up


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-27 Thread Valery Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 27 13:11:14 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): improve mark up


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.35 src/usr.sbin/mountd/exports.5:1.36
--- src/usr.sbin/mountd/exports.5:1.35	Wed Mar 27 01:43:26 2024
+++ src/usr.sbin/mountd/exports.5	Wed Mar 27 13:11:14 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.35 2024/03/27 01:43:26 riastradh Exp $
+.\"	$NetBSD: exports.5,v 1.36 2024/03/27 13:11:14 uwe Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)exports.5	8.3 (Berkeley) 3/29/95
 .\"
-.Dd October 8, 2006
+.Dd March 27, 2024
 .Dt EXPORTS 5
 .Os
 .Sh NAME
@@ -55,16 +55,16 @@ Each entry in
 is a line with a list of directories followed by a list of hosts,
 netgroups, and options, separated by spaces or tabs:
 .Pp
-.Dl Pf / Va dir "..." Oo Va host | Va netgroup | Fl Va option Oc "..."
+.D1 Li / Ns Ar dir Li ... Oo Ar host | Ar netgroup | Fl Ar option Oc Li ...
 .Pp
 All directories in a single line must live in the same filesystem,
 which is exported to the hosts and netgroups listed, according to the
 options specified.
 Exported directories must not have pathname components that are
 symbolic links,
-.Ql "." ,
+.Ql \&. ,
 or
-.Ql ".." .
+.Ql \&.. .
 .Pp
 .Bf -symbolic
 Warning:
@@ -110,8 +110,9 @@ must come before any hosts, netgroups, o
 Options begin with
 .Ql - .
 All other items on an export line are interpreted either as netgroups
-(see
-.Xr netgroup 5 )
+.Po see
+.Xr netgroup 5
+.Pc
 or as hosts, which can be either names, as in example.com, or numbers,
 as in 192.0.2.123 or 2001:db8:1234:abcd::42.
 Sets of hosts in a contiguous network range can be specified with the
@@ -129,7 +130,7 @@ options are exported to
 hosts on the network, with no access control.
 .Pp
 Supported export options:
-.Bl -tag -width ".Fl noresvport"
+.Bl -tag -width Fl
 .It Fl alldirs
 Allow mount requests from clients at any point within the filesystem,
 including regular files.
@@ -144,39 +145,40 @@ A client
 can still access the whole filesystem via individual RPCs if it
 wanted to, even if just one subdirectory has been mounted.
 .Sm off
-.It Fl maproot No = Ar user
+.It Fl maproot Li = Ar user
 .Sm on
 The credential of the specified user is used for remote access by root.
 The credential includes all the groups to which the user is a member
-on the local machine (see
-.Xr id 1 ) .
+on the local machine
+.Po see
+.Xr id 1
+.Pc .
 The user may be specified by name or number.
 .Sm off
-.It Fl maproot No = Ar user : group1 : group2 : ...
+.It Fl maproot Li = Ar user\^ Li \&: Ar group1\^ Li \&: group2\^ Li \&: Ar ...
 .Sm on
 The colon separated list is used to specify the precise credential
 to be used for remote access by root.
 The elements of the list may be either names or numbers.
 Note that
-.Sm off
-.Ql Ar user ":"
-.Sm on
+.Sq Ar user\^ Ns Li \&:
+(with the trailing colon)
 should be used to distinguish a credential containing no groups from a
 complete credential for that user.
 .Sm off
-.It Fl mapall No = Ar user
-.It Fl mapall No = Ar user : group1 : group2 : ...
+.It Fl mapall Li = Ar user
+.It Fl mapall Li = Ar user\^ Li \&: Ar group1\^ Li \&: Ar group2\^ Li \&: Ar ...
 .Sm on
 Mapping for all client uids (including root)
 using the same semantics as
 .Fl maproot .
 .It Fl r Ar user
-.It Fl r Ar user Ns : Ns Ar group1 Ns : Ns Ar group2 Ns : Ar ...
+.It Fl r Ar user\^ Ns Li \&: Ns Ar group1\^ Ns Li \&: Ns Ar group2\^ Ns Li \&: Ns Ar ...
 Synonym for
 .Fl maproot ,
 for compatibility with older export file formats.
 .Pp
-Note:
+.Em Note :
 Not a synonym for the read-only option
 .Fl ro .
 .El
@@ -196,7 +198,7 @@ If a
 option is given,
 all users (including root) will be mapped to that credential in
 place of their own.
-.Bl -tag -width ".Fl noresvport"
+.Bl -tag -width Fl
 .It Fl kerb
 Specifies that the Kerberos authentication server should be
 used to authenticate and map client credentials.
@@ -204,8 +206,11 @@ used to authenticate and map client cred
 .It Fl ro
 Export filesystem read-only.
 Clients will be forbidden to change or write to anything in the
-filesystem (except for named pipes, sockets, and device nodes, where
-write semantics is client-side anyway).
+filesystem
+.Po
+except for named pipes, sockets, and device nodes, where
+write semantics is client-side anyway
+.Pc .
 .It Fl o
 Synonym for
 .Fl ro
@@ -226,9 +231,7 @@ Using this option decreases the security
 (WebNFS)
 Enables WebNFS export, equivalent to combining
 .Fl public ,
-.Sm off
-.Fl mapall No = Ar nobody ,
-.Sm on
+.Fl mapall=nobody ,
 and
 .Fl ro .
 .It Fl 

CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 27 01:43:26 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Substantially rewrite for clarity.

Hope this is an improvement over the turgid paragraphs all about
first/second/third cases of everything.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.34 src/usr.sbin/mountd/exports.5:1.35
--- src/usr.sbin/mountd/exports.5:1.34	Wed Mar 27 00:46:17 2024
+++ src/usr.sbin/mountd/exports.5	Wed Mar 27 01:43:26 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.34 2024/03/27 00:46:17 riastradh Exp $
+.\"	$NetBSD: exports.5,v 1.35 2024/03/27 01:43:26 riastradh Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -39,116 +39,147 @@
 mount requests
 .Sh DESCRIPTION
 The
-.Nm exports
+.Nm
 file on an
 .Tn NFS
-server, used by
-.Xr mountd 8 ,
-lists filesystems to be exported to
+server lists filesystems to be exported to
 .Tn NFS
 clients.
+It is read and applied by
+.Xr mountd 8
+on start and on
+.Dv SIGHUP .
+.Pp
+Each entry in
+.Nm
+is a line with a list of directories followed by a list of hosts,
+netgroups, and options, separated by spaces or tabs:
+.Pp
+.Dl Pf / Va dir "..." Oo Va host | Va netgroup | Fl Va option Oc "..."
+.Pp
+All directories in a single line must live in the same filesystem,
+which is exported to the hosts and netgroups listed, according to the
+options specified.
+Exported directories must not have pathname components that are
+symbolic links,
+.Ql "." ,
+or
+.Ql ".." .
 .Pp
+.Bf -symbolic
+Warning:
 Exporting a directory exposes the
 .Em entire
 content of the filesystem that the directory lives in to
 .Tn NFS
-clients, even it it isn't the root directory of a filesystem on the
-server.
-The list of exports is only what the server advertises to clients in
-the mount protocol, not a restriction on what files or directories
-within exported filesystems clients have access to with
-.Tn NFS .
-.Pp
-Each line in the file
-(other than comment lines that begin with a
-.Sq # )
-specifies the mount point(s) and export flags within one local server
-filesystem for one or more hosts.
-A host may be specified only once for each local filesystem on the
-server and there may be only one default entry for each server
-filesystem that applies to all other hosts.
-The latter exports the filesystem to the
-.Dq world
-and should
-be used only when the filesystem contains public information.
+clients.
+.Ef
+This happens even if an exported directory is not the root directory of
+a filesystem on the server.
+.Tn NFS
+clients are only prevented from access to files and directories on
+filesystems that are
+.Em not
+exported at all.
 .Pp
-If you have modified the
-.Pa /etc/exports
-file, send the mountd a SIGHUP to make it re-read the
-.Pa /etc/exports
-file:
-.Dq kill -HUP `cat /var/run/mountd.pid` .
+.Bf -symbolic
+Warning:
+Access control is only by network address.
+.Ef
+.Tn NFS
+servers with any non-public data should be exposed only to restricted
+or firewalled networks with ingress filtering.
+There is no authentication or encryption to make it safe for
+restricting access on the open internet.
+.Pp
+Blank lines are ignored.
+Text beginning with
+.Ql #
+until the end of line is ignored as a comment.
+Each line ending with
+.Ql \e
+has the next line appended, without the
+.Ql \e ,
+as a continuation line.
+Characters can be escaped with
+.Ql \e .
+.Pp
+All directories, which begin with
+.Ql / ,
+must come before any hosts, netgroups, or options on a line.
+Options begin with
+.Ql - .
+All other items on an export line are interpreted either as netgroups
+(see
+.Xr netgroup 5 )
+or as hosts, which can be either names, as in example.com, or numbers,
+as in 192.0.2.123 or 2001:db8:1234:abcd::42.
+Sets of hosts in a contiguous network range can be specified with the
+.Fl network
+option.
 .Pp
-In a mount entry,
-the first field(s) specify the directory path(s) within a server filesystem
-that can be mounted on by the corresponding client(s).
-There are two forms of this specification.
-The first is to list all mount points as absolute
-directory paths separated by whitespace.
-The second is to specify the pathname of the root of the filesystem
-followed by the
-.Fl alldirs
-flag;
-this form allows the host(s) to mount at any point within the filesystem,
+The same filesystem may be exported on multiple lines with different
+options to different sets of hosts, as long as it is exported at most
+once to each host, netgroup, or network.
+.Pp
+Export lines with no hosts, netgroups, or
+.Fl network
+options are exported to
+.Em any
+hosts on the network, with no access control.

CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 27 01:43:26 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Substantially rewrite for clarity.

Hope this is an improvement over the turgid paragraphs all about
first/second/third cases of everything.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 27 00:46:17 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Revert warning about `-ro' on read/write file systems.

Looks like the nfs server does enforce that after all, in spite of
the rather oblique commentary in the BUGS section about export
options being tied to local mount point options with which they must
be noncontradictory.

And there's no reason in principle it shouldn't enforce this -- it
just need to block various file system _operations_, rather than the
subtree issue where the criteria for evaluating whether operations
are allowed on particular _file handles_ are too painful to
contemplate.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.33 src/usr.sbin/mountd/exports.5:1.34
--- src/usr.sbin/mountd/exports.5:1.33	Tue Mar 26 23:32:43 2024
+++ src/usr.sbin/mountd/exports.5	Wed Mar 27 00:46:17 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.33 2024/03/26 23:32:43 riastradh Exp $
+.\"	$NetBSD: exports.5,v 1.34 2024/03/27 00:46:17 riastradh Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -174,33 +174,14 @@ This option is currently not implemented
 .Pp
 The
 .Fl ro
-option should be specified for filesystems that are read-only (default
-is to assume read/write).
+option specifies that the filesystem should be exported read-only
+(default read/write).
 The option
 .Fl o
 is a synonym for
 .Fl ro
 in an effort to be backward compatible with older export file formats.
 .Pp
-.Bf -symbolic
-Warning:
-Exporting a read/write filesystem with
-.Fl ro
-.Em does not
-prevent clients from writing to it.
-.Ef
-To prevent clients from writing to a filesystem, it must be mounted
-read-only
-.Em on the server
-in the first place.
-To export a read/write filesystem so clients can only read from it, not
-write to it, you can mount a read-only nullfs from the filesystem with
-.Xr mount_null 8
-using the
-.Fl o Cm ro
-option, and then export the read-only nullfs instead.
-See also caveats about nullfs namespace below.
-.Pp
 The
 .Fl noresvport
 option specifies that NFS RPC calls for the filesystem do not have to come
@@ -424,7 +405,7 @@ systems.
 .Pp
 .Pp
 Filesystems that provide a namespace for a subtree of another
-filesystem such as nullfs 
+filesystem such as nullfs
 .No ( Xr mount_null 8 )
 and umapfs
 .No ( Xr mount_umap 8 )



CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar 27 00:46:17 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
exports(5): Revert warning about `-ro' on read/write file systems.

Looks like the nfs server does enforce that after all, in spite of
the rather oblique commentary in the BUGS section about export
options being tied to local mount point options with which they must
be noncontradictory.

And there's no reason in principle it shouldn't enforce this -- it
just need to block various file system _operations_, rather than the
subtree issue where the criteria for evaluating whether operations
are allowed on particular _file handles_ are too painful to
contemplate.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 26 23:32:43 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5 mountd.8

Log Message:
exports(5), mountd(8): First pass at clarifying export semantics.

The exports(5) man page is full of walls of turgid prose that should
be itemized lists with syntax templates, and I'm itching to rewrite
it, but let's get the security-relevant warnings out of the way
first.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mountd/exports.5
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.32 src/usr.sbin/mountd/exports.5:1.33
--- src/usr.sbin/mountd/exports.5:1.32	Thu Mar 28 22:54:25 2013
+++ src/usr.sbin/mountd/exports.5	Tue Mar 26 23:32:43 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: exports.5,v 1.32 2013/03/28 22:54:25 njoly Exp $
+.\"	$NetBSD: exports.5,v 1.33 2024/03/26 23:32:43 riastradh Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -34,22 +34,30 @@
 .Os
 .Sh NAME
 .Nm exports
-.Nd define remote mount points for
+.Nd exported filesystem mount points for
 .Tn NFS
 mount requests
-.Sh SYNOPSIS
-.Nm exports
 .Sh DESCRIPTION
 The
 .Nm exports
-file specifies remote mount points for the
+file on an
 .Tn NFS
-mount protocol per the
+server, used by
+.Xr mountd 8 ,
+lists filesystems to be exported to
 .Tn NFS
-server specification; see
-.%T "Network File System Protocol Specification RFC 1094, Appendix A"
-and
-.%T "NFS: Network File System Version 3 Specification, Appendix I" .
+clients.
+.Pp
+Exporting a directory exposes the
+.Em entire
+content of the filesystem that the directory lives in to
+.Tn NFS
+clients, even it it isn't the root directory of a filesystem on the
+server.
+The list of exports is only what the server advertises to clients in
+the mount protocol, not a restriction on what files or directories
+within exported filesystems clients have access to with
+.Tn NFS .
 .Pp
 Each line in the file
 (other than comment lines that begin with a
@@ -166,14 +174,33 @@ This option is currently not implemented
 .Pp
 The
 .Fl ro
-option specifies that the filesystem should be exported read-only
-(default read/write).
+option should be specified for filesystems that are read-only (default
+is to assume read/write).
 The option
 .Fl o
 is a synonym for
 .Fl ro
 in an effort to be backward compatible with older export file formats.
 .Pp
+.Bf -symbolic
+Warning:
+Exporting a read/write filesystem with
+.Fl ro
+.Em does not
+prevent clients from writing to it.
+.Ef
+To prevent clients from writing to a filesystem, it must be mounted
+read-only
+.Em on the server
+in the first place.
+To export a read/write filesystem so clients can only read from it, not
+write to it, you can mount a read-only nullfs from the filesystem with
+.Xr mount_null 8
+using the
+.Fl o Cm ro
+option, and then export the read-only nullfs instead.
+See also caveats about nullfs namespace below.
+.Pp
 The
 .Fl noresvport
 option specifies that NFS RPC calls for the filesystem do not have to come
@@ -369,6 +396,23 @@ The default remote mount-point file.
 .Xr mountd 8 ,
 .Xr nfsd 8 ,
 .Xr showmount 8
+.Rs
+.%T NFS: Network File System Protocol Specification
+.%R RFC 1094
+.%I IETF Network Working Group
+.%O Appendix A
+.%U https://datatracker.ietf.org/doc/html/rfc1094#appendix-A.1
+.Re
+.Rs
+.%A B. Callaghan
+.%A B. Pawlowski
+.%A P. Staubach
+.%T NFS Version 3 Protocol Specification
+.%R RFC 1813
+.%I IETF Network Working Group
+.%O Appendix I
+.%U https://datatracker.ietf.org/doc/html/rfc1813#section-5.0
+.Re
 .Sh CAVEATS
 Don't re-export NFS-mounted filesystems unless you are sure of the
 implications.
@@ -377,6 +421,21 @@ systems being exported, e.g. when timest
 Re-exporting should work to some extent and can even be useful in
 some cases, but don't expect it works as well as with local file
 systems.
+.Pp
+.Pp
+Filesystems that provide a namespace for a subtree of another
+filesystem such as nullfs 
+.No ( Xr mount_null 8 )
+and umapfs
+.No ( Xr mount_umap 8 )
+.Em do not
+restrict
+.Tn NFS
+clients to that namespace, so they cannot be used to securely limit
+.Tn NFS
+clients to a subtree of a filesystem.
+If you want to export one subtree and prevent access to other subtrees,
+the exported subtree must be on its own filesystem on the server.
 .Sh BUGS
 The export options are tied to the local mount points in the kernel and
 must be non-contradictory for any exported subdirectory of the local

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.42 src/usr.sbin/mountd/mountd.8:1.43
--- src/usr.sbin/mountd/mountd.8:1.42	Wed Mar 15 20:39:12 2023
+++ src/usr.sbin/mountd/mountd.8	Tue Mar 26 23:32:43 2024
@@ -1,4 +1,4 @@
-.\"	

CVS commit: src/usr.sbin/mountd

2024-03-26 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Mar 26 23:32:43 UTC 2024

Modified Files:
src/usr.sbin/mountd: exports.5 mountd.8

Log Message:
exports(5), mountd(8): First pass at clarifying export semantics.

The exports(5) man page is full of walls of turgid prose that should
be itemized lists with syntax templates, and I'm itching to rewrite
it, but let's get the security-relevant warnings out of the way
first.

PR misc/58063


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mountd/exports.5
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2023-03-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 15 20:39:12 UTC 2023

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mountd(8): comma before "and"

Not a serial comma, technically, as there are only two items, but it
makes reading easier, IMHO.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.41 src/usr.sbin/mountd/mountd.8:1.42
--- src/usr.sbin/mountd/mountd.8:1.41	Wed Mar 15 20:33:04 2023
+++ src/usr.sbin/mountd/mountd.8	Wed Mar 15 20:39:12 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.41 2023/03/15 20:33:04 uwe Exp $
+.\"	$NetBSD: mountd.8,v 1.42 2023/03/15 20:39:12 uwe Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -53,7 +53,7 @@ listens for service requests at the port
 .Tn NFS
 server specification; see
 .%T "Network File System Protocol Specification" ,
-RFC 1094, Appendix A and
+RFC 1094, Appendix A, and
 .%T "NFS: Network File System Version 3 Protocol Specification" ,
 Appendix I.
 .Pp



CVS commit: src/usr.sbin/mountd

2023-03-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 15 20:39:12 UTC 2023

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mountd(8): comma before "and"

Not a serial comma, technically, as there are only two items, but it
makes reading easier, IMHO.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2023-03-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 15 20:33:04 UTC 2023

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mountd(8): fix minor markup nits

While here, use $() instead of `` in the example.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.40 src/usr.sbin/mountd/mountd.8:1.41
--- src/usr.sbin/mountd/mountd.8:1.40	Tue Feb 16 10:01:55 2021
+++ src/usr.sbin/mountd/mountd.8	Wed Mar 15 20:33:04 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.40 2021/02/16 10:01:55 wiz Exp $
+.\"	$NetBSD: mountd.8,v 1.41 2023/03/15 20:33:04 uwe Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -59,7 +59,7 @@ Appendix I.
 .Pp
 Options and operands available for
 .Nm mountd :
-.Bl -tag -width Ds
+.Bl -tag -width Fl
 .It Fl d
 Enable debugging mode.
 .Nm
@@ -68,7 +68,7 @@ debugging messages to stderr.
 .It Fl N
 Do not require privileged ports for mount or NFS RPC calls.
 This option is equivalent to specifying
-.Dq -noresvport -noresvmnt
+.Ql -noresvport -noresvmnt
 on every export.
 See
 .Xr exports 5
@@ -94,13 +94,15 @@ to bind to the given port.
 If this option is not given,
 .Nm
 may bind to every anonymous port
-(in the range 600-1023) which causes trouble when trying to use
+(in the range 600\^\(en1023) which causes trouble when trying to use
 NFS through a firewall.
 .It Ar exportsfile
 The
 .Ar exportsfile
 argument specifies an alternative location
-for the exports file.
+for the
+.Xr exports 5
+file.
 Multiple exports files can be defined.
 .El
 .Pp
@@ -115,19 +117,23 @@ After changing the exports file,
 a hangup signal should be sent to the
 .Nm
 daemon to get it to reload the export information.
-After sending the SIGHUP
-(kill \-s HUP `cat /var/run/mountd.pid`),
+After sending the
+.Dv SIGHUP
+.Pp
+.Dl kill \-s HUP $(cat /var/run/mountd.pid)
+.Pp
 check the syslog output to see if
 .Nm
 logged any parsing errors in the exports file.
 .Pp
-After receiving SIGTERM,
+After receiving
+.Dv SIGTERM ,
 .Nm
 sends a broadcast request to remove the mount list from all the clients.
 This can take a long time, since the broadcast request waits for each
 client to respond.
 .Sh FILES
-.Bl -tag -width /var/run/mountd.pid -compact
+.Bl -tag -width ".Pa /var/run/mountd.pid" -compact
 .It Pa /etc/exports
 the list of exported filesystems
 .It Pa /var/run/mountd.pid



CVS commit: src/usr.sbin/mountd

2023-03-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Mar 15 20:33:04 UTC 2023

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mountd(8): fix minor markup nits

While here, use $() instead of `` in the example.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun  5 08:26:34 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Fix typo, its the element not the array ...


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.136 src/usr.sbin/mountd/mountd.c:1.137
--- src/usr.sbin/mountd/mountd.c:1.136	Fri Jun  4 10:46:57 2021
+++ src/usr.sbin/mountd/mountd.c	Sat Jun  5 08:26:34 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.136 2021/06/04 10:46:57 hannken Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.137 2021/06/05 08:26:34 hannken Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.136 2021/06/04 10:46:57 hannken Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.137 2021/06/05 08:26:34 hannken Exp $");
 #endif
 #endif/* not lint */
 
@@ -1294,7 +1294,7 @@ get_exportlist(int n)
 		(mel->mel_nexports > 0 || errno != EOPNOTSUPP))
 			syslog(LOG_ERR, "Can't update exports for %s (%m)",
 			mel_tab[i].mel_path);
-		for (j = 0; j < (int)mel_tab->mel_nexports; j++) {
+		for (j = 0; j < (int)mel->mel_nexports; j++) {
 			struct export_args *export = >mel_exports[j];
 
 			if (export->ex_indexfile)



CVS commit: src/usr.sbin/mountd

2021-06-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jun  5 08:26:34 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Fix typo, its the element not the array ...


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:46:57 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Change get_exportlist() to collect all exports and emit all
exports for a single mount in one call to nfssvc(2).

Should finally fix PR kern/5844 (NFS server sends "permission denied"
while mound re-read exports).


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.135 src/usr.sbin/mountd/mountd.c:1.136
--- src/usr.sbin/mountd/mountd.c:1.135	Fri Jun  4 10:46:01 2021
+++ src/usr.sbin/mountd/mountd.c	Fri Jun  4 10:46:57 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.135 2021/06/04 10:46:01 hannken Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.136 2021/06/04 10:46:57 hannken Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.135 2021/06/04 10:46:01 hannken Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.136 2021/06/04 10:46:57 hannken Exp $");
 #endif
 #endif/* not lint */
 
@@ -235,6 +235,8 @@ static struct uucred def_anon = {
 	0,
 	{ 0 }
 };
+static struct mountd_exports_list *mel_tab;
+static int mel_tab_len;
 
 int  opt_flags;
 static int	have_v6 = 1;
@@ -1207,6 +1209,18 @@ nextline:
 }
 
 /*
+ * Compare two export lists by path.
+ */
+static int
+mel_compare(const void *a, const void *b)
+{
+	const struct mountd_exports_list *mela = a;
+	const struct mountd_exports_list *melb = b;
+
+	return strcmp(mela->mel_path, melb->mel_path);
+}
+
+/*
  * Get the export list
  */
 /* ARGSUSED */
@@ -1216,7 +1230,7 @@ get_exportlist(int n)
 	struct exportlist *ep, *ep2;
 	struct grouplist *grp, *tgrp;
 	struct statvfs *fsp;
-	int num, i;
+	int i, j;
 	FILE *exp_file;
 
 
@@ -1243,20 +1257,14 @@ get_exportlist(int n)
 	 * And delete exports that are in the kernel for all local
 	 * file systems.
 	 */
-	num = getmntinfo(, MNT_NOWAIT);
-	for (i = 0; i < num; i++) {
-		struct mountd_exports_list mel;
-
-		/* Delete all entries from the export list. */
-		mel.mel_path = fsp->f_mntonname;
-		mel.mel_nexports = 0;
-		if (nfssvc(NFSSVC_SETEXPORTSLIST, ) == -1 &&
-		errno != EOPNOTSUPP)
-			syslog(LOG_ERR, "Can't delete exports for %s (%m)",
-			fsp->f_mntonname);
-
-		fsp++;
+	mel_tab_len = getmntinfo(, MNT_NOWAIT);
+	mel_tab = ecalloc(mel_tab_len, sizeof(*mel_tab));
+	for (i = 0; i < mel_tab_len; i++) {
+		mel_tab[i].mel_path = estrdup(fsp[i].f_mntonname);
+		mel_tab[i].mel_nexports = 0;
+		mel_tab[i].mel_exports = NULL;
 	}
+	qsort(mel_tab, mel_tab_len, sizeof(mel_tab[0]), mel_compare);
 
 	/*
 	 * Read in the exports file and build the list, calling
@@ -1278,6 +1286,30 @@ get_exportlist(int n)
 
 		(void)fclose(exp_file);
 	}
+
+	for (i = 0; i < mel_tab_len; i++) {
+		struct mountd_exports_list *mel = _tab[i];
+
+		if (nfssvc(NFSSVC_REPLACEEXPORTSLIST, mel) == -1 &&
+		(mel->mel_nexports > 0 || errno != EOPNOTSUPP))
+			syslog(LOG_ERR, "Can't update exports for %s (%m)",
+			mel_tab[i].mel_path);
+		for (j = 0; j < (int)mel_tab->mel_nexports; j++) {
+			struct export_args *export = >mel_exports[j];
+
+			if (export->ex_indexfile)
+free(export->ex_indexfile);
+			if (export->ex_addr)
+free(export->ex_addr);
+			if (export->ex_mask)
+free(export->ex_mask);
+		}
+		if (mel->mel_nexports > 0)
+			free(mel->mel_exports);
+		free(__UNCONST(mel->mel_path));
+	}
+	free(mel_tab);
+	mel_tab_len = 0;
 }
 
 /*
@@ -1923,31 +1955,39 @@ add_export_arg(const char *path, int exf
 struct sockaddr *addrp, int addrlen, struct sockaddr *maskp, int masklen,
 char *indexfile)
 {
-	struct mountd_exports_list mel;
-	struct export_args export;
-	int error;
+	const struct mountd_exports_list mel_key = { .mel_path = path };
+	struct mountd_exports_list *mel;
+	struct export_args *export;
 
 	if (addrp != NULL && addrp->sa_family == AF_INET6 && have_v6 == 0)
 		return 0;
 
-	mel.mel_path = path;
-	mel.mel_nexports = 1;
-	mel.mel_exports = 
-
-	export.ex_flags = exflags;
-	export.ex_anon = *anoncrp;
-	export.ex_indexfile = indexfile;
-	export.ex_addr = addrp;
-	export.ex_addrlen = addrlen;
-	export.ex_mask = maskp;
-	export.ex_masklen = masklen;
-
-	error = nfssvc(NFSSVC_SETEXPORTSLIST, );
-
-	if (error) {
-		syslog(LOG_ERR, "Can't change attributes for %s: %m", path);
+	mel = bsearch(_key, mel_tab, mel_tab_len, sizeof(mel_tab[0]),
+	mel_compare);
+	if (mel == NULL) {
+		syslog(LOG_ERR, "Can't change attributes for %s: not found",
+		path);
 		return 1;
 	}
+	ereallocarr(>mel_exports, mel->mel_nexports + 1,
+	sizeof(*mel->mel_exports));
+	export = >mel_exports[mel->mel_nexports++];
+	memset(export, 0, sizeof(*export));
+
+	export->ex_flags = 

CVS commit: src/usr.sbin/mountd

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:46:57 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Change get_exportlist() to collect all exports and emit all
exports for a single mount in one call to nfssvc(2).

Should finally fix PR kern/5844 (NFS server sends "permission denied"
while mound re-read exports).


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:46:01 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Restructure do_nfssvc() and simplify the left cases GT_HOST and GT_NET.

Add a helper add_export_arg() that emits a single export_args item and
does the IPv6 check.
Always use the path of the mount point for the export.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.134 src/usr.sbin/mountd/mountd.c:1.135
--- src/usr.sbin/mountd/mountd.c:1.134	Tue Feb 16 10:00:27 2021
+++ src/usr.sbin/mountd/mountd.c	Fri Jun  4 10:46:01 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.134 2021/02/16 10:00:27 hannken Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.135 2021/06/04 10:46:01 hannken Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.134 2021/02/16 10:00:27 hannken Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.135 2021/06/04 10:46:01 hannken Exp $");
 #endif
 #endif/* not lint */
 
@@ -1918,6 +1918,40 @@ get_ht(void)
 	return (hp);
 }
 
+static int
+add_export_arg(const char *path, int exflags, struct uucred *anoncrp,
+struct sockaddr *addrp, int addrlen, struct sockaddr *maskp, int masklen,
+char *indexfile)
+{
+	struct mountd_exports_list mel;
+	struct export_args export;
+	int error;
+
+	if (addrp != NULL && addrp->sa_family == AF_INET6 && have_v6 == 0)
+		return 0;
+
+	mel.mel_path = path;
+	mel.mel_nexports = 1;
+	mel.mel_exports = 
+
+	export.ex_flags = exflags;
+	export.ex_anon = *anoncrp;
+	export.ex_indexfile = indexfile;
+	export.ex_addr = addrp;
+	export.ex_addrlen = addrlen;
+	export.ex_mask = maskp;
+	export.ex_masklen = masklen;
+
+	error = nfssvc(NFSSVC_SETEXPORTSLIST, );
+
+	if (error) {
+		syslog(LOG_ERR, "Can't change attributes for %s: %m", path);
+		return 1;
+	}
+
+	return 0;
+}
+
 /*
  * Do the nfssvc syscall to push the export info into the kernel.
  */
@@ -1930,92 +1964,37 @@ do_nfssvc(const char *line, size_t linen
 	struct sockaddr_storage ss;
 	struct addrinfo *ai;
 	int addrlen;
-	int done;
-	struct export_args export;
 
-	export.ex_flags = exflags;
-	export.ex_anon = *anoncrp;
-	export.ex_indexfile = ep->ex_indexfile;
 	if (grp->gr_type == GT_HOST) {
-		ai = grp->gr_ptr.gt_addrinfo;
-		addrp = ai->ai_addr;
-		addrlen = ai->ai_addrlen;
-	} else {
-		addrp = NULL;
-		ai = NULL;	/* XXXGCC -Wuninitialized */
-		addrlen = 0;	/* XXXGCC -Wuninitialized */
-	}
-	done = FALSE;
-	while (!done) {
-		struct mountd_exports_list mel;
-
-		switch (grp->gr_type) {
-		case GT_HOST:
-			if (addrp != NULL && addrp->sa_family == AF_INET6 &&
-			have_v6 == 0)
-goto skip;
-			export.ex_addr = addrp;
-			export.ex_addrlen = addrlen;
-			export.ex_masklen = 0;
-			break;
-		case GT_NET:
-			export.ex_addr = (struct sockaddr *)
-			>gr_ptr.gt_net.nt_net;
-			if (export.ex_addr->sa_family == AF_INET6 &&
-			have_v6 == 0)
-goto skip;
-			export.ex_addrlen = export.ex_addr->sa_len;
-			memset(, 0, sizeof ss);
-			ss.ss_family = export.ex_addr->sa_family;
-			ss.ss_len = export.ex_addr->sa_len;
-			if (allones(, grp->gr_ptr.gt_net.nt_len) != 0) {
-syslog(LOG_ERR,
-"\"%s\", line %ld: Bad network flag",
-line, (unsigned long)lineno);
-return (1);
-			}
-			export.ex_mask = (struct sockaddr *)
-			export.ex_masklen = ss.ss_len;
-			break;
-		default:
-			syslog(LOG_ERR, "\"%s\", line %ld: Bad netgroup type",
+		for (ai = grp->gr_ptr.gt_addrinfo; ai; ai = ai->ai_next) {
+			addrp = ai->ai_addr;
+			addrlen = ai->ai_addrlen;
+			if (add_export_arg(fsb->f_mntonname, exflags, anoncrp,
+			addrp, addrlen, NULL, 0, ep->ex_indexfile) != 0)
+return 1;
+		}
+	} else if (grp->gr_type == GT_NET) {
+		addrp = (struct sockaddr *)>gr_ptr.gt_net.nt_net;
+		addrlen = addrp->sa_len;
+		memset(, 0, sizeof ss);
+		ss.ss_family = addrp->sa_family;
+		ss.ss_len = addrp->sa_len;
+		if (allones(, grp->gr_ptr.gt_net.nt_len) != 0) {
+			syslog(LOG_ERR, "\"%s\", line %ld: Bad network flag",
 			line, (unsigned long)lineno);
-			return (1);
-		};
-
-		/*
-		 * XXX:
-		 * Maybe I should just use the fsb->f_mntonname path?
-		 */
-
-		mel.mel_path = dirp;
-		mel.mel_nexports = 1;
-		mel.mel_exports = 
-
-		if (nfssvc(NFSSVC_SETEXPORTSLIST, ) != 0) {
-			syslog(LOG_ERR,
-	"\"%s\", line %ld: Can't change attributes for %s to %s: %m",
-			line, (unsigned long)lineno,
-			dirp, (grp->gr_type == GT_HOST) ?
-			grp->gr_ptr.gt_addrinfo->ai_canonname :
-			(grp->gr_type == GT_NET) ?
-			grp->gr_ptr.gt_net.nt_name :
-			"Unknown");
-			return (1);
+			return 1;
 		}
-skip:
-		if (addrp) {
-			ai = 

CVS commit: src/usr.sbin/mountd

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:46:01 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Restructure do_nfssvc() and simplify the left cases GT_HOST and GT_NET.

Add a helper add_export_arg() that emits a single export_args item and
does the IPv6 check.
Always use the path of the mount point for the export.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Feb 16 10:01:55 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Reword slightly.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.39 src/usr.sbin/mountd/mountd.8:1.40
--- src/usr.sbin/mountd/mountd.8:1.39	Tue Feb 16 10:00:27 2021
+++ src/usr.sbin/mountd/mountd.8	Tue Feb 16 10:01:55 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.39 2021/02/16 10:00:27 hannken Exp $
+.\"	$NetBSD: mountd.8,v 1.40 2021/02/16 10:01:55 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -101,7 +101,7 @@ The
 .Ar exportsfile
 argument specifies an alternative location
 for the exports file.
-There can many exports files.
+Multiple exports files can be defined.
 .El
 .Pp
 When



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Feb 16 10:01:55 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Reword slightly.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 10:00:27 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.8 mountd.c

Log Message:
Add support for multiple exports files. This will be useful for example for
ZFS, where we have an automatically generated /etc/zfs/exports file, which
should not be edited directly.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/mountd/mountd.8
cvs rdiff -u -r1.133 -r1.134 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 10:00:27 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.8 mountd.c

Log Message:
Add support for multiple exports files. This will be useful for example for
ZFS, where we have an automatically generated /etc/zfs/exports file, which
should not be edited directly.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/mountd/mountd.8
cvs rdiff -u -r1.133 -r1.134 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.38 src/usr.sbin/mountd/mountd.8:1.39
--- src/usr.sbin/mountd/mountd.8:1.38	Sat Dec 24 08:26:57 2016
+++ src/usr.sbin/mountd/mountd.8	Tue Feb 16 10:00:27 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.38 2016/12/24 08:26:57 abhinav Exp $
+.\"	$NetBSD: mountd.8,v 1.39 2021/02/16 10:00:27 hannken Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)mountd.8	8.4 (Berkeley) 4/28/95
 .\"
-.Dd November 2, 2011
+.Dd February 16, 2021
 .Dt MOUNTD 8
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@ mount requests
 .Op Fl dN
 .Op Fl P Ar policy
 .Op Fl p Ar port
-.Op Ar exportsfile
+.Op Ar exportsfile ...
 .Sh DESCRIPTION
 .Nm
 is the server for
@@ -101,6 +101,7 @@ The
 .Ar exportsfile
 argument specifies an alternative location
 for the exports file.
+There can many exports files.
 .El
 .Pp
 When

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.133 src/usr.sbin/mountd/mountd.c:1.134
--- src/usr.sbin/mountd/mountd.c:1.133	Tue Feb 16 09:58:35 2021
+++ src/usr.sbin/mountd/mountd.c	Tue Feb 16 10:00:27 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.134 2021/02/16 10:00:27 hannken Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.134 2021/02/16 10:00:27 hannken Exp $");
 #endif
 #endif/* not lint */
 
@@ -226,7 +226,8 @@ __dead static void no_nfs(int);
 static struct exportlist *exphead;
 static struct mountlist *mlhead;
 static struct grouplist *grphead;
-static const char *exname;
+static char *const exnames_default[] = { __UNCONST(_PATH_EXPORTS), NULL };
+static char *const *exnames;
 static struct uucred def_anon = {
 	1,
 	(uid_t) -2,
@@ -384,15 +385,15 @@ main(int argc, char **argv)
 #ifdef IPSEC
 			" [-P policy]"
 #endif
-			" [-p port] [exportsfile]\n", getprogname());
+			" [-p port] [exportsfile ...]\n", getprogname());
 			exit(1);
 		};
 	argc -= optind;
 	argv += optind;
-	if (argc == 1)
-		exname = *argv;
+	if (argc > 0)
+		exnames = argv;
 	else
-		exname = _PATH_EXPORTS;
+		exnames = exnames_default;
 
 	s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
 	if (s < 0)
@@ -408,7 +409,7 @@ main(int argc, char **argv)
 
 	sem_init(, 0, 0);
 	pthread_create(, NULL, exportlist_thread, NULL);
-	exname = _PATH_EXPORTS;
+	exnames = exnames_default;
 	have_v6 = 0;
 	(void)signal(SIGHUP, signal_get_exportlist);
 #endif
@@ -1261,20 +1262,22 @@ get_exportlist(int n)
 	 * Read in the exports file and build the list, calling
 	 * mount() as we go along to push the export rules into the kernel.
 	 */
-	if ((exp_file = fopen(exname, "r")) == NULL) {
-		/*
-		 * Don't exit here; we can still reload the config
-		 * after a SIGHUP.
-		 */
-		if (mountd_debug)
-			(void)fprintf(stderr, "Can't open %s: %s\n", exname,
-			strerror(errno));
-		return;
-	}
+	for (i = 0; exnames[i] != NULL; i++) {
+		if ((exp_file = fopen(exnames[i], "r")) == NULL) {
+			/*
+			 * Don't exit here; we can still reload the config
+			 * after a SIGHUP.
+			 */
+			if (mountd_debug)
+(void)fprintf(stderr, "Can't open %s: %s\n",
+exnames[i], strerror(errno));
+			continue;
+		}
 
-	get_exportlist_one(exp_file);
+		get_exportlist_one(exp_file);
 
-	(void)fclose(exp_file);
+		(void)fclose(exp_file);
+	}
 }
 
 /*



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 09:58:35 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Split get_exportlist() into get_exportlist() and get_exportlist_one()
in preparation to support multiple input files.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.132 src/usr.sbin/mountd/mountd.c:1.133
--- src/usr.sbin/mountd/mountd.c:1.132	Wed Jun 17 00:16:21 2020
+++ src/usr.sbin/mountd/mountd.c	Tue Feb 16 09:58:35 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.132 2020/06/17 00:16:21 kamil Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.132 2020/06/17 00:16:21 kamil Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.133 2021/02/16 09:58:35 hannken Exp $");
 #endif
 #endif/* not lint */
 
@@ -1009,81 +1009,22 @@ parse_directory(const char *line, size_t
 }
 
 
-/*
- * Get the export list
- */
-/* ARGSUSED */
-void
-get_exportlist(int n)
+static void
+get_exportlist_one(FILE *exp_file)
 {
 	struct exportlist *ep, *ep2;
 	struct grouplist *grp, *tgrp;
 	struct exportlist **epp;
 	struct dirlist *dirhead;
-	struct statvfs fsb, *fsp;
+	struct statvfs fsb;
 	struct addrinfo *ai;
 	struct uucred anon;
 	char *cp, *endcp, *dirp, savedc;
-	int has_host, exflags, got_nondir, dirplen, num, i;
-	FILE *exp_file;
+	int has_host, exflags, got_nondir, dirplen;
 	char *line;
 	size_t lineno = 0, len;
 
-
-	/*
-	 * First, get rid of the old list
-	 */
-	ep = exphead;
-	while (ep) {
-		ep2 = ep;
-		ep = ep->ex_next;
-		free_exp(ep2);
-	}
-	exphead = NULL;
-
 	dirp = NULL;
-	dirplen = 0;
-	grp = grphead;
-	while (grp) {
-		tgrp = grp;
-		grp = grp->gr_next;
-		free_grp(tgrp);
-	}
-	grphead = NULL;
-
-	/*
-	 * And delete exports that are in the kernel for all local
-	 * file systems.
-	 */
-	num = getmntinfo(, MNT_NOWAIT);
-	for (i = 0; i < num; i++) {
-		struct mountd_exports_list mel;
-
-		/* Delete all entries from the export list. */
-		mel.mel_path = fsp->f_mntonname;
-		mel.mel_nexports = 0;
-		if (nfssvc(NFSSVC_SETEXPORTSLIST, ) == -1 &&
-		errno != EOPNOTSUPP)
-			syslog(LOG_ERR, "Can't delete exports for %s (%m)",
-			fsp->f_mntonname);
-
-		fsp++;
-	}
-
-	/*
-	 * Read in the exports file and build the list, calling
-	 * mount() as we go along to push the export rules into the kernel.
-	 */
-	if ((exp_file = fopen(exname, "r")) == NULL) {
-		/*
-		 * Don't exit here; we can still reload the config
-		 * after a SIGHUP.
-		 */
-		if (mountd_debug)
-			(void)fprintf(stderr, "Can't open %s: %s\n", exname,
-			strerror(errno));
-		return;
-	}
 	dirhead = NULL;
 	while ((line = fparseln(exp_file, , , NULL, 0)) != NULL) {
 		if (mountd_debug)
@@ -1262,6 +1203,77 @@ nextline:
 		}
 		free(line);
 	}
+}
+
+/*
+ * Get the export list
+ */
+/* ARGSUSED */
+void
+get_exportlist(int n)
+{
+	struct exportlist *ep, *ep2;
+	struct grouplist *grp, *tgrp;
+	struct statvfs *fsp;
+	int num, i;
+	FILE *exp_file;
+
+
+	/*
+	 * First, get rid of the old list
+	 */
+	ep = exphead;
+	while (ep) {
+		ep2 = ep;
+		ep = ep->ex_next;
+		free_exp(ep2);
+	}
+	exphead = NULL;
+
+	grp = grphead;
+	while (grp) {
+		tgrp = grp;
+		grp = grp->gr_next;
+		free_grp(tgrp);
+	}
+	grphead = NULL;
+
+	/*
+	 * And delete exports that are in the kernel for all local
+	 * file systems.
+	 */
+	num = getmntinfo(, MNT_NOWAIT);
+	for (i = 0; i < num; i++) {
+		struct mountd_exports_list mel;
+
+		/* Delete all entries from the export list. */
+		mel.mel_path = fsp->f_mntonname;
+		mel.mel_nexports = 0;
+		if (nfssvc(NFSSVC_SETEXPORTSLIST, ) == -1 &&
+		errno != EOPNOTSUPP)
+			syslog(LOG_ERR, "Can't delete exports for %s (%m)",
+			fsp->f_mntonname);
+
+		fsp++;
+	}
+
+	/*
+	 * Read in the exports file and build the list, calling
+	 * mount() as we go along to push the export rules into the kernel.
+	 */
+	if ((exp_file = fopen(exname, "r")) == NULL) {
+		/*
+		 * Don't exit here; we can still reload the config
+		 * after a SIGHUP.
+		 */
+		if (mountd_debug)
+			(void)fprintf(stderr, "Can't open %s: %s\n", exname,
+			strerror(errno));
+		return;
+	}
+
+	get_exportlist_one(exp_file);
+
 	(void)fclose(exp_file);
 }
 



CVS commit: src/usr.sbin/mountd

2021-02-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 16 09:58:35 UTC 2021

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Split get_exportlist() into get_exportlist() and get_exportlist_one()
in preparation to support multiple input files.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2020-04-22 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 23 00:22:01 UTC 2020

Modified Files:
src/usr.sbin/mountd: get_net.c mountd.c mountd.h

Log Message:
Rename debug to mountd_debug to avoid overlap in rump tests


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mountd/get_net.c
cvs rdiff -u -r1.130 -r1.131 src/usr.sbin/mountd/mountd.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2020-04-22 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr 23 00:22:01 UTC 2020

Modified Files:
src/usr.sbin/mountd: get_net.c mountd.c mountd.h

Log Message:
Rename debug to mountd_debug to avoid overlap in rump tests


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mountd/get_net.c
cvs rdiff -u -r1.130 -r1.131 src/usr.sbin/mountd/mountd.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/get_net.c
diff -u src/usr.sbin/mountd/get_net.c:1.2 src/usr.sbin/mountd/get_net.c:1.3
--- src/usr.sbin/mountd/get_net.c:1.2	Thu Dec 24 01:41:19 2015
+++ src/usr.sbin/mountd/get_net.c	Thu Apr 23 00:22:01 2020
@@ -1,4 +1,4 @@
-/* 	$NetBSD: get_net.c,v 1.2 2015/12/24 01:41:19 christos Exp $	 */
+/* 	$NetBSD: get_net.c,v 1.3 2020/04/23 00:22:01 joerg Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -33,7 +33,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: get_net.c,v 1.2 2015/12/24 01:41:19 christos Exp $");
+__RCSID("$NetBSD: get_net.c,v 1.3 2020/04/23 00:22:01 joerg Exp $");
 
 #include 
 #include 
@@ -52,7 +52,7 @@ __RCSID("$NetBSD: get_net.c,v 1.2 2015/1
 #ifdef TEST
 int  opt_flags;
 const int ninumeric = NI_NUMERICHOST;
-int  debug = 1;
+int  mountd_debug = 1;
 #endif
 
 static int 
@@ -145,7 +145,7 @@ get_net(char *cp, struct netmsk *net, in
 		sin.sin_family = AF_INET;
 		sin.sin_len = sizeof sin;
 		sin.sin_addr = inet_makeaddr(inet_network(cp), 0);
-		if (debug)
+		if (mountd_debug)
 			fprintf(stderr, "get_net: '%s' v4 addr %x\n",
 			cp, sin.sin_addr.s_addr);
 		sa = (struct sockaddr *)

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.130 src/usr.sbin/mountd/mountd.c:1.131
--- src/usr.sbin/mountd/mountd.c:1.130	Tue Jan  9 03:31:13 2018
+++ src/usr.sbin/mountd/mountd.c	Thu Apr 23 00:22:01 2020
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.130 2018/01/09 03:31:13 christos Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.131 2020/04/23 00:22:01 joerg Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.130 2018/01/09 03:31:13 christos Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.131 2020/04/23 00:22:01 joerg Exp $");
 #endif
 #endif/* not lint */
 
@@ -238,7 +238,7 @@ int  opt_flags;
 static int	have_v6 = 1;
 const int ninumeric = NI_NUMERICHOST;
 
-int  debug = DEBUGGING;
+int  mountd_debug = DEBUGGING;
 #if 0
 static void SYSLOG(int, const char *,...);
 #endif
@@ -369,7 +369,7 @@ main(int argc, char **argv)
 			forcedport = atoi(optarg);
 			break;
 		case 'd':
-			debug = 1;
+			mountd_debug = 1;
 			break;
 		case 'N':
 			noprivports = 1;
@@ -414,16 +414,16 @@ main(int argc, char **argv)
 	grphead = NULL;
 	exphead = NULL;
 	mlhead = NULL;
-	openlog("mountd", LOG_PID | (debug ? LOG_PERROR : 0), LOG_DAEMON);
+	openlog("mountd", LOG_PID | (mountd_debug ? LOG_PERROR : 0), LOG_DAEMON);
 	(void)signal(SIGSYS, no_nfs);
 
-	if (debug)
+	if (mountd_debug)
 		(void)fprintf(stderr, "Getting export list.\n");
 	get_exportlist(0);
-	if (debug)
+	if (mountd_debug)
 		(void)fprintf(stderr, "Getting mount list.\n");
 	get_mountlist();
-	if (debug)
+	if (mountd_debug)
 		(void)fprintf(stderr, "Here we go.\n");
 	(void)signal(SIGTERM, send_umntall);
 
@@ -547,7 +547,7 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
-	if (debug == 0) {
+	if (mountd_debug == 0) {
 		daemon(0, 0);
 		(void)signal(SIGINT, SIG_IGN);
 		(void)signal(SIGQUIT, SIG_IGN);
@@ -612,16 +612,16 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *t
 			syslog(LOG_ERR, "Can't send reply");
 		return;
 	case MOUNTPROC_MNT:
-		if (debug)
+		if (mountd_debug)
 			fprintf(stderr,
 			"got mount request from %s\n", numerichost);
 		if (!svc_getargs(transp, xdr_dir, rpcpath)) {
-			if (debug)
+			if (mountd_debug)
 fprintf(stderr, "-> garbage args\n");
 			svcerr_decode(transp);
 			return;
 		}
-		if (debug)
+		if (mountd_debug)
 			fprintf(stderr,
 			"-> rpcpath: %s\n", rpcpath);
 		/*
@@ -638,14 +638,14 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *t
 		(!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) ||
 		statvfs1(rdirpath, , ST_WAIT) < 0) {
 			(void)chdir("/"); /* Just in case realpath doesn't */
-			if (debug)
+			if (mountd_debug)
 (void)fprintf(stderr, "-> stat failed on %s\n",
 rdirpath);
 			if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) ))
 syslog(LOG_ERR, "Can't send reply");
 			return;
 		}
-		if (debug)
+		if (mountd_debug)
 			fprintf(stderr,
 			"-> dirpath: %s\n", rdirpath);
 		/* Check in the exports list */
@@ -696,7 +696,7 @@ mntsrv(struct svc_req *rqstp, SVCXPRT *t
 add_mlist(host, rdirpath, hostset);
 			else
 add_mlist(numerichost, rdirpath, hostset);
-			if (debug)
+			if (mountd_debug)
 

CVS commit: src/usr.sbin/mountd

2016-12-24 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat Dec 24 08:26:57 UTC 2016

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Remove xref to signal(7).

As noted by wiz, it is probably not a good idea to mention signal(7) in SEE ALSO
every time a signal name is used in a man page.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.37 src/usr.sbin/mountd/mountd.8:1.38
--- src/usr.sbin/mountd/mountd.8:1.37	Thu Dec 22 09:44:56 2016
+++ src/usr.sbin/mountd/mountd.8	Sat Dec 24 08:26:57 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.37 2016/12/22 09:44:56 abhinav Exp $
+.\"	$NetBSD: mountd.8,v 1.38 2016/12/24 08:26:57 abhinav Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -140,7 +140,6 @@ the list of remotely mounted filesystems
 .Xr nfssvc 2 ,
 .Xr ipsec_set_policy 3 ,
 .Xr exports 5 ,
-.Xr signal 7 ,
 .Xr nfsd 8 ,
 .Xr rpcbind 8 ,
 .Xr showmount 8



CVS commit: src/usr.sbin/mountd

2016-12-24 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat Dec 24 08:26:57 UTC 2016

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Remove xref to signal(7).

As noted by wiz, it is probably not a good idea to mention signal(7) in SEE ALSO
every time a signal name is used in a man page.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2016-12-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Dec 22 09:44:56 UTC 2016

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Add xrefs to ipsec_set_policy(3) and signal(7)


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2016-12-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Thu Dec 22 09:44:56 UTC 2016

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Add xrefs to ipsec_set_policy(3) and signal(7)


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.36 src/usr.sbin/mountd/mountd.8:1.37
--- src/usr.sbin/mountd/mountd.8:1.36	Wed Nov  2 20:27:33 2011
+++ src/usr.sbin/mountd/mountd.8	Thu Dec 22 09:44:56 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mountd.8,v 1.36 2011/11/02 20:27:33 wiz Exp $
+.\"	$NetBSD: mountd.8,v 1.37 2016/12/22 09:44:56 abhinav Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -138,7 +138,9 @@ the list of remotely mounted filesystems
 .Sh SEE ALSO
 .Xr nfsstat 1 ,
 .Xr nfssvc 2 ,
+.Xr ipsec_set_policy 3 ,
 .Xr exports 5 ,
+.Xr signal 7 ,
 .Xr nfsd 8 ,
 .Xr rpcbind 8 ,
 .Xr showmount 8



CVS commit: src/usr.sbin/mountd

2015-12-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 29 04:30:43 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.h

Log Message:
Add missing $NetBSD$ tag, and copy License/Copyright from mountd.c

OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2015-12-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Tue Dec 29 04:30:43 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.h

Log Message:
Add missing $NetBSD$ tag, and copy License/Copyright from mountd.c

OK christos@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.h
diff -u src/usr.sbin/mountd/mountd.h:1.2 src/usr.sbin/mountd/mountd.h:1.3
--- src/usr.sbin/mountd/mountd.h:1.2	Thu Dec 24 01:41:27 2015
+++ src/usr.sbin/mountd/mountd.h	Tue Dec 29 04:30:43 2015
@@ -1,3 +1,36 @@
+/* 	$NetBSD: mountd.h,v 1.3 2015/12/29 04:30:43 pgoyette Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Herb Hasler and Rick Macklem at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 #define	OP_MAPROOT	0x001
 #define	OP_MAPALL	0x002



CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 23 16:19:49 UTC 2015

Modified Files:
src/usr.sbin/mountd: Makefile mountd.c
Added Files:
src/usr.sbin/mountd: get_net.c mountd.h

Log Message:
Split out get_net function so that it is easily testable. Restore
functionality where 1.2.3/24 -> 1.2.3.0/24 not 1.2.0.3/24 now that
getaddrinfo(3) parses old-style incomplete dotted quads as old
style addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/mountd/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.sbin/mountd/get_net.c \
src/usr.sbin/mountd/mountd.h
cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/Makefile
diff -u src/usr.sbin/mountd/Makefile:1.18 src/usr.sbin/mountd/Makefile:1.19
--- src/usr.sbin/mountd/Makefile:1.18	Mon May 28 08:06:37 2007
+++ src/usr.sbin/mountd/Makefile	Wed Dec 23 11:19:49 2015
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.18 2007/05/28 12:06:37 tls Exp $
+#	$NetBSD: Makefile,v 1.19 2015/12/23 16:19:49 christos Exp $
 #	@(#)Makefile	8.3 (Berkeley) 1/25/94
 
 USE_FORT?= yes	# network server
 
 PROG=	mountd
-SRCS=	mountd.c ipsec.c
+SRCS=	mountd.c ipsec.c get_net.c
 MAN=	exports.5 mountd.8
 
 INETDDIR= ${.CURDIR}/../inetd

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.128 src/usr.sbin/mountd/mountd.c:1.129
--- src/usr.sbin/mountd/mountd.c:1.128	Sun Nov  8 16:03:16 2015
+++ src/usr.sbin/mountd/mountd.c	Wed Dec 23 11:19:49 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.128 2015/11/08 21:03:16 christos Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.129 2015/12/23 16:19:49 christos Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.128 2015/11/08 21:03:16 christos Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.129 2015/12/23 16:19:49 christos Exp $");
 #endif
 #endif/* not lint */
 
@@ -105,6 +105,8 @@ __RCSID("$NetBSD: mountd.c,v 1.128 2015/
 #define DEBUGGING 0
 #endif
 
+#include "mountd.h"
+
 /*
  * Structures for keeping the mount list and export list
  */
@@ -140,12 +142,6 @@ struct exportlist {
 /* ex_flag bits */
 #define	EX_LINKED	0x1
 
-struct netmsk {
-	struct sockaddr_storage nt_net;
-	int		nt_len;
-	char   *nt_name;
-};
-
 union grouptypes {
 	struct addrinfo *gt_addrinfo;
 	struct netmsk   gt_net;
@@ -206,7 +202,6 @@ static int get_host(const char *, size_t
 struct grouplist *);
 static struct hostlist *get_ht(void);
 static void get_mountlist(void);
-static int get_net(char *, struct netmsk *, int);
 static void free_exp_grp(struct exportlist *, struct grouplist *);
 static struct grouplist *get_grp(void);
 static void hang_dirp(struct dirlist *, struct grouplist *,
@@ -225,7 +220,6 @@ static int bitcmp(void *, void *, int);
 static int netpartcmp(struct sockaddr *, struct sockaddr *, int);
 static int sacmp(struct sockaddr *, struct sockaddr *);
 static int allones(struct sockaddr_storage *, int);
-static int countones(struct sockaddr *);
 static void bind_resv_port(int, sa_family_t, in_port_t);
 __dead static void no_nfs(int);
 static struct exportlist *exphead;
@@ -240,22 +234,11 @@ static struct uucred def_anon = {
 	{ 0 }
 };
 
-static int  opt_flags;
+int  opt_flags;
 static int	have_v6 = 1;
-static const int ninumeric = NI_NUMERICHOST;
-
-/* Bits for above */
-#define	OP_MAPROOT	0x001
-#define	OP_MAPALL	0x002
-#define	OP_KERB		0x004
-#define	OP_MASK		0x008
-#define	OP_NET		0x010
-#define	OP_ALLDIRS	0x040
-#define OP_NORESPORT	0x080
-#define OP_NORESMNT	0x100
-#define OP_MASKLEN	0x200
+const int ninumeric = NI_NUMERICHOST;
 
-static int  debug = DEBUGGING;
+int  debug = DEBUGGING;
 #if 0
 static void SYSLOG(int, const char *,...);
 #endif
@@ -1590,41 +1573,6 @@ allones(struct sockaddr_storage *ssp, in
 }
 
 static int
-countones(struct sockaddr *sa)
-{
-	void *mask;
-	int i, bits = 0, bytelen;
-	u_int8_t *p;
-
-	switch (sa->sa_family) {
-	case AF_INET:
-		mask = (u_int8_t *)&((struct sockaddr_in *)sa)->sin_addr;
-		bytelen = 4;
-		break;
-	case AF_INET6:
-		mask = (u_int8_t *)&((struct sockaddr_in6 *)sa)->sin6_addr;
-		bytelen = 16;
-		break;
-	default:
-		return 0;
-	}
-
-	p = mask;
-
-	for (i = 0; i < bytelen; i++, p++) {
-		if (*p != 0xff) {
-			for (bits = 0; bits < 8; bits++) {
-if (!(*p & (1 << (7 - bits
-	break;
-			}
-			break;
-		}
-	}
-
-	return (i * 8 + bits);
-}
-
-static int
 sacmp(struct sockaddr *sa1, struct sockaddr *sa2)
 {
 	void *p1, *p2;
@@ -2051,125 +1999,6 @@ skip:
 }
 
 /*
- * Translate a net address.
- */
-static int
-get_net(char *cp, struct netmsk *net, int maskflg)
-{
-	struct netent *np;
-	char *nname, *p, *prefp;
-	struct sockaddr_in sin, *sinp;
-	struct sockaddr *sa;
-	struct addrinfo hints, 

CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 23 16:19:49 UTC 2015

Modified Files:
src/usr.sbin/mountd: Makefile mountd.c
Added Files:
src/usr.sbin/mountd: get_net.c mountd.h

Log Message:
Split out get_net function so that it is easily testable. Restore
functionality where 1.2.3/24 -> 1.2.3.0/24 not 1.2.0.3/24 now that
getaddrinfo(3) parses old-style incomplete dotted quads as old
style addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/mountd/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.sbin/mountd/get_net.c \
src/usr.sbin/mountd/mountd.h
cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 24 01:41:27 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.h

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.h
diff -u src/usr.sbin/mountd/mountd.h:1.1 src/usr.sbin/mountd/mountd.h:1.2
--- src/usr.sbin/mountd/mountd.h:1.1	Wed Dec 23 11:19:49 2015
+++ src/usr.sbin/mountd/mountd.h	Wed Dec 23 20:41:27 2015
@@ -5,9 +5,9 @@
 #define	OP_MASK		0x008
 #define	OP_NET		0x010
 #define	OP_ALLDIRS	0x040
-#define OP_NORESPORT	0x080
-#define OP_NORESMNT	0x100
-#define OP_MASKLEN	0x200
+#define	OP_NORESPORT	0x080
+#define	OP_NORESMNT	0x100
+#define	OP_MASKLEN	0x200
 
 extern int opt_flags;
 extern int debug;



CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 24 01:41:19 UTC 2015

Modified Files:
src/usr.sbin/mountd: get_net.c

Log Message:
fix comment, from kre


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mountd/get_net.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/get_net.c
diff -u src/usr.sbin/mountd/get_net.c:1.1 src/usr.sbin/mountd/get_net.c:1.2
--- src/usr.sbin/mountd/get_net.c:1.1	Wed Dec 23 11:19:49 2015
+++ src/usr.sbin/mountd/get_net.c	Wed Dec 23 20:41:19 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: get_net.c,v 1.1 2015/12/23 16:19:49 christos Exp $	 */
+/* 	$NetBSD: get_net.c,v 1.2 2015/12/24 01:41:19 christos Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -33,7 +33,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: get_net.c,v 1.1 2015/12/23 16:19:49 christos Exp $");
+__RCSID("$NetBSD: get_net.c,v 1.2 2015/12/24 01:41:19 christos Exp $");
 
 #include 
 #include 
@@ -160,7 +160,7 @@ get_net(char *cp, struct netmsk *net, in
 	}
 
 	/*
-	 * Only allow /pref notation for v6 addresses.
+	 * Disallow v6 addresses without a specific mask or masklen
 	 */
 	if (sa->sa_family == AF_INET6 && (!(opt_flags & OP_MASKLEN) || maskflg))
 		return 1;



CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 24 01:41:19 UTC 2015

Modified Files:
src/usr.sbin/mountd: get_net.c

Log Message:
fix comment, from kre


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mountd/get_net.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2015-12-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 24 01:41:27 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.h

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mountd/mountd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2015-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  8 21:03:16 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Again copying code is bad; the second copy of mountd was completely stale.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2015-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  8 21:03:16 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Again copying code is bad; the second copy of mountd was completely stale.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.127 src/usr.sbin/mountd/mountd.c:1.128
--- src/usr.sbin/mountd/mountd.c:1.127	Wed Aug  5 19:23:47 2015
+++ src/usr.sbin/mountd/mountd.c	Sun Nov  8 16:03:16 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.128 2015/11/08 21:03:16 christos Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.128 2015/11/08 21:03:16 christos Exp $");
 #endif
 #endif/* not lint */
 
@@ -64,6 +64,13 @@ __RCSID("$NetBSD: mountd.c,v 1.127 2015/
 #include 
 #include 
 
+#ifdef MOUNTD_RUMP
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include 
 
 #include 
@@ -91,6 +98,13 @@ __RCSID("$NetBSD: mountd.c,v 1.127 2015/
 
 #include 
 
+#ifdef MOUNTD_RUMP
+#include "svc_fdset.h"
+#define DEBUGGING 1
+#else
+#define DEBUGGING 0
+#endif
+
 /*
  * Structures for keeping the mount list and export list
  */
@@ -203,7 +217,6 @@ static void parsecred(char *, struct uuc
 static int put_exlist(struct dirlist *, XDR *, struct dirlist *, int *);
 static int scan_tree(struct dirlist *, struct sockaddr *);
 __dead static void send_umntall(int);
-static int umntall_each(caddr_t, struct sockaddr_in *);
 static int xdr_dir(XDR *, char *);
 static int xdr_explist(XDR *, caddr_t);
 static int xdr_fhs(XDR *, caddr_t);
@@ -242,7 +255,7 @@ static const int ninumeric = NI_NUMERICH
 #define OP_NORESMNT	0x100
 #define OP_MASKLEN	0x200
 
-static int  debug = 0;
+static int  debug = DEBUGGING;
 #if 0
 static void SYSLOG(int, const char *,...);
 #endif
@@ -253,6 +266,82 @@ static void SYSLOG(int, const char *,...
  */
 static int noprivports;
 
+#ifdef MOUNTD_RUMP
+#define C2FD(_c_) ((int)(uintptr_t)(_c_))
+static int
+rumpread(void *cookie, char *buf, int count)
+{
+
+	return rump_sys_read(C2FD(cookie), buf, count);
+}
+
+static int
+rumpwrite(void *cookie, const char *buf, int count)
+{
+
+	return rump_sys_write(C2FD(cookie), buf, count);
+}
+
+static off_t
+rumpseek(void *cookie, off_t off, int whence)
+{
+
+	return rump_sys_lseek(C2FD(cookie), off, whence);
+}
+
+static int
+rumpclose(void *cookie)
+{
+
+	return rump_sys_close(C2FD(cookie));
+}
+
+int __sflags(const char *, int *); /* XXX */
+static FILE *
+rumpfopen(const char *path, const char *opts)
+{
+	int fd, oflags;
+
+	__sflags(opts, );
+	fd = rump_sys_open(path, oflags, 0777);
+	if (fd == -1)
+		return NULL;
+
+	return funopen((void *)(uintptr_t)fd,
+	rumpread, rumpwrite, rumpseek, rumpclose);
+}
+
+/*
+ * Make sure mountd signal handler is executed from a thread context
+ * instead of the signal handler.  This avoids the signal handler
+ * ruining our kernel context.
+ */
+static sem_t exportsem;
+static void
+signal_get_exportlist(int sig)
+{
+
+	sem_post();
+}
+
+static void *
+exportlist_thread(void *arg)
+{
+
+	for (;;) {
+		sem_wait();
+		get_exportlist(0);
+	}
+
+	return NULL;
+}
+#define statvfs1(a, b, c) rump_sys_statvfs1((a), (b), (c))
+#define getfh(a, b, c) rump_sys_getfh((a), (b), (c))
+#define nfssvc(a, b) rump_sys_nfssvc((a), (b))
+#define fopen(a, b) rumpfopen((a), (b))
+#define lstat(a, b) rump_sys_lstat((a), (b))
+#define stat(a, b) rump_sys_stat((a), (b))
+
 /*
  * Mountd server for NFS mount protocol as described in:
  * NFS: Network File System Protocol Specification, RFC1094, Appendix A
@@ -261,14 +350,19 @@ static int noprivports;
  * "-d" to enable debugging
  * and "-n" to allow nonroot mount.
  */
+void *mountd_main(void *);
+void *
+mountd_main(void *arg)
+#else
 int
 main(int argc, char **argv)
+#endif
 {
 	SVCXPRT *udptransp, *tcptransp, *udp6transp, *tcp6transp;
 	struct netconfig *udpconf, *tcpconf, *udp6conf, *tcp6conf;
 	int udpsock, tcpsock, udp6sock, tcp6sock;
-	int xcreated = 0, s;
-	int c, one = 1;
+	int xcreated = 0;
+	int one = 1;
 	int maxrec = RPC_MAXDATASIZE;
 	in_port_t forcedport = 0;
 #ifdef IPSEC
@@ -277,7 +371,8 @@ main(int argc, char **argv)
 #else
 #define ADDOPTS
 #endif
-
+#ifndef MOUNTD_RUMP
+	int s, c;
 	while ((c = getopt(argc, argv, "dNnrp:" ADDOPTS)) != -1)
 		switch (c) {
 #ifdef IPSEC
@@ -310,21 +405,34 @@ main(int argc, char **argv)
 		};
 	argc -= optind;
 	argv += optind;
-	grphead = NULL;
-	exphead = NULL;
-	mlhead = NULL;
 	if (argc == 1)
 		exname = *argv;
 	else
 		exname = 

CVS commit: src/usr.sbin/mountd

2015-08-05 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Wed Aug  5 23:23:47 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
PR/50125 - Jarle Greipsland -- Incorrect PID in /var/run/mountd.pid

Move call to pidfile() after daemon() so that correct (child) pid is
written to pidfile.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.126 src/usr.sbin/mountd/mountd.c:1.127
--- src/usr.sbin/mountd/mountd.c:1.126	Fri Apr  4 12:45:59 2014
+++ src/usr.sbin/mountd/mountd.c	Wed Aug  5 23:23:47 2015
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mountd.c  8.15 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $);
+__RCSID($NetBSD: mountd.c,v 1.127 2015/08/05 23:23:47 jnemeth Exp $);
 #endif
 #endif/* not lint */
 
@@ -336,7 +336,6 @@ main(int argc, char **argv)
 		(void)fprintf(stderr, Here we go.\n);
 	(void)signal(SIGHUP, get_exportlist);
 	(void)signal(SIGTERM, send_umntall);
-	pidfile(NULL);
 
 	rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL);
 	rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL);
@@ -463,6 +462,7 @@ main(int argc, char **argv)
 		(void)signal(SIGINT, SIG_IGN);
 		(void)signal(SIGQUIT, SIG_IGN);
 	}
+	pidfile(NULL);
 	svc_run();
 	syslog(LOG_ERR, Mountd died);
 	exit(1);



CVS commit: src/usr.sbin/mountd

2015-08-05 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Wed Aug  5 23:23:47 UTC 2015

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
PR/50125 - Jarle Greipsland -- Incorrect PID in /var/run/mountd.pid

Move call to pidfile() after daemon() so that correct (child) pid is
written to pidfile.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2014-04-04 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Apr  4 12:45:59 UTC 2014

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
When daemonizing, delay the parent exit until the daemon is ready to
provide service.  Fixes a race that is a third possible cause of
PR misc/48282, in addition to the ones in rpc.rquotad and nfsd that
were fixed earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.125 src/usr.sbin/mountd/mountd.c:1.126
--- src/usr.sbin/mountd/mountd.c:1.125	Sat Oct 19 17:16:37 2013
+++ src/usr.sbin/mountd/mountd.c	Fri Apr  4 12:45:59 2014
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.125 2013/10/19 17:16:37 christos Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)mountd.c  8.15 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: mountd.c,v 1.125 2013/10/19 17:16:37 christos Exp $);
+__RCSID($NetBSD: mountd.c,v 1.126 2014/04/04 12:45:59 gson Exp $);
 #endif
 #endif/* not lint */
 
@@ -334,11 +334,6 @@ main(int argc, char **argv)
 	get_mountlist();
 	if (debug)
 		(void)fprintf(stderr, Here we go.\n);
-	if (debug == 0) {
-		daemon(0, 0);
-		(void)signal(SIGINT, SIG_IGN);
-		(void)signal(SIGQUIT, SIG_IGN);
-	}
 	(void)signal(SIGHUP, get_exportlist);
 	(void)signal(SIGTERM, send_umntall);
 	pidfile(NULL);
@@ -463,6 +458,11 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
+	if (debug == 0) {
+		daemon(0, 0);
+		(void)signal(SIGINT, SIG_IGN);
+		(void)signal(SIGQUIT, SIG_IGN);
+	}
 	svc_run();
 	syslog(LOG_ERR, Mountd died);
 	exit(1);



CVS commit: src/usr.sbin/mountd

2014-04-04 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Apr  4 12:45:59 UTC 2014

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
When daemonizing, delay the parent exit until the daemon is ready to
provide service.  Fixes a race that is a third possible cause of
PR misc/48282, in addition to the ones in rpc.rquotad and nfsd that
were fixed earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2012-08-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Aug 26 14:50:45 UTC 2012

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
Dots as macro arguments need quoting.
Bug reported by Paul Goyette.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/exports.5
diff -u src/usr.sbin/mountd/exports.5:1.30 src/usr.sbin/mountd/exports.5:1.31
--- src/usr.sbin/mountd/exports.5:1.30	Mon Oct  9 21:36:18 2006
+++ src/usr.sbin/mountd/exports.5	Sun Aug 26 14:50:45 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: exports.5,v 1.30 2006/10/09 21:36:18 wiz Exp $
+.\	$NetBSD: exports.5,v 1.31 2012/08/26 14:50:45 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -92,7 +92,7 @@ can still access the whole filesystem vi
 wanted to, even if just one subdirectory has been mounted.
 The pathnames must not have any symbolic links in them and should not have
 any
-.Dq .
+.Dq \.
 or
 .Dq ..
 components.



CVS commit: src/usr.sbin/mountd

2012-08-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Aug 26 14:50:45 UTC 2012

Modified Files:
src/usr.sbin/mountd: exports.5

Log Message:
Dots as macro arguments need quoting.
Bug reported by Paul Goyette.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/mountd/exports.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  2 18:12:55 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mention macos/x needing -N


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.33 src/usr.sbin/mountd/mountd.8:1.34
--- src/usr.sbin/mountd/mountd.8:1.33	Wed Nov  2 14:09:43 2011
+++ src/usr.sbin/mountd/mountd.8	Wed Nov  2 14:12:54 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: mountd.8,v 1.33 2011/11/02 18:09:43 christos Exp $
+.\	$NetBSD: mountd.8,v 1.34 2011/11/02 18:12:54 christos Exp $
 .\
 .\ Copyright (c) 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -73,6 +73,7 @@ on every export.
 See
 .Xr exports 5
 for more information.
+Some operating systems (notably MacOS/X) require this option.
 .It Fl P Ar policy
 IPsec
 .Ar policy



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov  2 20:26:56 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.34 src/usr.sbin/mountd/mountd.8:1.35
--- src/usr.sbin/mountd/mountd.8:1.34	Wed Nov  2 18:12:54 2011
+++ src/usr.sbin/mountd/mountd.8	Wed Nov  2 20:26:56 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: mountd.8,v 1.34 2011/11/02 18:12:54 christos Exp $
+.\	$NetBSD: mountd.8,v 1.35 2011/11/02 20:26:56 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -81,15 +81,17 @@ string,
 as described in
 .Xr ipsec_set_policy 3 .
 Multiple IPsec policy strings may be specified by using a semicolon as
-a separator. If conflicting policy strings are found in a single line,
-the last string will take effect. If an invalid IPsec policy string is used
+a separator.
+If conflicting policy strings are found in a single line,
+the last string will take effect.
+If an invalid IPsec policy string is used
 .Nm
 logs an error message and terminates itself.
 .It Fl p Ar port
 Force
 .Nm
-to bind to the given port. If this
-option is not given,
+to bind to the given port.
+If this option is not given,
 .Nm
 may bind to every anonymous port
 (in the range 600-1023) which causes trouble when trying to use



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov  2 20:27:33 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Spelling.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.8
diff -u src/usr.sbin/mountd/mountd.8:1.35 src/usr.sbin/mountd/mountd.8:1.36
--- src/usr.sbin/mountd/mountd.8:1.35	Wed Nov  2 20:26:56 2011
+++ src/usr.sbin/mountd/mountd.8	Wed Nov  2 20:27:33 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: mountd.8,v 1.35 2011/11/02 20:26:56 wiz Exp $
+.\	$NetBSD: mountd.8,v 1.36 2011/11/02 20:27:33 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -73,7 +73,7 @@ on every export.
 See
 .Xr exports 5
 for more information.
-Some operating systems (notably MacOS/X) require this option.
+Some operating systems (notably Mac OS X) require this option.
 .It Fl P Ar policy
 IPsec
 .Ar policy



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  2 18:09:44 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8 mountd.c

Log Message:
Don't document long defunct flags


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/mountd/mountd.8
cvs rdiff -u -r1.122 -r1.123 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  2 18:12:55 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
mention macos/x needing -N


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov  2 20:26:56 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2011-11-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov  2 20:27:33 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.8

Log Message:
Spelling.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/mountd/mountd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2011-08-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Aug 30 20:00:58 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
ANSIfy. Use __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.121 src/usr.sbin/mountd/mountd.c:1.122
--- src/usr.sbin/mountd/mountd.c:1.121	Tue Aug 30 17:06:21 2011
+++ src/usr.sbin/mountd/mountd.c	Tue Aug 30 20:00:58 2011
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.121 2011/08/30 17:06:21 plunky Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.122 2011/08/30 20:00:58 joerg Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)mountd.c  8.15 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: mountd.c,v 1.121 2011/08/30 17:06:21 plunky Exp $);
+__RCSID($NetBSD: mountd.c,v 1.122 2011/08/30 20:00:58 joerg Exp $);
 #endif
 #endif/* not lint */
 
@@ -164,57 +164,57 @@
 };
 
 /* Global defs */
-static char*add_expdir __P((struct dirlist **, char *, int));
-static void add_dlist __P((struct dirlist **, struct dirlist *,
-struct grouplist *, int));
-static void add_mlist __P((char *, char *, int));
-static int check_dirpath __P((const char *, size_t, char *));
-static int check_options __P((const char *, size_t, struct dirlist *));
-static int chk_host __P((struct dirlist *, struct sockaddr *, int *, int *));
-static int del_mlist __P((char *, char *, struct sockaddr *));
-static struct dirlist *dirp_search __P((struct dirlist *, char *));
-static int do_nfssvc __P((const char *, size_t, struct exportlist *,
-struct grouplist *, int, struct uucred *, char *, int, struct statvfs *));
-static int do_opt __P((const char *, size_t, char **, char **,
-struct exportlist *, struct grouplist *, int *, int *, struct uucred *));
-static struct exportlist *ex_search __P((fsid_t *));
-static int parse_directory __P((const char *, size_t, struct grouplist *,
-int, char *, struct exportlist **, struct statvfs *));
-static int parse_host_netgroup __P((const char *, size_t, struct exportlist *,
-struct grouplist *, char *, int *, struct grouplist **));
-static struct exportlist *get_exp __P((void));
-static void free_dir __P((struct dirlist *));
-static void free_exp __P((struct exportlist *));
-static void free_grp __P((struct grouplist *));
-static void free_host __P((struct hostlist *));
-static void get_exportlist __P((int));
-static int get_host __P((const char *, size_t, const char *,
-struct grouplist *));
-static struct hostlist *get_ht __P((void));
-static void get_mountlist __P((void));
-static int get_net __P((char *, struct netmsk *, int));
-static void free_exp_grp __P((struct exportlist *, struct grouplist *));
-static struct grouplist *get_grp __P((void));
-static void hang_dirp __P((struct dirlist *, struct grouplist *,
-struct exportlist *, int));
-static void mntsrv __P((struct svc_req *, SVCXPRT *));
-static void nextfield __P((char **, char **));
-static void parsecred __P((char *, struct uucred *));
-static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
-static int scan_tree __P((struct dirlist *, struct sockaddr *));
-static void send_umntall __P((int));
-static int umntall_each __P((caddr_t, struct sockaddr_in *));
-static int xdr_dir __P((XDR *, char *));
-static int xdr_explist __P((XDR *, caddr_t));
-static int xdr_fhs __P((XDR *, caddr_t));
-static int xdr_mlist __P((XDR *, caddr_t));
-static int bitcmp __P((void *, void *, int));
-static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int));
-static int sacmp __P((struct sockaddr *, struct sockaddr *));
-static int allones __P((struct sockaddr_storage *, int));
-static int countones __P((struct sockaddr *));
-static void bind_resv_port __P((int, sa_family_t, in_port_t));
-static void no_nfs(int);
+static char*add_expdir(struct dirlist **, char *, int);
+static void add_dlist(struct dirlist **, struct dirlist *,
+struct grouplist *, int);
+static void add_mlist(char *, char *, int);
+static int check_dirpath(const char *, size_t, char *);
+static int check_options(const char *, size_t, struct dirlist *);
+static int chk_host(struct dirlist *, struct sockaddr *, int *, int *);
+static int del_mlist(char *, char *, struct sockaddr *);
+static struct dirlist *dirp_search(struct dirlist *, char *);
+static int do_nfssvc(const char *, size_t, struct exportlist *,
+struct grouplist *, int, struct uucred *, char *, int, struct statvfs *);
+static int do_opt(const char *, size_t, char **, char **,
+struct exportlist *, struct grouplist *, int *, int *, struct uucred *);
+static struct exportlist *ex_search(fsid_t *);
+static int parse_directory(const char *, size_t, struct grouplist *,
+int, char *, struct exportlist **, struct statvfs 

CVS commit: src/usr.sbin/mountd

2011-08-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Aug 30 20:00:58 UTC 2011

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
ANSIfy. Use __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/mountd

2009-10-11 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Oct 11 16:30:19 UTC 2009

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
make this compatible with bool.h.  no functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.119 src/usr.sbin/mountd/mountd.c:1.120
--- src/usr.sbin/mountd/mountd.c:1.119	Fri Apr 17 13:56:33 2009
+++ src/usr.sbin/mountd/mountd.c	Sun Oct 11 16:30:19 2009
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.119 2009/04/17 13:56:33 lukem Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.120 2009/10/11 16:30:19 pooka Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)mountd.c  8.15 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: mountd.c,v 1.119 2009/04/17 13:56:33 lukem Exp $);
+__RCSID($NetBSD: mountd.c,v 1.120 2009/10/11 16:30:19 pooka Exp $);
 #endif
 #endif/* not lint */
 
@@ -709,13 +709,13 @@
 	caddr_t cp;
 {
 	struct mountlist *mlp;
-	int true = 1;
-	int false = 0;
+	int trueval = 1;
+	int falseval = 0;
 	char *strp;
 
 	mlp = mlhead;
 	while (mlp) {
-		if (!xdr_bool(xdrsp, true))
+		if (!xdr_bool(xdrsp, trueval))
 			return (0);
 		strp = mlp-ml_host[0];
 		if (!xdr_string(xdrsp, strp, RPCMNT_NAMELEN))
@@ -725,7 +725,7 @@
 			return (0);
 		mlp = mlp-ml_next;
 	}
-	if (!xdr_bool(xdrsp, false))
+	if (!xdr_bool(xdrsp, falseval))
 		return (0);
 	return (1);
 }
@@ -739,7 +739,7 @@
 	caddr_t cp;
 {
 	struct exportlist *ep;
-	int false = 0;
+	int falseval = 0;
 	int putdef;
 	sigset_t sighup_mask;
 
@@ -757,7 +757,7 @@
 		ep = ep-ex_next;
 	}
 	(void)sigprocmask(SIG_UNBLOCK, sighup_mask, NULL);
-	if (!xdr_bool(xdrsp, false))
+	if (!xdr_bool(xdrsp, falseval))
 		return (0);
 	return (1);
 errout:
@@ -778,15 +778,15 @@
 {
 	struct grouplist *grp;
 	struct hostlist *hp;
-	int true = 1;
-	int false = 0;
+	int trueval = 1;
+	int falseval = 0;
 	int gotalldir = 0;
 	char *strp;
 
 	if (dp) {
 		if (put_exlist(dp-dp_left, xdrsp, adp, putdefp))
 			return (1);
-		if (!xdr_bool(xdrsp, true))
+		if (!xdr_bool(xdrsp, trueval))
 			return (1);
 		strp = dp-dp_dirp;
 		if (!xdr_string(xdrsp, strp, RPCMNT_PATHLEN))
@@ -801,7 +801,7 @@
 			while (hp) {
 grp = hp-ht_grp;
 if (grp-gr_type == GT_HOST) {
-	if (!xdr_bool(xdrsp, true))
+	if (!xdr_bool(xdrsp, trueval))
 		return (1);
 	strp =
 	  grp-gr_ptr.gt_addrinfo-ai_canonname;
@@ -809,7 +809,7 @@
 			RPCMNT_NAMELEN))
 		return (1);
 } else if (grp-gr_type == GT_NET) {
-	if (!xdr_bool(xdrsp, true))
+	if (!xdr_bool(xdrsp, trueval))
 		return (1);
 	strp = grp-gr_ptr.gt_net.nt_name;
 	if (!xdr_string(xdrsp, strp,
@@ -823,7 +823,7 @@
 }
 			}
 		}
-		if (!xdr_bool(xdrsp, false))
+		if (!xdr_bool(xdrsp, falseval))
 			return (1);
 		if (put_exlist(dp-dp_right, xdrsp, adp, putdefp))
 			return (1);



CVS commit: src/usr.sbin/mountd

2009-04-17 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Fri Apr 17 13:56:33 UTC 2009

Modified Files:
src/usr.sbin/mountd: mountd.c

Log Message:
Fix WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare)


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.sbin/mountd/mountd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/mountd/mountd.c
diff -u src/usr.sbin/mountd/mountd.c:1.118 src/usr.sbin/mountd/mountd.c:1.119
--- src/usr.sbin/mountd/mountd.c:1.118	Fri Aug 29 00:50:45 2008
+++ src/usr.sbin/mountd/mountd.c	Fri Apr 17 13:56:33 2009
@@ -1,4 +1,4 @@
-/* 	$NetBSD: mountd.c,v 1.118 2008/08/29 00:50:45 gmcgarry Exp $	 */
+/* 	$NetBSD: mountd.c,v 1.119 2009/04/17 13:56:33 lukem Exp $	 */
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)mountd.c  8.15 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: mountd.c,v 1.118 2008/08/29 00:50:45 gmcgarry Exp $);
+__RCSID($NetBSD: mountd.c,v 1.119 2009/04/17 13:56:33 lukem Exp $);
 #endif
 #endif/* not lint */
 
@@ -218,7 +218,7 @@
 static struct exportlist *exphead;
 static struct mountlist *mlhead;
 static struct grouplist *grphead;
-static char*exname;
+static const char *exname;
 static struct uucred def_anon = {
 	1,
 	(uid_t) -2,
@@ -489,7 +489,7 @@
 	int lookup_failed = 1;
 	struct sockaddr *saddr;
 	u_short sport;
-	charrpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN];
+	charrpcpath[RPCMNT_PATHLEN + 1], rdirpath[MAXPATHLEN];
 	longbad = EACCES;
 	int defset, hostset, ret;
 	sigset_tsighup_mask;
@@ -542,27 +542,27 @@
 		 * Get the real pathname and make sure it is a file or
 		 * directory that exists.
 		 */
-		if (realpath(rpcpath, dirpath) == 0 ||
-		stat(dirpath, stb)  0 ||
+		if (realpath(rpcpath, rdirpath) == 0 ||
+		stat(rdirpath, stb)  0 ||
 		(!S_ISDIR(stb.st_mode)  !S_ISREG(stb.st_mode)) ||
-		statvfs(dirpath, fsb)  0) {
+		statvfs(rdirpath, fsb)  0) {
 			(void)chdir(/); /* Just in case realpath doesn't */
 			if (debug)
 (void)fprintf(stderr, - stat failed on %s\n,
-dirpath);
+rdirpath);
 			if (!svc_sendreply(transp, xdr_long, (caddr_t) bad))
 syslog(LOG_ERR, Can't send reply);
 			return;
 		}
 		if (debug)
 			fprintf(stderr,
-			- dirpath: %s\n, dirpath);
+			- dirpath: %s\n, rdirpath);
 		/* Check in the exports list */
 		(void)sigprocmask(SIG_BLOCK, sighup_mask, NULL);
 		ep = ex_search(fsb.f_fsidx);
 		hostset = defset = 0;
 		if (ep  (chk_host(ep-ex_defdir, saddr, defset,
-		   hostset) || ((dp = dirp_search(ep-ex_dirl, dirpath)) 
+		   hostset) || ((dp = dirp_search(ep-ex_dirl, rdirpath)) 
 		   chk_host(dp, saddr, defset, hostset)) ||
 		   (defset  scan_tree(ep-ex_defdir, saddr) == 0 
 		   scan_tree(ep-ex_dirl, saddr) == 0))) {
@@ -582,9 +582,9 @@
 			/* Get the file handle */
 			memset(fhr.fhr_fh, 0, sizeof(fhr.fhr_fh)); /* for v2 */
 			fh_size = sizeof(fhr.fhr_fh);
-			if (getfh(dirpath, fhr.fhr_fh, fh_size)  0) {
+			if (getfh(rdirpath, fhr.fhr_fh, fh_size)  0) {
 bad = errno;
-syslog(LOG_ERR, Can't get fh for %s, dirpath);
+syslog(LOG_ERR, Can't get fh for %s, rdirpath);
 if (!svc_sendreply(transp, xdr_long,
 (char *)bad))
 	syslog(LOG_ERR, Can't send reply);
@@ -602,9 +602,9 @@
 			if (!svc_sendreply(transp, xdr_fhs, (char *) fhr))
 syslog(LOG_ERR, Can't send reply);
 			if (!lookup_failed)
-add_mlist(host, dirpath, hostset);
+add_mlist(host, rdirpath, hostset);
 			else
-add_mlist(numerichost, dirpath, hostset);
+add_mlist(numerichost, rdirpath, hostset);
 			if (debug)
 (void)fprintf(stderr, Mount successful.\n);
 		} else {
@@ -619,13 +619,13 @@
 			syslog(LOG_ERR, Can't send reply);
 		return;
 	case MOUNTPROC_UMNT:
-		if (!svc_getargs(transp, xdr_dir, dirpath)) {
+		if (!svc_getargs(transp, xdr_dir, rdirpath)) {
 			svcerr_decode(transp);
 			return;
 		}
 		if (!lookup_failed)
-			ret = del_mlist(host, dirpath, saddr);
-		ret |= del_mlist(numerichost, dirpath, saddr);
+			ret = del_mlist(host, rdirpath, saddr);
+		ret |= del_mlist(numerichost, rdirpath, saddr);
 		if (ret) {
 			svcerr_weakauth(transp);
 			return;
@@ -1460,7 +1460,7 @@
 	case AF_INET:
 		src = ((struct sockaddr_in *)s1)-sin_addr;
 		dst = ((struct sockaddr_in *)s2)-sin_addr;
-		if (bitlen  sizeof(((struct sockaddr_in *)s1)-sin_addr) * 8)
+		if (bitlen  (int)sizeof(((struct sockaddr_in *)s1)-sin_addr) * 8)
 			return 1;
 		break;
 	case AF_INET6:
@@ -1469,7 +1469,7 @@
 		if (((struct sockaddr_in6 *)s1)-sin6_scope_id !=
 		((struct sockaddr_in6 *)s2)-sin6_scope_id)
 			return 1;
-		if (bitlen  sizeof(((struct sockaddr_in6 *)s1)-sin6_addr) * 8)
+		if (bitlen  (int)sizeof(((struct sockaddr_in6 *)s1)-sin6_addr) * 8)
 			return 1;
 		break;
 	default:
@@ -2011,7 +2011,7 @@
 	int maskflg;
 {
 	struct netent *np;
-	char