From nobody Sun Nov 24 20:49:02 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XxLXv092vz5dfSQ; Sun, 24 Nov 2024 20:49:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XxLXt6g02z4cJ8; Sun, 24 Nov 2024 20:49:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732481342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AuiItwxBwLlHnm+5uDIhenI385yAM+D0iANWJl6lV8Y=; b=ASynSORjY12bEPTS1o2FDq1kqSKQ9/We/qDFnMJWa/JMg/Hj+Yv3xf8kPg7540XCCJrT1Q +ZT1dFQ7DzGSJNHiXaHMV3Cx5ykybE44PAouQ4pDBzMCsBloLTbDMgGwFkamyk7TGY39T4 JIS52wDvsFslNyhAu2QY+A6ZMGBe83jE27uicHsoJX9c/ewcyvC0u7wudobQRqgytqwnUR 7KDilQHr31jNupJpuNFoSDUIwFLWraVWzLLuSHJuEvaCaT4qWe+0Tp9fl6XUbL2CPhpS/S WJe+aY+bzdkEfDANMu5OPW+2RBNdhFwDuSutl3wWajlV2G7WWh6+4rZVLwoYiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732481342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AuiItwxBwLlHnm+5uDIhenI385yAM+D0iANWJl6lV8Y=; b=tRf4+5V/DuoNjlae6MAVu/M2VlSQa/1/WjX2cFJmiR4l5e4Y1OOYCAAniqD3Z6VlhLp5f/ Ga5Bq8glplJPSgiRLUR4kcEVIJjcDB/pKztZEccM2DHOWQw6+Mz8YFz4/E4qH7QMX95gx3 ddn0lfXUuNUJQ9i80xOUX3J8ssi5Xp2CvQW8Q0x3nh+ksdKpE0kn1+Evl8pyaQt5Il6TbQ OEmys0qkemHETryFBD/3hlTGd33Euhd8X5yI4TTZb+vM9oXd+hy5Zjb9+/rmPwV/+I9RsB RDbzZrLgWCBd5G4HG8fWbTeXBihEYRpf5UL2k9Fc4igxw3hnQIXaQnz5hB4c4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732481342; a=rsa-sha256; cv=none; b=HZLKDYD7Mn4OfkJhc9MrXeNdaVzX8KThTMr6A0GD+YxfeKJGirxvqTaAwEIrXrKF4xGYZP NWcCJVWDQ8OAp6x3pP6TqPyo4Y+GdBHvCf8jTqdQRsVBOdgdSRVJ8XCG/o0ie8IpoqYO9e PK3JwVW074W8bgxVXics4lEzNKbLZ7TrN1RmvyBIqWTigZbqPnfATAbOPDrEfke1G3UXWM 7OCoieK2thLIPuNcN0qpXkOg46XoJBCFSqgsn3SFfg7E19YWdcqEXSXovCqcGh52bQDDR2 /p7a2IUKrkQn0mrxq628UDV7zUWftxi1tty/qeaBiqHl3YxBVo+sMC/zMUcpmw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XxLXt67zDz192D; Sun, 24 Nov 2024 20:49:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AOKn2Qc084230; Sun, 24 Nov 2024 20:49:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AOKn2rI084226; Sun, 24 Nov 2024 20:49:02 GMT (envelope-from git) Date: Sun, 24 Nov 2024 20:49:02 GMT Message-Id: <202411242049.4AOKn2rI084226@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 0347ddf41f42 - main - nfs_commonsubs.c: Make all upper case user domain work List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0347ddf41f4226c0351d2d1d78f09e8300ebac93 Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=0347ddf41f4226c0351d2d1d78f09e8300ebac93 commit 0347ddf41f4226c0351d2d1d78f09e8300ebac93 Author: Rick Macklem AuthorDate: 2024-11-24 20:47:56 +0000 Commit: Rick Macklem CommitDate: 2024-11-24 20:47:56 +0000 nfs_commonsubs.c: Make all upper case user domain work Without this patch, an all upper case user domain name (as specified by nfsuserd(8)) would not work. I believe this was done so that Kerberos realms were not confused with user domains. Now, RFC8881 specifies that the user domain name is a DNS name. As such, all upper case names should work. This patch fixes this case so that it works. The custom comparison function is no longer needed. PR: 282620 Tested by: jmmv MFC after: 2 weeks --- sys/fs/nfs/nfs_commonsubs.c | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 81c558d768ea..fc01630f77f9 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -225,7 +225,6 @@ static int nfs_bigreply[NFSV42_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep); static void nfsv4_wanted(struct nfsv4lock *lp); static uint32_t nfsv4_filesavail(struct statfs *, struct mount *); -static int nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len); static int nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char *name); static void nfsrv_removeuser(struct nfsusrgrp *usrp, int isuser); static int nfsrv_getrefstr(struct nfsrv_descript *, u_char **, u_char **, @@ -3438,13 +3437,13 @@ tryagain: /* * If an '@' is found and the domain name matches, search for * the name with dns stripped off. - * Mixed case alphabetics will match for the domain name, but - * all upper case will not. + * The match for alphabetics in now case insensitive, + * since RFC8881 defines this string as a DNS domain name. */ if (cnt == 0 && i < len && i > 0 && (len - 1 - i) == NFSD_VNET(nfsrv_dnsnamelen) && - !nfsrv_cmpmixedcase(cp, - NFSD_VNET(nfsrv_dnsname), NFSD_VNET(nfsrv_dnsnamelen))) { + strncasecmp(cp, NFSD_VNET(nfsrv_dnsname), + NFSD_VNET(nfsrv_dnsnamelen)) == 0) { len -= (NFSD_VNET(nfsrv_dnsnamelen) + 1); *(cp - 1) = '\0'; } @@ -3665,8 +3664,8 @@ tryagain: */ if (cnt == 0 && i < len && i > 0 && (len - 1 - i) == NFSD_VNET(nfsrv_dnsnamelen) && - !nfsrv_cmpmixedcase(cp, - NFSD_VNET(nfsrv_dnsname), NFSD_VNET(nfsrv_dnsnamelen))) { + strncasecmp(cp, NFSD_VNET(nfsrv_dnsname), + NFSD_VNET(nfsrv_dnsnamelen)) == 0) { len -= (NFSD_VNET(nfsrv_dnsnamelen) + 1); *(cp - 1) = '\0'; } @@ -3714,35 +3713,6 @@ out: return (error); } -/* - * Cmp len chars, allowing mixed case in the first argument to match lower - * case in the second, but not if the first argument is all upper case. - * Return 0 for a match, 1 otherwise. - */ -static int -nfsrv_cmpmixedcase(u_char *cp, u_char *cp2, int len) -{ - int i; - u_char tmp; - int fndlower = 0; - - for (i = 0; i < len; i++) { - if (*cp >= 'A' && *cp <= 'Z') { - tmp = *cp++ + ('a' - 'A'); - } else { - tmp = *cp++; - if (tmp >= 'a' && tmp <= 'z') - fndlower = 1; - } - if (tmp != *cp2++) - return (1); - } - if (fndlower) - return (0); - else - return (1); -} - /* * Set the port for the nfsuserd. */