160 Commits

Author SHA1 Message Date
Andrew G. Morgan
91e3124a29 More useful cross linking for man pages.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-19 20:17:01 -07:00
Andrew G. Morgan
087afa007d Break out description of text formats to a separate man page.
See cap_text_formats(7). This is the 2nd time this breakout has been
requested. This time by way of Carlos Rodriguez-Fernandez.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-19 20:01:48 -07:00
Andrew G. Morgan
aabdd103bb Mention CAP_MODE_HYBRID in man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-16 10:26:58 -08:00
Tianjia Zhang
d7b41e480d doc: Fix typo of cap_cap_proc
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-16 10:21:31 -08:00
Andrew G. Morgan
b017fcff26 Eliminating -wrap use.
This addresses the following bug:

   https://bugzilla.kernel.org/show_bug.cgi?id=219456

insofar as it eliminates the need for -wrap=pthread_create
linkage. Mostly, code that uses -lpsx functions can simply
link with -lpsx now. However, for legacy reasons the library
still works when linked wrapped or with the new content of
the libpsx.pc file:

   -Wl,--no-as-needed -Wl,--whole-archive -lpsx -Wl,--no-whole-archive -Wl,--as-needed -lpthread

These last options are required for getting -lcap to act at a
consistent process level and not a thread level.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-09 23:19:18 -08:00
Andrew G. Morgan
676971a20a Document current behavior of cap_iab_set_proc()
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-09-22 11:11:44 -07:00
Andrew G. Morgan
bbcfccdcc4 Setting ambient bits does not require CAP_SETPCAP.
Limit the conditions where we raise CAP_SETPCAP to set an IAB value.
There are some situations where that capability is needed, but they
are by no means a requirement for all IAB value setting.

Credit for discovering this goes to Christopher Head and reporting
it in:

  https://bugzilla.kernel.org/show_bug.cgi?id=219169

Update the man pages to better reflect use of Amibient bit setting.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-16 20:20:12 -07:00
Andrew G. Morgan
13b9ee57f9 Tidy up some of the automated formatting.
doc/mkmd.sh also has some dependencies on the format of the man
pages, so make that work again.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-05 19:00:59 -07:00
Carlos Rodriguez-Fernandez
56ee609f67 doc: document the use of * to refer to all users
Signed-off-by: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-05 18:16:48 -07:00
Carlos Rodriguez-Fernandez
caab6200d2 doc: document pam_cap and its conf
Signed-off-by: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-03 18:08:22 -07:00
Jakub Wilk
011eb766ce Fix reference formatting in the captree man page.
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-01-12 12:34:40 -08:00
Andrew G. Morgan
ac8d461a2c Make it harder to set invalid capabilities on files.
This change introduces the setcap -f argument to allow setting
of nonsense capabilities on files. But the default is to fail
when attempting to set such invalid capabilities.

This commit addresses:

  https://bugzilla.kernel.org/show_bug.cgi?id=217592

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-06-24 22:24:00 -07:00
Emanuele Torre
a4089305d9 Improve style in man page function prototypes
Use  type *id  everywhere instead of using  type * id  and  type* id
in some places. Also remove superflous spaces after commas, and closing
parentheses.

While doing this, I also fixed a C syntax mistake in an example in
cap_launch.3

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-04-10 17:23:58 -07:00
Andrew G. Morgan
8c435a6fec Some formatting fixes for the libpsx man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-18 18:02:44 -07:00
Andrew G. Morgan
e32563557b Recognize the new man page links.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-19 19:57:41 -08:00
Andrew G. Morgan
44ab72a6f9 Update documentation for all API functions.
There were a few straggler API functions in libcap and libpsx.
Also some functions that should be hidden from references outside
the library.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-19 19:43:13 -08:00
Andrew G. Morgan
27954dde34 Provide a method to import preamble and postscript for md man pages
If you have local files:

   .../libcap/doc/local-md.preamble
   .../libcap/doc/local-md.postscript

when you run .../libcap/doc/mkmd.sh these two files will be inlined
into the generated index.md file.

This addresses:

   https://bugzilla.kernel.org/show_bug.cgi?id=217007

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-06 18:01:43 -08:00
Andrew G. Morgan
10041371f4 Reviewed man pages, adding overlooked references.
This started out as addressing this bug:

   https://bugzilla.kernel.org/show_bug.cgi?id=216585

But I then made crosslink.sh to figure out what I had missed, and
fixed those bits too.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-16 17:09:11 -07:00
Andrew G. Morgan
b643699aa6 Address bad-whatis-entry issue noticed by Debian build tests
Details:

