]> git.ipfire.org Git - thirdparty/util-linux.git/commit
setpriv: proxy function checking whether a capability is set
authorPatrick Steinhardt <ps@pks.im>
Sat, 24 Jun 2017 14:04:31 +0000 (16:04 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Jun 2017 12:59:19 +0000 (14:59 +0200)
commit30129e2f5824b6c8f77c792c31298912678cd66f
treecc5bf2881cdbacf643b631e4bea97be660850a50
parent9e5dd89da670879c2463ae24934772032fd4ee26
setpriv: proxy function checking whether a capability is set

The loop in `print_caps` iterates over every capability, checks whether
it is set and, if so, prints out its name. Currently, the checking and
printing is rather intertwined, making it harder to extend the check
whether we own a capability.

Prepare code for the introduction of ambient capabilities by
disentangling the code checking for a capability and printing code. A
new function `has_cap` is introduced and `print_caps` will now simply
call out to it and only handle printing itself. This easily allows to
extend the capability check based on which capability set is queried.

Reviewed-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
sys-utils/setpriv.c