Skip to content

Commit 7ea4392

Browse files
kkuehlzkeszybz
authored andcommitted
basic: Fix capability_ambient_set_apply for kernels < 4.3
systemd#14133 made capability_ambient_set_apply() acquire capabilities that were explicitly asked for and drop all others. This change means the function is called even with an empty capability set, opening up a code path for users without ambient capabilities to call this function. This function will error with EINVAL out on kernels < 4.3 because PR_CAP_AMBIENT is not understood. This turns capability_ambient_set_apply() into a noop for kernels < 4.3 Fixes systemd#15225
1 parent 3e118d1 commit 7ea4392

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/basic/capability-util.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ int capability_ambient_set_apply(uint64_t set, bool also_inherit) {
107107
unsigned long i;
108108
int r;
109109

110+
/* Check that we can use PR_CAP_AMBIENT or quit early. */
111+
if (!ambient_capabilities_supported())
112+
return 0;
113+
110114
/* Add the capabilities to the ambient set. */
111115

112116
if (also_inherit) {

0 commit comments

Comments
 (0)