From nobody Sun Dec 08 01:43:15 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 4Y5SSN0rlwz5fpp2; Sun, 08 Dec 2024 01:43:16 +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 4Y5SSN0J6Xz4hT7; Sun, 8 Dec 2024 01:43:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733622196; 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=55ZCqNI2E1kcrTKGhCfFuUc+46ORwz5g08nZgtB/7RA=; b=tYeohi2sLOMbp7xkQY4z8ypyW8/neThV3/Lw+Uy28YYFvfGhTipYSDrG4A8/eLACz4O8NX JEu8rRd6K3v6pIuv/R9stsAYtFiL5DQyY1ChIi/Z3KFSQ/qr4oNZktkIPzOsWH887YmR3X oZ4i0nGRPdQ38Hg9hG/G9Z0V/NUQN/awbrY/WIMi0HTnuNLNUMB8mjV8b0kkmxanAin8rA MccfMvUvd15EYHTIZEdJvn5ZOSA64LozvFXN0hM7MK/WObbIYSoJjXV1+j7wkVws7nRnWA ub25qa4i+f6cJHkU8Y8evVoyrurmmQhpysjzLoD/PYgPtGA4vf2x5kURjmFT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733622196; 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=55ZCqNI2E1kcrTKGhCfFuUc+46ORwz5g08nZgtB/7RA=; b=Oo717nuFLsoVdt4DKmWANUWolhcMws5PZ+KLH122ldG4Vq5oKA11XpEzbbM7sm6kOkMb6F 28KFKTpUKXaoWpC8E5OpUCzP6oApQBjKiwK6VXH+H452Za7ESiii3s+FBnnSvrSRdmfSg9 qdPaIUGF8GOLhzgJrK7IvALEJJwFKhHFo1cInS4JDqLfILm2J5ZjPCMllh4XeX7n29AH1U rbAOI4CEoqwkWF1N9iredxW6AincavtC6MHLrbF0nd4W0B3kaigwVtehA51S1LOhSXLxEh BuWqUio797cC/CBkIA5fs4nEAtyYYOHXKxBwgYoAYeZeXdY8XknT222mi4oJAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733622196; a=rsa-sha256; cv=none; b=HjOX70IY8vHruwEMW6SDy7vGZ4l0ta0sl14D/RH/Oakm9WIjkJfUUe1oWZmEFaqOvce9i0 ZBvqaq5/g1JJY4qoOvx2aCEv8m8gZraQJjuBEnkghfe+dWVBm1ge7jeoahQ7DLAXekzCXk 0+xVj8s36WY0pGRYbwvbT3swyljr4uAUF87t93Kn/dNUbSjeQfrR/qytKzivdxPONhjtkZ wb8wQ9HQArCEEajf1pzrWoAeijSj0AYf7N/chpwrmPB7YyxzUfB38w0Ht3qgiDuJjK7Ovj q+wn54y67PvYNTBa6dF12tiRqdmQVIRtz2QcDol76I0g7zAWUq1AumN/+uFpcw== 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 4Y5SSM70wHzXp6; Sun, 8 Dec 2024 01:43:15 +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 4B81hFIh019172; Sun, 8 Dec 2024 01:43:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B81hFsX019169; Sun, 8 Dec 2024 01:43:15 GMT (envelope-from git) Date: Sun, 8 Dec 2024 01:43:15 GMT Message-Id: <202412080143.4B81hFsX019169@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 7a4f370a352f - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7a4f370a352f89f00411a0e9cd7a7b8f8424be3a Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=7a4f370a352f89f00411a0e9cd7a7b8f8424be3a commit 7a4f370a352f89f00411a0e9cd7a7b8f8424be3a Author: Rick Macklem AuthorDate: 2024-11-24 20:47:56 +0000 Commit: Rick Macklem CommitDate: 2024-12-08 01:41:52 +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 (cherry picked from commit 0347ddf41f4226c0351d2d1d78f09e8300ebac93) --- 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 b83df5e21ecd..510e497bce2e 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 **, @@ -3442,13 +3441,13 @@ tryagain: /* * If an '@' is found and the domain name matches, search for * the name with dns stripped off. - * Mixed case alpahbetics 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'; } @@ -3669,8 +3668,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'; } @@ -3718,35 +3717,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. */