[PATCH v2 7/9] setpriv: dump ambient capabilities
Patrick Steinhardt
ps at pks.im
Sun Jul 2 15:16:22 UTC 2017
On Sun, Jul 02, 2017 at 03:42:56PM +0200, Patrick Steinhardt wrote:
> As with the previous commit, this commit introduces the ability to dump
> the set of ambient capabilities.
> ---
> util-linux/setpriv.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
> index 3dc662d33..e051330c3 100644
> --- a/util-linux/setpriv.c
> +++ b/util-linux/setpriv.c
> @@ -95,6 +95,16 @@
> #define PR_GET_NO_NEW_PRIVS 39
> #endif
>
> +#ifndef PR_CAP_AMBIENT
> +#define PR_CAP_AMBIENT 47
> +#define PR_CAP_AMBIENT_IS_SET 1
> +#endif
> +
> +#if ENABLE_FEATURE_SETPRIV_CAPABILITIES
> +static cap_user_header_t cap_header;
> +static int cap_u32s;
> +#endif
> +
Just noticed that this patch introduces these variables a second
time. This is from a bogus rebase, will remove in version 3.
> enum {
> IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,)
> OPTBIT_NNP,
> @@ -263,6 +273,25 @@ static int dump(void)
> printf("[none]");
> putchar('\n');
>
> + printf("Ambient capabilities: ");
> + for (n = 0, i = 0; cap_valid(i); i++) {
> + int ret = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, (unsigned long) i, 0UL, 0UL);
> + if (ret < 0)
> + bb_simple_perror_msg_and_die("prctl: CAP_AMBIENT_IS_SET");
> +
> + if (ret) {
> + if (n)
> + putchar(',');
> + printcap(i);
> + n++;
> + }
> + }
> + if (!n && !i)
> + printf("[unsupported]");
> + else if (!n)
> + printf("[none]");
> + putchar('\n');
> +
> printf("Capability bounding set: ");
> for (n = 0, i = 0; cap_valid(i); i++) {
> int ret = prctl(PR_CAPBSET_READ, (unsigned long) i, 0UL, 0UL, 0UL);
> --
> 2.13.2
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20170702/c1435f3c/attachment.asc>
More information about the busybox
mailing list