/* fixed size equivalent of "kdbus_caps" */
struct kdbus_meta_caps {
u32 last_cap;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ kernel_cap_t cap_sets[4];
+#else
struct {
u32 caps[_KERNEL_CAPABILITY_U32S];
} set[4];
+#endif
};
/**
out->last_cap = CAP_LAST_CAP;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ if (parent) {
+ out->cap_sets[0] = cred->cap_inheritable;
+ out->cap_sets[1] = cred->cap_permitted;
+ out->cap_sets[2] = cred->cap_effective;
+ out->cap_sets[3] = cred->cap_bset;
+ } else if (owner) {
+ out->cap_sets[0] = CAP_EMPTY_SET;
+ out->cap_sets[1] = CAP_FULL_SET;
+ out->cap_sets[2] = CAP_FULL_SET;
+ out->cap_sets[3] = CAP_FULL_SET;
+ } else {
+ out->cap_sets[0] = CAP_EMPTY_SET;
+ out->cap_sets[1] = CAP_EMPTY_SET;
+ out->cap_sets[2] = CAP_EMPTY_SET;
+ out->cap_sets[3] = CAP_EMPTY_SET;
+ }
+
+ /* clear unused bits */
+ for (i = 0; i < 4; i++)
+ out->cap_sets[i].val &= CAP_VALID_MASK;
+#else
CAP_FOR_EACH_U32(i) {
if (parent) {
out->set[0].caps[i] = cred->cap_inheritable.cap[i];
for (i = 0; i < 4; i++)
out->set[i].caps[CAP_TO_INDEX(CAP_LAST_CAP)] &=
CAP_LAST_U32_VALID_MASK;
+#endif
}
/* This is equivalent to from_kuid_munged(), but maps INVALID_UID to itself */