696 Commits

Author SHA1 Message Date
Andrew G. Morgan
c7dbcf0bc9 Up the release version to 2.71
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.71 psx/v1.2.71 sig-libcap-2.71 v1.2.71 libcap-korg-2.71 libcap-2.71
2024-10-25 22:17:54 -07:00
Andrew G. Morgan
67b8bf1476 Tidy up some white space (tab -> space)
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:01:07 -07:00
Andrew G. Morgan
d510135f8d Add a more modern signing key.
This addresses the request in:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 21:50:53 -07:00
Andrew G. Morgan
c73ae0df31 c89 compilation test fix.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-24 21:28:22 -07:00
Andrew G. Morgan
9e4b652f48 Lessen the situations where cap.SETPCAP is required for IAB setting.
Discussion and explanation of what is up here is in:

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

This gets the Go cap package to parity with the recent changes to
libcap. This change will be live in cap/v1.2.71.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-19 16:37:56 -07: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
30892a5d5b Add a test example.
First attempt to get the docs on go.dev to have ready to run examples.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-09-22 11:10:05 -07:00
Andrew G. Morgan
7d571d1336 Suppress use of -Bsymbolic-functions which otherwise breaks libpsx
Credit to Stas Sergeev for unraveling this and reporting it:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-17 09:36:33 -07:00
Pierre-Clément Tosi
651d99fdf0 libcap: Use all $(xFLAGS) when building 'empty'
Pass the flags as they might be needed by $(CC) to properly compile or
link an executable (e.g. --sysroot).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-17 08:50:55 -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
dc3b42a261 Work around a longstanding problem with glibc/fedora with segfaulting
https://sourceware.org/bugzilla/show_bug.cgi?id=26729

We can't rely on getpw/grid() functions working from static compiled binaries.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-06-22 12:28:19 -07:00
Andrew G. Morgan
d24490223f Document program exit for inconsistent system call behavior.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-06-21 07:10:53 -07:00
Andrew G. Morgan
8fe536b53f Up the release version to 2.70
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.70 psx/v1.2.70 cap/v1.2.70 v1.2.70 libcap-korg-2.70 libcap-2.70
2024-05-18 21:43:17 -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
Andrew G. Morgan
e79c7f06e1 Reformat doc text for web.go
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-02-18 07:24:19 -08:00
Jakub Wilk
17c5e89521 getpcaps: fix program name in help message
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-01-29 07:19:36 -08: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
ee20d385ef Stop using _pam_overwrite() in pam_cap.c.
It looks like the Linux-PAM folk have deprecated this macro. Compiler optimization
is hard to account for: apparently this explicit deletion is no longer
guaranteed to work. This function was marked deprecated in v1.5.3 of Linux-PAM.

I've replaced its use with memset(). I'm not convinced that that will be honored
either, but remain hopeful and prefer to leave the code explicit in its intent
without a deprecation warning messing up the build log. Should some compiler
optimize it away and it leads to an exploit of some sort, it can be revealed as
a compilation bug.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-12-22 06:37:02 -08:00
Andrew G. Morgan
6585135806 Restore c89 compaitbility for C source files.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-08-13 13:56:29 -07:00
Andrew G. Morgan
4ffb54079c Add a check for a capabability of all spaces.
Address user report of confusing behavior by adding a check to setcap
for a "<space...>" capability not meaning "-r".

Another suggestion from

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-06-24 22:47:45 -07: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
Andrew G. Morgan
8785077d6c Tidy up the overview example for the "cap" package.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-24 06:55:47 -07:00
Andrew G. Morgan
8bed80f9b5 Up the release version to 2.69
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.69 libcap-korg-2.69 cap/v1.2.69 psx/v1.2.69 v1.2.69 libcap-2.69
2023-05-14 19:10:04 -07:00
Andrew G. Morgan
6baf268986 Ignore the content of a capability.conf file if it is world-writable.
Other than the case of /dev/null, there is no situation in which pam_cap.so
should act on world writable config files.

There are legitimate local administration choices for the file being owned
by non-root users, and similarly writable by a group of trusted users. So,
we do not require any specific ownership for the file and do not check for
writable access based on owner of group membership.

