nfsuserd.c: Fix handling where pw_name/gr_name differ from lookup name

When an NSS backend returns a canonical pw_name or gr_name that differs from
the lookup name supplied by the NFSv4 upcall, nfsuserd stores the successful
mapping in the kernel cache under the canonical name instead of the requested
name.

This causes the retry lookup performed by nfsv4_strtouid() or
nfsv4_strtogid() to miss the newly inserted cache entry, resulting in the
default UID/GID being returned although the NSS lookup itself succeeded.

PR:	296753
Reviewed by:	rmacklem
Tested by:	Emanuel Helms <[email protected]>
MFC after:	2 weeks
This commit is contained in:
Emanuel Helms authored and Rick Macklem committed 2026-09-07 12:50:58 -07:00
1 parent 8ffe2419e4
commit 1771ab245c
1 file changed
+4 -2
+4 -2
View File
@@ -704,7 +704,8 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
if (pwd != NULL) { if (pwd != NULL) {
nid.nid_usertimeout = defusertimeout; nid.nid_usertimeout = defusertimeout;
nid.nid_uid = pwd->pw_uid; nid.nid_uid = pwd->pw_uid;
nid.nid_name = pwd->pw_name; /* NSS may canonicalize the name used for the lookup. */
nid.nid_name = info.name;
} else { } else {
nid.nid_usertimeout = 5; nid.nid_usertimeout = 5;
nid.nid_uid = defaultuid; nid.nid_uid = defaultuid;
@@ -737,7 +738,8 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
if (grp != NULL) { if (grp != NULL) {
nid.nid_usertimeout = defusertimeout; nid.nid_usertimeout = defusertimeout;
nid.nid_gid = grp->gr_gid; nid.nid_gid = grp->gr_gid;
nid.nid_name = grp->gr_name; /* NSS may canonicalize the name used for the lookup. */
nid.nid_name = info.name;
} else { } else {
nid.nid_usertimeout = 5; nid.nid_usertimeout = 5;
nid.nid_gid = defaultgid; nid.nid_gid = defaultgid;