Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F98756892
D46917.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
D46917.diff
View Options
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -2456,6 +2456,24 @@
groups_normalize(&cr->cr_ngroups, cr->cr_groups);
}
+/*
+ * Same as crsetgroups() but accepts an empty groups array.
+ *
+ * This function ensures that an effective GID is always present in credentials.
+ * An empty array is treated as a one-size one holding the passed effective GID
+ * fallback.
+ */
+void
+crsetgroups_empty_fallback(struct ucred *cr, int ngrp, const gid_t *groups,
+ const gid_t fallback)
+{
+ if (ngrp == 0)
+ /* Shortcut. */
+ crsetgroups_internal(cr, 1, &fallback);
+ else
+ crsetgroups(cr, ngrp, groups);
+}
+
/*
* Get login name, if available.
*/
diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h
--- a/sys/sys/ucred.h
+++ b/sys/sys/ucred.h
@@ -165,6 +165,8 @@
void cru2x(struct ucred *cr, struct xucred *xcr);
void cru2xt(struct thread *td, struct xucred *xcr);
void crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups);
+void crsetgroups_empty_fallback(struct ucred *cr, int ngrp,
+ const gid_t *groups, const gid_t fallback);
/*
* Returns whether gid designates a primary group in cred.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 5, 3:29 PM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13652573
Default Alt Text
D46917.diff (1 KB)
Attached To
Mode
D46917: cred: New crsetgroups_empty_fallback()
Attached
Detach File
Event Timeline
Log In to Comment