git: deaa6984ada8 - stable/14 - mountd: do not warn about using class mask with -mask

From: Mike Karels <karels_at_FreeBSD.org>
Date: Tue, 12 Sep 2023 14:19:04 UTC
The branch stable/14 has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=deaa6984ada80e36aea2f16e5f7211dd0d14800c

commit deaa6984ada80e36aea2f16e5f7211dd0d14800c
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2023-09-08 14:06:42 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2023-09-12 14:18:52 +0000

    mountd: do not warn about using class mask with -mask
    
    The previous code would warn that the mask was being defaulted to
    an obsolete class mask even if -mask was present after -network.
    Import a fix from Peter Much with a little tweaking, deferring the
    warning until after all parameters are processed.
    
    PR:             263011
    Obtained from:  pmc at citilink.dinoex.sub.org
    Reviewed by:    rmacklem
    Differential Revision:  https://reviews.freebsd.org/D41774
    
    (cherry picked from commit 48514c5724cdf3338dd6d220e5deee6178d7ee48)
---
 usr.sbin/mountd/mountd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 436481bad14c..6602dbc09aa0 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -319,6 +319,7 @@ static struct pidfh *pfh = NULL;
 #define	OP_QUIET	0x100
 #define OP_MASKLEN	0x200
 #define OP_SEC		0x400
+#define OP_CLASSMASK	0x800	/* mask not specified, is Class A/B/C default */
 
 #ifdef DEBUG
 static int debug = 1;
@@ -1757,6 +1758,11 @@ get_exportlist_one(int passno)
 			nextfield(&cp, &endcp);
 			len = endcp - cp;
 		}
+		if (opt_flags & OP_CLASSMASK)
+			syslog(LOG_WARNING,
+			    "WARNING: No mask specified for %s, "
+			    "using out-of-date default",
+			    (&grp->gr_ptr.gt_net)->nt_name);
 		if (check_options(dirhead)) {
 			getexp_err(ep, tgrp, NULL);
 			goto nextline;
@@ -3393,6 +3399,7 @@ get_net(char *cp, struct netmsk *net, int maskflg)
 			goto fail;
 		bcopy(sa, &net->nt_mask, sa->sa_len);
 		opt_flags |= OP_HAVEMASK;
+		opt_flags &= ~OP_CLASSMASK;
 	} else {
 		/* The specified sockaddr is a network address. */
 		bcopy(sa, &net->nt_net, sa->sa_len);
@@ -3426,9 +3433,6 @@ get_net(char *cp, struct netmsk *net, int maskflg)
 		    (opt_flags & OP_MASK) == 0) {
 			in_addr_t addr;
 
-			syslog(LOG_WARNING,
-			    "WARNING: No mask specified for %s, "
-			    "using out-of-date default", name);
 			addr = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
 			if (IN_CLASSA(addr))
 				preflen = 8;
@@ -3443,7 +3447,7 @@ get_net(char *cp, struct netmsk *net, int maskflg)
 
 			bcopy(sa, &net->nt_mask, sa->sa_len);
 			makemask(&net->nt_mask, (int)preflen);
-			opt_flags |= OP_HAVEMASK;
+			opt_flags |= OP_HAVEMASK | OP_CLASSMASK;
 		}
 	}