https://www.mit.edu/afs.new/sipb/project/debathena/lintian/www/tags/manpage-has-bad-whatis-entry.html

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-04 21:48:36 -07:00
Andrew G. Morgan
60ff008d95 Fix typos in the cap_from_text.3 man page.
This addresses this bug reported by Paulo Andrade (thanks!):

  https://bugzilla.kernel.org/show_bug.cgi?id=216514

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-09-22 06:54:37 -07:00
Andrew G. Morgan
eb0f1df722 Prevent 'capsh --user=xxx --' from generating a bash error.
This change adds support to capsh for the --noenv argument, which
will restore pre-libcap-2.65 behavior to capsh. The change we're
making here, however, is that capsh will now set the USER and HOME
environment variables when the command line contains --user=xxx.

The issue this addresses is described here:

  https://bugzilla.kernel.org/show_bug.cgi?id=215926

This has been annoying me for long enough, and I want to clean up
the article:

  https://sites.google.com/site/fullycapable/inheriting-privilege

to not pepper "--norc" in distracting places.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-30 16:04:47 -07:00
Andrew G. Morgan
9a95791818 Improve documentation for cap_get_pid and cap_reset_ambient.
- cap_get_pid() add detail about the function argument and return
  value when used across namespaces. Thanks to nemonemo for reporting:

    https://bugzilla.kernel.org/show_bug.cgi?id=215812

- cap_reset_ambient() had some factually incorrect content. Thanks to
  Tinker One for reporting:

    https://bugzilla.kernel.org/show_bug.cgi?id=215910

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-28 21:27:57 -07:00
Andrew G. Morgan
94250487ed More useful captree usage string and man page.
Include more detail about command line expectations
and exit status values.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-11 10:23:18 -07:00
Andrew G. Morgan
ceaa591b01 Clarify how the cap_get_pid() argument is interpreted.
Addresses:

  https://bugzilla.kernel.org/show_bug.cgi?id=215812

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-09 17:02:13 -07:00
Andrew G. Morgan
af2bf057ed Make cgo psx_syscall variant crash like runtime.AllThreadsSyscall
When a syscall that yields different return values is called from
the Go psx.Syscall*() API, we want to mirror the behavior of the
native golang runtime.AllThreadsSyscall() function.

The previous inconsistency was pointed out by Lorenz Bauer in:

  https://bugzilla.kernel.org/show_bug.cgi?id=215283#c8

[I decided to defer this change until 2.63, and not include this
in the bug-fix for 215283, on the grounds it is a slight
incompatibility in runtime behavior, and wanted to give folk an
opportunity to plan for it. This new behavior enforcement will
crash an unprepared go program.]

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-12 11:52:16 -08:00
Andrew G. Morgan
1fe7dbe984 Drop perl from the build requirements.
David Seifert at Gentoo made a request to not require perl for
the libcap build since their distribution wants to build it prior
to building perl and so requiring it requires they maintain some
extra patches.

We previously introduced the need for perl in response to some
apparent incompatibilities between various versions of sed:

https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=9494a1fab59ac0b6e4f0bfc536fa482c6d6490b6

However, it has been 13 years since that time so we're optimistic
those problems are no longer present for anyone and we've also
added a make variable abstraction in case some builder wants to
override their system default 'sed' as make BUILD_SED=... etc.

We've also done something similar with make uses of grep, egrep
and fgrep.

Finally, for make variable naming consistency, we've replaced use
of BUILD_GPERF with USE_GPERF. Since folk may be using BUILD_GPERF
in their package building scripts, we error out if it is set.
The expectation is that people will update their package defs.
(Eventually, we plan to reuse BUILD_GPERF as an alias for 'gperf'.)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-04 10:18:50 -08:00
Andrew G. Morgan
2ec5fdcdd5 Include link for cap_max_bits.3 man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-21 10:18:55 -08:00
Andrew G. Morgan
f7deb5ad45 Add some information about cap_max_bits().
This function has been defined for a while (since libcap-2.30),
but I just found it wasn't documented.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-20 16:36:44 -08:00
Andrew G. Morgan
e0582d0aee Prune the the.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-17 09:21:31 -08:00
Andrew G. Morgan
e4725c1a9e Add --quiet and cap_launch() support to capsh.
The flag --quiet causes capsh to suppress its startup check that
the linked libcap has support for all of the named capabilities
of the hosting kernel.

The cap_launch() support is via "-+" and "=+" arguments. These use
cap_launch() to fork() before exec*()ing the corresponding command
but are otherwise equivalent to "--" and "==" respectively.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 20:51:02 -07:00
Andrew G. Morgan
73194f5369 Make cap_launcher_t operations atomic.
Modify the cap_launch() behavior when chroot is set. Now, the
launcher code will force the post chroot() environment to
chdir("/").

