summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2009-06-19 17:10:35 +0000
committerbrooks <brooks@FreeBSD.org>2009-06-19 17:10:35 +0000
commitf53c1c309de799bd46cd12223b6f4966838f2e7a (patch)
tree851f3659dd95c07bf7aaf4a54cd53e83c804702d /usr.sbin
parent020220234336a0527c3a4eb5fe739a256bd31981 (diff)
downloadFreeBSD-src-f53c1c309de799bd46cd12223b6f4966838f2e7a.zip
FreeBSD-src-f53c1c309de799bd46cd12223b6f4966838f2e7a.tar.gz
Rework the credential code to support larger values of NGROUPS and
NGROUPS_MAX, eliminate ABI dependencies on them, and raise the to 1024 and 1023 respectively. (Previously they were equal, but under a close reading of POSIX, NGROUPS_MAX was defined to be too large by 1 since it is the number of supplemental groups, not total number of groups.) The bulk of the change consists of converting the struct ucred member cr_groups from a static array to a pointer. Do the equivalent in kinfo_proc. Introduce new interfaces crcopysafe() and crsetgroups() for duplicating a process credential before modifying it and for setting group lists respectively. Both interfaces take care for the details of allocating groups array. crsetgroups() takes care of truncating the group list to the current maximum (NGROUPS) if necessary. In the future, crsetgroups() may be responsible for insuring invariants such as sorting the supplemental groups to allow groupmember() to be implemented as a binary search. Because we can not change struct xucred without breaking application ABIs, we leave it alone and introduce a new XU_NGROUPS value which is always 16 and is to be used or NGRPS as appropriate for things such as NFS which need to use no more than 16 groups. When feasible, truncate the group list rather than generating an error. Minor changes: - Reduce the number of hand rolled versions of groupmember(). - Do not assign to both cr_gid and cr_groups[0]. - Modify ipfw to cache ucreds instead of part of their contents since they are immutable once referenced by more than one entity. Submitted by: Isilon Systems (initial implementation) X-MFC after: never PR: bin/113398 kern/133867
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/mount_portalfs/portald.h1
-rw-r--r--usr.sbin/mountd/mountd.c8
2 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/mount_portalfs/portald.h b/usr.sbin/mount_portalfs/portald.h
index 5bd63ed..99cd5d7 100644
--- a/usr.sbin/mount_portalfs/portald.h
+++ b/usr.sbin/mount_portalfs/portald.h
@@ -36,6 +36,7 @@
*/
#include <sys/cdefs.h>
+#include <sys/ucred.h>
#include <fs/portalfs/portal.h>
/*
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 6977b93..b6ca3cd 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -2637,7 +2637,7 @@ parsecred(namelist, cr)
char *names;
struct passwd *pw;
struct group *gr;
- gid_t groups[NGROUPS + 1];
+ gid_t groups[XU_NGROUPS + 1];
int ngroups;
cr->cr_version = XUCRED_VERSION;
@@ -2665,7 +2665,7 @@ parsecred(namelist, cr)
return;
}
cr->cr_uid = pw->pw_uid;
- ngroups = NGROUPS + 1;
+ ngroups = XU_NGROUPS + 1;
if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
syslog(LOG_ERR, "too many groups");
/*
@@ -2690,7 +2690,7 @@ parsecred(namelist, cr)
return;
}
cr->cr_ngroups = 0;
- while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS) {
+ while (names != NULL && *names != '\0' && cr->cr_ngroups < XU_NGROUPS) {
name = strsep(&names, ":");
if (isdigit(*name) || *name == '-') {
cr->cr_groups[cr->cr_ngroups++] = atoi(name);
@@ -2702,7 +2702,7 @@ parsecred(namelist, cr)
cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid;
}
}
- if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS)
+ if (names != NULL && *names != '\0' && cr->cr_ngroups == XU_NGROUPS)
syslog(LOG_ERR, "too many groups");
}
OpenPOWER on IntegriCloud