Util-Linux package development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Bernhard Voelker <mail@bernhard-voelker.de>
Cc: util-linux@vger.kernel.org, kzak@redhat.com
Subject: Re: [PATCH] setpriv: support setting unnamed capabilities
Date: Wed, 19 Jul 2017 09:42:20 +0200	[thread overview]
Message-ID: <20170719074220.GA1186@pks-xps> (raw)
In-Reply-To: <2105c6b6-3574-be3c-3f2a-e951e6d8e61d@bernhard-voelker.de>

[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]

On Wed, Jul 19, 2017 at 08:18:55AM +0200, Bernhard Voelker wrote:
> On 07/17/2017 11:14 PM, Patrick Steinhardt wrote:
> > When setting capabilities, we accept human readable names like for
> > example `sys_rawio` or `net_admin`. To do so the translation between the
> > capability name and its in-kernel index, we rely on the function
> > `capng_name_to_capability`. When the function does not know the named
> > capability, it will return an error value and we abort setting the
> > capability.
> > 
> > This relies upon the ability of libcap to know all capabilities inside
> > of the kernel. But actually, it is possible that new capabilities are
> > introduced inside of the Linux kernel which are not recognized yet by
> > the library. When dumping these unknown capabilities, libcap will simply
> > return a string like "cap_38", that is it will append the capability's
> > in-kernel index to the prefix "cap_". This may lead a user to also think
> > that "cap_38" may be passed to the switches "--inh-caps" or
> > "--ambient-caps", which is unfortunately not the case.
> > 
> > We can do better here by instead accepting strings in the form of
> > "cap_N". To do so, we can simply rely on the fact that capability
> > indices are steadily increasing and that the highest index known to the
> > kernel is stored inside of the kernel's procfs, made readily available
> > by our function `real_cap_last_cap()`. So in case libcap does not know a
> > capability name, we can simply parse the string and, if it is in the
> > correct format, check whether the detected index is between 0 and the
> > highest capability index. If so, we can treat it as a valid capability
> > string and apply it.
> 
> Thanks - would you mind to also add a sentence to the man page?
> 
> Thanks & have a nice day,
> Berny

Sure, can do this. I'll send a follow-up patch tomorrow as the
patch has already been applied.

Patrick

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-07-19  7:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 21:14 [PATCH] setpriv: support setting unnamed capabilities Patrick Steinhardt
2017-07-18 11:55 ` Karel Zak
2017-07-19  6:18 ` Bernhard Voelker
2017-07-19  7:42   ` Patrick Steinhardt [this message]
2017-07-19 21:34     ` Bernhard Voelker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170719074220.GA1186@pks-xps \
    --to=ps@pks.im \
    --cc=kzak@redhat.com \
    --cc=mail@bernhard-voelker.de \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox