Commit graph

6 commits

Author SHA1 Message Date
Karel Zak
01a0a55601 lib/caputils: fix integer handling issues [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-05-18 10:26:02 +02:00
David Gibson
acb72212eb unshare: Move implementation of --keep-caps option to library function
unshare.c open codes some logic to copy the permitted capability set to the
ambient set in order to implement the --keep-caps option.  Move this logic
to lib/caputils.c so that we can reuse it in nsenter.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-03-29 13:36:15 +11:00
Karel Zak
c0f40fe5ad lib/caputils: use lib/procfs.c 2021-10-06 11:01:54 +02:00
Karel Zak
966420219c lib/caputils: split to multiple functions, add test
Let's split the code to make it possible to test separately bsearch as
well as procfs based cap_last_cap().

 $ ./test_caputils --last-by-bsearch
 last cap: 39
 $ ./test_caputils --last-by-procfs
 last cap: 39
 $ ./test_caputils --last
 last cap: 39

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-20 11:21:41 +01:00
Érico Rolim
5d95818757 lib/caputils: add fall back for last cap using prctl.
This allows the rest of the programs using cap_last_cap to trust the
value returned by it, since it will either be obtained from procfs
(straight from kernel) or with prctl.

Also checked if the file under /proc is actually mounted in a procfs.
2020-11-18 14:39:33 -03:00
James Peach
cef4decf04 unshare: add --keep-caps option
Add the --keep-caps option to unshare to preserve capabilities that
are granted when creating a new user namespace. This allows the child
process to retain privilege within the new user namespace without also
being UID 0.
2019-09-09 20:23:08 -07:00