Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150095256
D34874.1791673901.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D34874.1791673901.diff
View Options
Index: lib/libsysdecode/flags.c
===================================================================
--- lib/libsysdecode/flags.c
+++ lib/libsysdecode/flags.c
@@ -1171,7 +1171,8 @@
void
sysdecode_cap_rights(FILE *fp, cap_rights_t *rightsp)
{
- struct name_table *t;
+ cap_rights_t diff, sum, zero;
+ const struct name_table *t;
int i;
bool comma;
@@ -1181,13 +1182,59 @@
return;
}
}
- comma = false;
- for (t = caprights; t->str != NULL; t++) {
+ cap_rights_init(&sum);
+ diff = *rightsp;
+ for (t = caprights, comma = false; t->str != NULL; t++) {
+ cap_rights_clear(&diff, t->val);
if (cap_rights_is_set(rightsp, t->val)) {
+ if (cap_rights_is_set(&sum, t->val)) {
+ /* Don't print redundant rights. */
+ continue;
+ }
+ cap_rights_set(&sum, t->val);
+
fprintf(fp, "%s%s", comma ? "," : "", t->str);
comma = true;
}
}
+ if (!comma)
+ fprintf(fp, "CAP_NONE");
+
+ /*
+ * Provide a breadcrumb if some of the provided rights are not included
+ * in the table, likely due to a bug in the mktables script.
+ */
+ CAP_NONE(&zero);
+ if (!cap_rights_contains(&zero, &diff))
+ fprintf(fp, ",unknown rights");
+}
+
+/*
+ * Pre-sort the set of rights, which has a partial ordering defined by the
+ * subset relation. This lets sysdecode_cap_rights() print a list of minimal
+ * length with a single pass over the "caprights" table.
+ */
+static void __attribute__((constructor))
+sysdecode_cap_rights_init(void)
+{
+ cap_rights_t tr, qr;
+ struct name_table *t, *q, tmp;
+ bool swapped;
+
+ do {
+ for (t = caprights, swapped = false; t->str != NULL; t++) {
+ cap_rights_init(&tr, t->val);
+ for (q = t + 1; q->str != NULL; q++) {
+ cap_rights_init(&qr, q->val);
+ if (cap_rights_contains(&qr, &tr)) {
+ tmp = *t;
+ *t = *q;
+ *q = tmp;
+ swapped = true;
+ }
+ }
+ }
+ } while (swapped);
}
static struct name_table cmsgtypeip[] = {
Index: lib/libsysdecode/mktables
===================================================================
--- lib/libsysdecode/mktables
+++ lib/libsysdecode/mktables
@@ -159,7 +159,7 @@
gen_table "sigcode" "SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?" "sys/signal.h"
gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/umtx.h"
gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h"
-gen_table "caprights" "CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)" "sys/capsicum.h"
+gen_table "caprights" "CAP_[A-Z_]+[[:space:]]+((CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\))|(\(CAP_[A-Z_]+[[:space:]]*\|.*\)))" "sys/capsicum.h"
gen_table "sctpprpolicy" "SCTP_PR_SCTP_[A-Z_]+[[:space:]]+0x[0-9]+" "netinet/sctp_uio.h" "SCTP_PR_SCTP_ALL"
gen_table "cmsgtypesocket" "SCM_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/socket.h"
if [ -e "${include_dir}/x86/sysarch.h" ]; then
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 10, 11:11 PM (14 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30291103
Default Alt Text
D34874.1791673901.diff (2 KB)
Attached To
Mode
D34874: libsysdecode: Fix decoding of Capsicum rights
Attached
Detach File
Event Timeline
Log In to Comment