From ad63102943d3f648b37b65f5c734b2c345a3b280 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 6 Jul 2017 22:47:16 +0200 Subject: setpriv: dump inheritable capability set The setpriv executable from util-linux also dumps out information on the different capability sets known by the kernel. By default, these are the inheritable capabilities, bounding capabilities and (not yet released) the ambient capabilities, which have been introduced with Linux 4.3. This patch introduces the ability to dump the set of inheritable capabilities. By default, setpriv(1) identifies capabilities by their human-readable name, for example 'net_admin'. For unknown capabilities, though, it does instead use the capability's value, for example 'cap_12', which is equivalent to 'net_admin'. As there is no kernel interface to retrieve capability names by their index, we have to declare these ourselves, which adds to setpriv's size. To counteract, using the human-readble name has been made configurable. The following sizes are with the 'FEATURE_SETPRIV_CAPABILITY_NAMES' enabled: function old new delta .rodata 145969 146405 +436 setpriv_main 467 842 +375 capabilities - 304 +304 And with 'FEATURE_SETPRIV_CAPABILITY_NAMES' disabled: function old new delta setpriv_main 467 838 +371 .rodata 145969 146101 +132 Signed-off-by: Patrick Steinhardt Signed-off-by: Denys Vlasenko --- util-linux/setpriv.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 147 insertions(+), 4 deletions(-) (limited to 'util-linux') diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index 8d3f25875..a509204a2 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c @@ -23,6 +23,26 @@ //config: help //config: Enables the "--dump" switch to print out the current privilege //config: state. This is helpful for diagnosing problems. +//config: +//config:config FEATURE_SETPRIV_CAPABILITIES +//config: bool "Support capabilities" +//config: default y +//config: depends on SETPRIV +//config: help +//config: Capabilities can be used to grant processes additional rights +//config: without the necessity to always execute as the root user. +//config: Enabling this option enables "--dump" to show information on +//config: capabilities. +//config: +//config:config FEATURE_SETPRIV_CAPABILITY_NAMES +//config: bool "Support capability names" +//config: default y +//config: depends on SETPRIV && FEATURE_SETPRIV_CAPABILITIES +//config: help +//config: Capabilities can be either referenced via a human-readble name, +//config: e.g. "net_admin", or using their index, e.g. "cap_12". Enabling +//config: this option allows using the human-readable names in addition to +//config: the index-based names. //applet:IF_SETPRIV(APPLET(setpriv, BB_DIR_BIN, BB_SUID_DROP)) @@ -55,6 +75,10 @@ // --selinux-label