Modify the API for many of the cap_launch_*() functions that
previously were void, to returning int (0=OK, -1=see errno).
I'm confident that this should be code backwardly compatible,
since the return values are new and prior code would have been
assuming success.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 12:10:40 -07:00
Andrew G. Morgan
5b16d336d0 Add a cap_iab_dup() function and make IAB access atomic.
Embed mutex locked operation into the IAB API. The idea being that
while libcap operates on an IAB tuple, it cannot be operated on by
a thread running in parallel. This makes IAB access thread safe (but
not reentrant).

The only potential API behavioral change is that the IAB tuple
associated with a cap_launcher_t is now locked for the duration of
its association with that launcher. This prevents a race condition
with launching and another thread changing that IAB tuple.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 11:34:53 -07:00
Andrew G. Morgan
2ffbc9d248 Implement cap_fill_flag() and cap.FillFlag() APIs.
This API avoids a complex use case that requires substantially
more code outside of libcap.

Signed-off-by: Andrew G. Morgan <agm@google.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-01 19:18:48 -07:00
Andrew G. Morgan
d07df10aaa Fix miscellaneous build and lint warnings.
Addresses the issues listed here:

   https://bugzilla.kernel.org/show_bug.cgi?id=214579

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-29 21:42:33 -07:00
Andrew G. Morgan
6643c636e8 Recognize that NULL is an invalid cap_t and cap_iab_t.
This was a regresssion introduced in libcap-2.55. Fixed in libcap-2.59.
Added a cap_launch NULL test too. Comparing against NULL would cause a
SIGSEGV against these library revisions.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-24 10:46:24 -07:00
Andrew G. Morgan
b35370f7f6 Implement --strict capsh argument.
Up to this point, capsh hides some complexity concerning raising
the CAP_SETPCAP in order to raise inheritable and drop bounding
set values. This made it harder to explain some aspects of
inheritance, and I ran into that detail writing this:

https://sites.google.com/site/fullycapable/why-didnt-that-work#h.z7rwbcazhr4r

Refactored capsh.c to clean up some buggy code, and also fix some
documentation, including reference to the --strict argument.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-07 13:14:54 -07:00
Andrew G. Morgan
8434c10a69 Be more systematic about POSIX.1e value group names
cap.Set's have Flag component Values
cap.IAB's have Vector component Values

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-07 10:47:45 -07:00
Andrew G. Morgan
967b3a0a95 Add --mode query support to capsh
This addresses the feature request:

  https://bugzilla.kernel.org/show_bug.cgi?id=214319

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-05 11:42:28 -07:00
Andrew G. Morgan
5ef14d0742 Refactor top level Makefile to reduce redundant building
Make build a bit quicker for folk that don't want to run tests.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-04 14:05:11 -07:00
Andrew G. Morgan
c54a087429 Document latest option for captree in its man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-02 20:03:09 -07:00
Andrew G. Morgan
41f065cdc9 cap_iab.3 doc fixes and cleanup
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-01 07:25:18 -07:00
Andrew G. Morgan
b9d56654de Update man pages.
Some fixes, some more efficient URLs, some more coherrent cross-references.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-29 15:43:17 -07:00
Andrew G. Morgan
b972c50c09 Add captree command line options and support process by name.
Add some features to captree. I plan to post a companion article
here:

   https://sites.google.com/site/fullycapable/captree

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-29 15:42:17 -07:00
Andrew G. Morgan
61b2fcc451 Make sudotest more robust against untestable environments
I'm setting up some testing environments and they are not all
created equal.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-28 16:50:35 -07:00
Andrew G. Morgan
4f45bcc835 Add cap_iab_{compare,get_pid} functions to libcap; --iab to getpcaps.
This brings libcap back to parity with the Go 'cap' package. We
provide a CAP_IAB_DIFFERS(result, vector) macro to evaluate the result
of cap_iab_compare().

Extend the getpcaps arguments to include --iab. This causes the utility
to explore the IAB tuple for the specified process. When used, this
outputs a text representation in a similar format to that of the
'captree' (Go) utility.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-22 21:13:56 -07:00
Samanta Navarro
e721aff543 Fix typos.
Typos found with codespell

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-14 11:03:27 -07:00
Andrew G. Morgan
e1af96aa58 Add a note about cap_launch callback function return values.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-01 16:59:33 -07:00
Andrew G. Morgan
c523294a0c Clarify some cap_launch documentation.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-07-12 21:23:47 -07:00
Andrew G. Morgan
69f7ddbb12 Provide a '--current' command line argument for capsh.
This is equivalent to 'capsh --print|fgrep Current'. I've been using
that combination a lot in the write-ups on the libcap website
(https://sites.google.com/site/fullycapable/) and so it struck me
that capsh probably should support it natively.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-07-02 19:51:51 -07:00
Andrew G. Morgan
c89405455d Add fill support for the 1e capabilities
We previously added a cap_iab_fill() etc, functions. Bring the
regular capability flag manipulation API into alignment by
adding libcap.cap_fill() and (*cap.Set).Fill().

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-06-19 13:58:36 -07:00