From nobody Sun Dec 08 01:51:13 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 4Y5SdY4hX9z5fqRS; Sun, 08 Dec 2024 01:51:13 +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 4Y5SdY4H24z4jmw; Sun, 8 Dec 2024 01:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733622673; 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=nHf9i8TeRQdqQgQJu6NyhNisiNhdurypXAkyH1B5P9U=; b=HdZCFN1YMvZaD7kOUg5OncMjaXYCAcIMW0/Nb72wSf/FXpTIiYNaOnFPAoncF6V12YtXXG fyKqit9WspaRfpD2v4UainpKo8rsDrlsY3q3hhr81y4/cswnqZ52wg92cfgmImsic6zjNe sYDB09lUwpK9YD77JSUM6UDjfK/aAYHsYZWqSossoZQtNkuIN9ngiamGv/keGd7Okwnu44 31N1gm3Y/miJl+x3wTuFunXYJx2hBAXR0SosrVB1iZHWqeXCd/MWgAI6xpdtuSPncWWkFd Mqimz6MQvTEuza2I6HFcfTTo9LDP70IC0/Dcv/mK+NHbO91s74aAsw74lvBQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733622673; 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=nHf9i8TeRQdqQgQJu6NyhNisiNhdurypXAkyH1B5P9U=; b=Fmr7aLfyzvF68lgbdd+eB1QdPWYR2XZXfCK0wcxUHf5eIWzxbKk7xhOpeIABwhlni33gzM /ZDUgL0nfn1gfBhjAFkAtZU6oR64cEnA3/0X7ismWjx9zyjRZ7vSovWGc0I9Lybh3PecA8 vp1rPHKKuqEBhXJJZqC86HTJFXU+aAJ+LE9niwnHfPCz77Lz8ew0opbb3z4wCqIhLnxEwK i1q443Yh3cvmzkqOE1lzDr8+ZIAk/pYfjI7QMQ13SCTC1fNeU89Qbsy9rOq2rDvZJedztj WYSMIBhcjeNSN5YdRYYE3tmCa8A29n8BENGBe/SQep6kPtNfwo9iwSZS9nJqrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733622673; a=rsa-sha256; cv=none; b=lyCloC9PuOU23U+EZ7tl2v42c+lFl7V0YhWjUs/Jm9my/RTHjbpsbubE6n1avPGeCAxgFL 348S2WhzlpUzUGI4B9DDsFvMhI9VDl4i2rMzhhYXn7amgJoD7BDgAQpez+Y++6ep7G0cv/ PxZ1lrZFuyIREL2a0N9JF8U6riB7D7Hb+sZMIMJ+6SHyyExHyLr35stgjVDQXu5k2jsU9Z /shQP980IH0LswXx/8CRhtMqKJi/2RQWJ56f/K49Ka4E3iXMuov8/jWqbcoJUP6RzU9s8p bcCsHO/QLN9CCpt1K8+h6RFo9Bz2Jux1Lt6QbR0MoerjU1wvLtyUlxgVX9yvRQ== 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 4Y5SdY3sZDzYK5; Sun, 8 Dec 2024 01:51:13 +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 4B81pD05034323; Sun, 8 Dec 2024 01:51:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B81pDq6034321; Sun, 8 Dec 2024 01:51:13 GMT (envelope-from git) Date: Sun, 8 Dec 2024 01:51:13 GMT Message-Id: <202412080151.4B81pDq6034321@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: f6245e432208 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: f6245e432208cf1dd43f31b759db64aac7590108 Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=f6245e432208cf1dd43f31b759db64aac7590108 commit f6245e432208cf1dd43f31b759db64aac7590108 Author: Rick Macklem AuthorDate: 2024-11-24 20:47:56 +0000 Commit: Rick Macklem CommitDate: 2024-12-08 01:49:55 +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 256342f146f0..ebed4a4b5905 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 **, @@ -3365,13 +3364,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'; } @@ -3592,8 +3591,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'; } @@ -3641,35 +3640,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. */