Credit for finding this bug in pam_cap.so goes to X41 D-Sec GmbH
(https://x41-dsec.de/) who performed a security audit of the libcap
source code in April of 2023. The audit was sponsored by the Open
Source Technology Improvement Fund (https://ostif.org/).

Audit ref: LCAP-CR-23-101

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:56:14 -07:00
Andrew G. Morgan
917c8b5d34 There was a small memory leak in pam_cap.so when libpam returned an error.
The function pam_set_data() takes ownership of a memory pointer if
the call succeeds, but does not take that ownership if the function
fails. Previously, the failure caused no deferred capability setting and
a return code PAM_IGNORE. It continues to do that in this case, but no
longer leaks the allocated iab memory.

This bug was introduced with deferred IAB capability setting support in
libcap-2.58.

Credit for finding this bug in pam_cap.so goes to X41 D-Sec GmbH
(https://x41-dsec.de/) who performed a security audit of the libcap
source code in April of 2023. The audit was sponsored by the Open
Source Technology Improvement Fund (https://ostif.org/).

Audit ref: LCAP-CR-23-100

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:56:00 -07:00
Andrew G. Morgan
422bec25ae Large strings can confuse libcap's internal strdup code.
Avoid something subtle with really long strings: 1073741823 should
be enough for anybody. This is an improved fix over something attempted
in libcap-2.55 to address some static analysis findings.

Reviewing the library, cap_proc_root() and cap_launcher_set_chroot()
are the only two calls where the library is potentially exposed to a
user controlled string input.

Credit for finding this bug in libcap goes to Richard Weinberger of
X41 D-Sec GmbH (https://x41-dsec.de/) who performed a security audit
of the libcap source code in April of 2023. The audit was sponsored
by the Open Source Technology Improvement Fund (https://ostif.org/).

Audit ref: LCAP-CR-23-02 (CVE-2023-2603)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:49:46 -07:00
Andrew G. Morgan
bc6b36682f Correct the check of pthread_create()'s return value.
This function returns a positive number (errno) on error, so the code
wasn't previously freeing some memory in this situation.

Discussion:

  https://stackoverflow.com/a/3581020/14760867

Credit for finding this bug in libpsx goes to David Gstir of
X41 D-Sec GmbH (https://x41-dsec.de/) who performed a security
audit of the libcap source code in April of 2023. The audit
was sponsored by the Open Source Technology Improvement Fund
(https://ostif.org/).

Audit ref: LCAP-CR-23-01 (CVE-2023-2602)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:48:18 -07:00
Andrew G. Morgan
819f941bce Partially revive fully static binaries.
It looks like I broke the kdebug target build when I dropped fully
static building of capsh and friends. Discovered this, looking at
answering:

https://unix.stackexchange.com/questions/741532/launch-process-with-limited-capabilities-on-minimal-busybox-based-system

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-04-22 15:38:29 -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
3c7dda330b Up the release version to 2.68
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.68 cap/v1.2.68 libcap-korg-2.68 psx/v1.2.68 v1.2.68 libcap-2.68
2023-03-25 17:03:17 -07:00
Andrew G. Morgan
3a93d8edcf Undo hiding the wrapped function call in libpsx.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-25 16:55:20 -07:00
Andrew G. Morgan
5496a0e385 Tidy up some text explaining cap.NamedCaps.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-19 20:18:44 -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
9c084eceb2 Replace the README with a README.md
Also include the `go mod tidy` detail.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-11 18:11:47 -08: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
5c6c1fbebc Drop vendor directory and clean up extra gcc...sh file
These three files were left over, they should have been
removed in the last commit.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-11 21:15:03 -08:00
Andrew G. Morgan
7e41da1050 Simplify and refactor the bug215510 code.
This code is investigating the issue:

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

This present commit extends x86_64 (aka amd64) support to 32-bit
arm build support. It is now possible cross compile the program
for the Raspberry Pi. To do this, the code needs 'docker' to work.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-11 19:02:11 -08:00
Andrew G. Morgan
ddbaa98412 Make the compare-cap binary clean up after itself.
When run via sudo, compare-cap exits with some file capabilities
left on its binary file. This is a test binary, so that's not a
big problem, however, it does mean that a 2nd run of the program
is started with, potentially, a different initial state.

This commit fixes that exit condition and addresses:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-09 20:13:25 -08:00
Andrew G. Morgan
329b69ea64 Be more strict about what symbols are externally visible.
Increase the enforcement of the documented libcap API by marking
internal library utility functions as "hidden". This also goes
for the .so executable entry points.

This addresses this bug:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-08 19:13:45 -08:00
Andrew G. Morgan
dbb9617e6f Sigh. Fix some copy-pasta errors with psx_test.go changes.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-06 19:06:27 -08:00
Andrew G. Morgan
b6d210ee03 Add some more explicit testing to the psx_test.go code.
While we test this in many other places, we didn't test this
explicitly in the psx.go local testing before. Now we do.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-06 18:55:40 -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
cf91d35d62 Drop an unnecessary use of ", _" from captree.go
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-06 07:50:02 -08:00
Andrew G. Morgan
34b0329dc7 Up the release version to 2.67
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.67 psx/v1.2.67 cap/v1.2.67 libcap-korg-2.67 v1.2.67 libcap-2.67
2023-02-02 20:10:27 -08:00
Andrew G. Morgan
3f483219d5 Resolve a couple of compiler warnings.
Explicitly add (void) as argument lists for two function definitions:

   cap_reset_ambient(void)
   _libcap_initialize(void)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-02 20:10:06 -08:00
Andrew G. Morgan
9bdfc8609a Clean up some of the markdown text.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-30 13:52:38 -07:00
Andrew G. Morgan
6521defb40 Minor clean ups of the contrib/bug216610 code/docs
I generated  mirror on github to conveniently see the .md docs and
found a few typos.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-29 21:30:08 -07:00