Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151307172
D47011.id144485.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D47011.id144485.diff
View Options
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
@@ -245,7 +245,7 @@
static int makemask(struct sockaddr_storage *ssp, int bitlen);
static void mntsrv(struct svc_req *, SVCXPRT *);
static void nextfield(char **, char **);
-static void out_of_mem(void);
+static void out_of_mem(void) __dead2;
static void parsecred(char *, struct expcred *);
static int parsesec(char *, struct exportlist *);
static int put_exlist(struct dirlist *, XDR *, struct dirlist *,
@@ -3692,6 +3692,50 @@
}
groups[cr->cr_ngroups++] = group;
}
+ if (cr->cr_ngroups == 0) {
+ /*
+ * If no group has been explicitly specified, since in the end
+ * some user must pertain to at least one group, lookup
+ * "nogroup" on this host as the preferred default, else use
+ * GID_NOGROUP.
+ */
+ char *buf = NULL;
+ /* Arbitrary initial size, should cover most practical cases. */
+ size_t buf_size, next_size = 64;
+
+ for (;;) {
+ struct group *res, grp;
+ int lookup_rv;
+
+ buf = realloc(buf, next_size);
+ if (buf == NULL)
+ out_of_mem();
+ buf_size = next_size;
+ lookup_rv = getgrnam_r("nogroup", &grp, buf, buf_size,
+ &res);
+ if (lookup_rv == 0) {
+ /* "nogroup" found? */
+ if (res != NULL)
+ cr->cr_groups[0] = grp.gr_gid;
+ break;
+ }
+ /* Buffer too small? */
+ if (errno != ERANGE)
+ break;
+ next_size = buf_size >= PAGE_SIZE ?
+ buf_size + PAGE_SIZE :
+ buf_size * 2;
+ }
+ free(buf);
+
+ /*
+ * 'groups' was initialized with GID_NOGROUP in 'groups[0]' at
+ * start of this function. If looking up "nogroup" just above
+ * didn't work, that slot remains unchanged. In all cases, the
+ * first slot is now valid.
+ */
+ cr->cr_ngroups = 1;
+ }
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));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 8, 11:41 AM (1 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31079625
Default Alt Text
D47011.id144485.diff (1 KB)
Attached To
Mode
D47011: mountd(8): parsecred(): Fallback to "nogroup" or GID_NOGROUP
Attached
Detach File
Event Timeline
Log In to Comment