Page MenuHomeFreeBSD

D47011.diff
No OneTemporary

D47011.diff

diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -264,6 +264,8 @@
static void terminate(int);
static void cp_cred(struct expcred *, struct expcred *);
+static gid_t nogroup();
+
#define EXPHASH(f) (fnv_32_buf((f), sizeof(fsid_t), 0) % exphashsize)
static struct exportlisthead *exphead = NULL;
static struct exportlisthead *oldexphead = NULL;
@@ -1587,7 +1589,7 @@
anon.cr_groups = anon.cr_smallgrps;
anon.cr_uid = UID_NOBODY;
anon.cr_ngroups = 1;
- anon.cr_groups[0] = GID_NOGROUP;
+ anon.cr_groups[0] = nogroup();
exflags = MNT_EXPORTED;
got_nondir = 0;
opt_flags = 0;
@@ -3623,7 +3625,7 @@
*/
cr->cr_groups = cr->cr_smallgrps;
cr->cr_uid = UID_NOBODY;
- cr->cr_groups[0] = GID_NOGROUP;
+ cr->cr_groups[0] = nogroup();
cr->cr_ngroups = 1;
/*
* Get the user's password table entry.
@@ -3692,6 +3694,11 @@
}
groups[cr->cr_ngroups++] = group;
}
+ if (cr->cr_ngroups == 0) {
+ /* cr->cr_groups[0] filled at start with nogroup(). */
+ cr->cr_ngroups = 1;
+ return;
+ }
if (cr->cr_ngroups > SMALLNGROUPS)
cr->cr_groups = malloc(cr->cr_ngroups * sizeof(gid_t));
memcpy(cr->cr_groups, groups, cr->cr_ngroups * sizeof(gid_t));
@@ -4077,3 +4084,19 @@
memcpy(outcr->cr_groups, incr->cr_groups, incr->cr_ngroups *
sizeof(gid_t));
}
+
+static gid_t
+nogroup()
+{
+ static gid_t nogroup = 0; /* 0 means unset. */
+
+ if (nogroup == 0) {
+ const struct group *gr = getgrnam("nogroup");
+
+ if (gr != NULL && gr->gr_gid != 0)
+ nogroup = gr->gr_gid;
+ else
+ nogroup = GID_NOGROUP;
+ }
+ return (nogroup);
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Feb 5, 7:38 PM (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15463490
Default Alt Text
D47011.diff (1 KB)

Event Timeline