FreeBSD Bugzilla – Attachment 255020 Details for
Bug 282620
NFSv4 user mapping not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Sample patch
patch.diff (text/plain), 3.60 KB, created by
Julio Merino,+1 347 694 0576,New York City
on 2024-11-08 04:15:30 UTC
(
hide
)
Description:
Sample patch
Filename:
MIME Type:
Creator:
Julio Merino,+1 347 694 0576,New York City
Created:
2024-11-08 04:15:30 UTC
Size:
3.60 KB
patch
obsolete
>diff --git a/usr.sbin/nfsuserd/nfsuserd.c b/usr.sbin/nfsuserd/nfsuserd.c >index 08e8c3c5e6a2..e7cce1b8f431 100644 >--- a/usr.sbin/nfsuserd/nfsuserd.c >+++ b/usr.sbin/nfsuserd/nfsuserd.c >@@ -103,6 +103,32 @@ static struct sockaddr_storage fromip; > static struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT; > #endif > >+static void >+canonicalize(char *buf, size_t buflen, const char *principal) >+{ >+ if (strchr(principal, '@') != NULL) { >+ snprintf(buf, buflen, "%s", principal); >+ } else { >+ snprintf(buf, buflen, "%s@%s", principal, dnsname); >+ } >+ >+ char *ptr = strchr(buf, '@'); >+ while (*ptr != '\0') { >+ *ptr = toupper(*ptr); >+ ptr++; >+ } >+} >+ >+static void >+nametrunc(char *buf, size_t buflen, const char *principal) >+{ >+ snprintf(buf, buflen, "%s", principal); >+ char *ptr = strchr(buf, '@'); >+ if (ptr != NULL) { >+ *ptr = '\0'; >+ } >+} >+ > int > main(int argc, char *argv[]) > { >@@ -377,8 +403,10 @@ main(int argc, char *argv[]) > setgrent(); > while (i < nid.nid_usermax && (grp = getgrent())) { > nid.nid_gid = grp->gr_gid; >- nid.nid_name = grp->gr_name; >- nid.nid_namelen = strlen(grp->gr_name); >+ char buf[MAXNAME]; >+ canonicalize(buf, sizeof(buf), grp->gr_name); >+ nid.nid_name = buf; >+ nid.nid_namelen = strlen(nid.nid_name); > nid.nid_ngroup = 0; > nid.nid_grps = NULL; > nid.nid_flag = NFSID_ADDGID; >@@ -416,8 +444,10 @@ main(int argc, char *argv[]) > continue; > check_dups[i - start_uidpos] = pwd->pw_uid; > nid.nid_uid = pwd->pw_uid; >- nid.nid_name = pwd->pw_name; >- nid.nid_namelen = strlen(pwd->pw_name); >+ char buf[MAXNAME]; >+ canonicalize(buf, sizeof(buf), pwd->pw_name); >+ nid.nid_name = buf; >+ nid.nid_namelen = strlen(nid.nid_name); > if (manage_gids != 0) { > /* Get the group list for this user. */ > ngroup = NGROUPS; >@@ -529,6 +559,7 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) > struct sockaddr_in6 *fromsin6, *sin6; > char buf[INET6_ADDRSTRLEN]; > #endif >+ char namebuf[MAXNAME]; > > /* > * Only handle requests from localhost on a reserved port number. >@@ -617,7 +648,8 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) > if (pwd != NULL) { > nid.nid_usertimeout = defusertimeout; > nid.nid_uid = pwd->pw_uid; >- nid.nid_name = pwd->pw_name; >+ canonicalize(namebuf, sizeof(namebuf), pwd->pw_name); >+ nid.nid_name = namebuf; > if (manage_gids != 0) { > /* Get the group list for this user. */ > ngroup = NGROUPS; >@@ -662,7 +694,8 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) > if (grp != NULL) { > nid.nid_usertimeout = defusertimeout; > nid.nid_gid = grp->gr_gid; >- nid.nid_name = grp->gr_name; >+ canonicalize(namebuf, sizeof(namebuf), grp->gr_name); >+ nid.nid_name = buf; > } else { > nid.nid_usertimeout = 5; > nid.nid_gid = (gid_t)info.id; >@@ -691,12 +724,13 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) > svcerr_decode(transp); > return; > } >- pwd = getpwnam(info.name); >+ nametrunc(buf, sizeof(buf), info.name); >+ pwd = getpwnam(buf); > info.retval = 0; > if (pwd != NULL) { > nid.nid_usertimeout = defusertimeout; > nid.nid_uid = pwd->pw_uid; >- nid.nid_name = pwd->pw_name; >+ nid.nid_name = info.name; > } else { > nid.nid_usertimeout = 5; > nid.nid_uid = defaultuid; >@@ -724,12 +758,13 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) > svcerr_decode(transp); > return; > } >- grp = getgrnam(info.name); >+ nametrunc(buf, sizeof(buf), info.name); >+ grp = getgrnam(buf); > info.retval = 0; > if (grp != NULL) { > nid.nid_usertimeout = defusertimeout; > nid.nid_gid = grp->gr_gid; >- nid.nid_name = grp->gr_name; >+ nid.nid_name = info.name; > } else { > nid.nid_usertimeout = 5; > nid.nid_gid = defaultgid;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 282620
: 255020 |
255038