Lines 103-108
static struct sockaddr_storage fromip;
Link Here
|
103 |
static struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT; |
103 |
static struct in6_addr in6loopback = IN6ADDR_LOOPBACK_INIT; |
104 |
#endif |
104 |
#endif |
105 |
|
105 |
|
|
|
106 |
static void |
107 |
canonicalize(char *buf, size_t buflen, const char *principal) |
108 |
{ |
109 |
if (strchr(principal, '@') != NULL) { |
110 |
snprintf(buf, buflen, "%s", principal); |
111 |
} else { |
112 |
snprintf(buf, buflen, "%s@%s", principal, dnsname); |
113 |
} |
114 |
|
115 |
char *ptr = strchr(buf, '@'); |
116 |
while (*ptr != '\0') { |
117 |
*ptr = toupper(*ptr); |
118 |
ptr++; |
119 |
} |
120 |
} |
121 |
|
122 |
static void |
123 |
nametrunc(char *buf, size_t buflen, const char *principal) |
124 |
{ |
125 |
snprintf(buf, buflen, "%s", principal); |
126 |
char *ptr = strchr(buf, '@'); |
127 |
if (ptr != NULL) { |
128 |
*ptr = '\0'; |
129 |
} |
130 |
} |
131 |
|
106 |
int |
132 |
int |
107 |
main(int argc, char *argv[]) |
133 |
main(int argc, char *argv[]) |
108 |
{ |
134 |
{ |
Lines 377-384
main(int argc, char *argv[])
Link Here
|
377 |
setgrent(); |
403 |
setgrent(); |
378 |
while (i < nid.nid_usermax && (grp = getgrent())) { |
404 |
while (i < nid.nid_usermax && (grp = getgrent())) { |
379 |
nid.nid_gid = grp->gr_gid; |
405 |
nid.nid_gid = grp->gr_gid; |
380 |
nid.nid_name = grp->gr_name; |
406 |
char buf[MAXNAME]; |
381 |
nid.nid_namelen = strlen(grp->gr_name); |
407 |
canonicalize(buf, sizeof(buf), grp->gr_name); |
|
|
408 |
nid.nid_name = buf; |
409 |
nid.nid_namelen = strlen(nid.nid_name); |
382 |
nid.nid_ngroup = 0; |
410 |
nid.nid_ngroup = 0; |
383 |
nid.nid_grps = NULL; |
411 |
nid.nid_grps = NULL; |
384 |
nid.nid_flag = NFSID_ADDGID; |
412 |
nid.nid_flag = NFSID_ADDGID; |
Lines 416-423
main(int argc, char *argv[])
Link Here
|
416 |
continue; |
444 |
continue; |
417 |
check_dups[i - start_uidpos] = pwd->pw_uid; |
445 |
check_dups[i - start_uidpos] = pwd->pw_uid; |
418 |
nid.nid_uid = pwd->pw_uid; |
446 |
nid.nid_uid = pwd->pw_uid; |
419 |
nid.nid_name = pwd->pw_name; |
447 |
char buf[MAXNAME]; |
420 |
nid.nid_namelen = strlen(pwd->pw_name); |
448 |
canonicalize(buf, sizeof(buf), pwd->pw_name); |
|
|
449 |
nid.nid_name = buf; |
450 |
nid.nid_namelen = strlen(nid.nid_name); |
421 |
if (manage_gids != 0) { |
451 |
if (manage_gids != 0) { |
422 |
/* Get the group list for this user. */ |
452 |
/* Get the group list for this user. */ |
423 |
ngroup = NGROUPS; |
453 |
ngroup = NGROUPS; |
Lines 529-534
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
Link Here
|
529 |
struct sockaddr_in6 *fromsin6, *sin6; |
559 |
struct sockaddr_in6 *fromsin6, *sin6; |
530 |
char buf[INET6_ADDRSTRLEN]; |
560 |
char buf[INET6_ADDRSTRLEN]; |
531 |
#endif |
561 |
#endif |
|
|
562 |
char namebuf[MAXNAME]; |
532 |
|
563 |
|
533 |
/* |
564 |
/* |
534 |
* Only handle requests from localhost on a reserved port number. |
565 |
* Only handle requests from localhost on a reserved port number. |
Lines 617-623
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
Link Here
|
617 |
if (pwd != NULL) { |
648 |
if (pwd != NULL) { |
618 |
nid.nid_usertimeout = defusertimeout; |
649 |
nid.nid_usertimeout = defusertimeout; |
619 |
nid.nid_uid = pwd->pw_uid; |
650 |
nid.nid_uid = pwd->pw_uid; |
620 |
nid.nid_name = pwd->pw_name; |
651 |
canonicalize(namebuf, sizeof(namebuf), pwd->pw_name); |
|
|
652 |
nid.nid_name = namebuf; |
621 |
if (manage_gids != 0) { |
653 |
if (manage_gids != 0) { |
622 |
/* Get the group list for this user. */ |
654 |
/* Get the group list for this user. */ |
623 |
ngroup = NGROUPS; |
655 |
ngroup = NGROUPS; |
Lines 662-668
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
Link Here
|
662 |
if (grp != NULL) { |
694 |
if (grp != NULL) { |
663 |
nid.nid_usertimeout = defusertimeout; |
695 |
nid.nid_usertimeout = defusertimeout; |
664 |
nid.nid_gid = grp->gr_gid; |
696 |
nid.nid_gid = grp->gr_gid; |
665 |
nid.nid_name = grp->gr_name; |
697 |
canonicalize(namebuf, sizeof(namebuf), grp->gr_name); |
|
|
698 |
nid.nid_name = buf; |
666 |
} else { |
699 |
} else { |
667 |
nid.nid_usertimeout = 5; |
700 |
nid.nid_usertimeout = 5; |
668 |
nid.nid_gid = (gid_t)info.id; |
701 |
nid.nid_gid = (gid_t)info.id; |
Lines 691-702
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
Link Here
|
691 |
svcerr_decode(transp); |
724 |
svcerr_decode(transp); |
692 |
return; |
725 |
return; |
693 |
} |
726 |
} |
694 |
pwd = getpwnam(info.name); |
727 |
nametrunc(buf, sizeof(buf), info.name); |
|
|
728 |
pwd = getpwnam(buf); |
695 |
info.retval = 0; |
729 |
info.retval = 0; |
696 |
if (pwd != NULL) { |
730 |
if (pwd != NULL) { |
697 |
nid.nid_usertimeout = defusertimeout; |
731 |
nid.nid_usertimeout = defusertimeout; |
698 |
nid.nid_uid = pwd->pw_uid; |
732 |
nid.nid_uid = pwd->pw_uid; |
699 |
nid.nid_name = pwd->pw_name; |
733 |
nid.nid_name = info.name; |
700 |
} else { |
734 |
} else { |
701 |
nid.nid_usertimeout = 5; |
735 |
nid.nid_usertimeout = 5; |
702 |
nid.nid_uid = defaultuid; |
736 |
nid.nid_uid = defaultuid; |
Lines 724-735
nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
Link Here
|
724 |
svcerr_decode(transp); |
758 |
svcerr_decode(transp); |
725 |
return; |
759 |
return; |
726 |
} |
760 |
} |
727 |
grp = getgrnam(info.name); |
761 |
nametrunc(buf, sizeof(buf), info.name); |
|
|
762 |
grp = getgrnam(buf); |
728 |
info.retval = 0; |
763 |
info.retval = 0; |
729 |
if (grp != NULL) { |
764 |
if (grp != NULL) { |
730 |
nid.nid_usertimeout = defusertimeout; |
765 |
nid.nid_usertimeout = defusertimeout; |
731 |
nid.nid_gid = grp->gr_gid; |
766 |
nid.nid_gid = grp->gr_gid; |
732 |
nid.nid_name = grp->gr_name; |
767 |
nid.nid_name = info.name; |
733 |
} else { |
768 |
} else { |
734 |
nid.nid_usertimeout = 5; |
769 |
nid.nid_usertimeout = 5; |
735 |
nid.nid_gid = defaultgid; |
770 |
nid.nid_gid = defaultgid; |