113 Commits

Author SHA1 Message Date
Andrew G. Morgan
8bed80f9b5 Up the release version to 2.69
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-14 19:10:04 -07:00
Andrew G. Morgan
3c7dda330b Up the release version to 2.68
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-25 17:03:17 -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
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
34b0329dc7 Up the release version to 2.67
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-02 20:10:27 -08:00
Andrew G. Morgan
70998415a8 Reviewed license information and adde SPDX ids.
Günther Noack reported some issues with automated dependency checking in

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

Perhaps these additional lines will help assist those things.

I did find a typo in pam_cap/execable.c so I've fixed that.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-10-19 19:05:11 -07:00
Andrew G. Morgan
4f96e6788d Up the release version to 2.66
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-09-24 13:37:39 -07:00
Andrew G. Morgan
a47d86dfb9 Up the release version to 2.65
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-07-17 15:33:06 -07:00
Andrew G. Morgan
38cfa2e958 Up the release version to 2.64
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-10 15:39:39 -07:00
Andrew G. Morgan
1d88048c31 Up the release version to 2.63
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-01-23 16:36:22 -08:00
Andrew G. Morgan
cc91f55960 Up the release version to 2.62
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-11 18:06:34 -08:00
Andrew G. Morgan
89b4b8021d Clean up cap package documentation for Launch.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-11 18:01:14 -08:00
Andrew G. Morgan
e458889fbd Complete launch thread exit sequence.
This should complete the fix for:

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

Simplify the code, and add a test that the kernel has confirmed that
the thread is no longer running.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-11 14:56:07 -08:00
Andrew G. Morgan
806b53d13a Take more care post launch
Lorenz Bauer found a race condition in the cap.Launcher teardown
process and reported it here:

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

This seems to significantly improve the situation. I'm going to
study the test case some more, but this is definitely part of the
solution.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-10 20:59:19 -08:00
Andrew G. Morgan
42555598bf Recognize default secbits of 0 as "HYBRID" mode.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-21 09:39:02 -08:00
Andrew G. Morgan
d63835d491 Up the release version to 2.61
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-11-20 22:20:04 -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
5306fa23ff Up the release version to 2.60
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 21:29:14 -07:00
Andrew G. Morgan
687dc0b8fe Unify the cap package tests for good *Set or *IAB types.
We had somewhat inconsistent checks before, so this should cut
down on corner cases to worry about.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 16:32:51 -07:00
Andrew G. Morgan
3d60128581 Concurrency fixes for *cap.Set atomicity.
Previously, the atomicity was not uniformly enforced.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 15:58:53 -07:00
Andrew G. Morgan
140fa8438b Bugfix for (*IAB).Fill() and improve atomicity of API.
Improve atomicity of Launcher and IAB use within the cap package.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-10-22 15:33:36 -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
9eb56596ee Up the release version to 2.59
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-26 18:20:33 -07:00
Andrew G. Morgan
f8b7549673 Update example to avoid reference to deprecated Compare function.
In 2.54 (*Set).Compare() was deprecated in favor of (*Set).Cf(),
so update the top level comment to reflect the preferred API.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-23 20:46:31 -07:00
Andrew G. Morgan
33a6686e2b More compliant cap.Differs documentation.
Deprecation has a stylized comment format as per go.dev.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-17 21:07:19 -07:00
Andrew G. Morgan
01627eae86 Up the release version to 2.58
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-17 19:35:42 -07:00
Andrew G. Morgan
e7297c1925 More standard deprecation comment for cap.Compare and cap.IABInit
Based on what I see on go.dev, there seems to be some preferred
comment style for deprecating a function. Use it to help spread
the word.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-10 16:02:28 -07:00
Andrew G. Morgan
3906730197 Up the release version to 2.57
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-09 13:57:36 -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
0f286b584e Up the release version to 2.56
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-02 20:03:32 -07:00
Andrew G. Morgan
2bfe36c999 Up the release version to 2.55
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-29 18:54:03 -07:00
Andrew G. Morgan
386af0edbc Stop installing the cap and psx packages, but do install captree.
We also add the cap.ProcRoot() API to let the user redirect to their
local /proc/ directory - in case anyone runs with an unusual setup
like that.

I've been studying the downstream package definitions and no one
it doesn't seem popular to build the Go packages. Indeed, Go folk
themselves prefer to install via modules anyway, so we're getting
with the program.

However, if folk want to build test the Go stuff as part of a package
build and run an install as well, we reward them with the 'captree'
binary.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-26 22:26:56 -07:00
Andrew G. Morgan
07cdff9ac9 Up the release version to 2.54
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-25 21:09:19 -07:00
Andrew G. Morgan
ac297b51c6 Revamp the comparison API of *Set and *IAB tuples; add IABGetPID().
Older APIs remain but are documented as deprecated. If we ever need
to release a golang version "2" version of the library, I'll drop
support for deprecated functions, but I have no intention of needing
to do that. In the mean time, the deprecated functions are wrappers
around the new functions.

New API: *Set and *IAB have .Cf() functions now. That return a
[IAB]Diff value. This value, if 0, means the compared pointers
match one another. Non-zero values can be interogated with the
([IAB]Diff).Has() functions.

Also, add an IABGetPID() function. Since the kernel provides no
syscall support for this, we have to resort to parsing the /proc/
files. Implemented mostly for parity with the syscall backed
GetPID() *Set returning API.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-22 14:32:12 -07:00
Andrew G. Morgan
797050ca7f Up the release version to 2.53
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-15 19:06:35 -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
b56ffb05b4 Add some documentation concerning the cap.FuncLauncher() behavior.
Slavi Marinov was asking about how a single webserver might use the
cap package to serve different content as a different user? So I
realized this detail wasn't obvious from the package documentation.

I also put together this example sketch:

   https://play.golang.org/p/6Hr0XW3JP6a

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-03 18:45:17 -07:00
Andrew G. Morgan
8070dfec39 Up the release version to 2.52
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-01 17:49:56 -07:00
Andrew G. Morgan
3857d17677 Up the release version to 2.51
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-06-20 16:57:57 -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
Andrew G. Morgan
1a5a67b48c Stabilize exporting capabilities into a comparable external format
A desire for this stabilization came out of a conversation with a
Google colleague, Mike Schilling.

This commit unifies the default libcap/cap (Go) behavior with libcap2
with respect to the binary output of cap.Export(). Previously,
libcap/cap.Export() could generate shorter binary values. [To restore
that behavior, set libcap/cap.MinExtFlagSize = 0.]

Looking to some point in the distant future, this also prepares libcap
to retain the same exported binary representation for capabilities
defineable today... That is, if the kernel were to extend the capability
flags to be 96 bits, but a capability of "cap_chown=ep" would not touch
any of the higher bits, an 'exported' capability in external format
should not need to change. (Setting libcap/cap.MinExtFlagSize = 0,
cap.Export() => 8 bytes for this capability set in external format.
However, libcap and libcap/cap now both default to 29 bytes. That is
libcap2 has the more significant legacy footprint.)

In all cases, libcap/cap and libcap2 were previously interoperable,
being able to import each others exported format. This remains true
[independent of the setting of libcap/cap.MinExtFlagSize].

Addresses this bug:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-06-19 13:20:41 -07:00
Andrew G. Morgan
4408d8ae5b Up the release version to 2.50
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-24 12:05:16 -07:00
Andrew G. Morgan
578b4cd7bf Add support for --suggest=phrase to capsh.
Ever wondered something like which capability allows a process
to do privileged things with a tty? Try this:

  capsh --suggest="tty"

cap_sys_tty_config (26) [/proc/self/status:CapXXX: 0x0000000004000000]

    Allows a process to manipulate tty devices:
      - configure tty devices
      - perform vhangup() of a tty

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-16 18:36:24 -07:00
Andrew G. Morgan
572b1f8099 Validate that user namespaces require CAP_SETFCAP to map UID=0.
I found this corner case privilege escalation in December 2020.
Now that it is fixed upstream and widely deployed, add a test
so we don't regress.

[If you find 'make sutotest' fails for you, you should upgrade
your kernel.]

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-16 16:15:28 -07:00
Andrew G. Morgan
1eb64332b1 More aggressive cap_test to ensure the launcher isolates context
Stress test the launcher code a little harder.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-30 18:43:42 -07:00
Andrew G. Morgan
cf6ddafe1d Add --explain=cap_foo support to capsh.
A convenience feature, so you don't have to grep the
system header, and/or wade through a man page.

This addresses:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-27 14:07:50 -07:00
Andrew G. Morgan
f38c190ceb Fix tyop in go pragma.
Report from Lorenz Bauer

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-19 19:45:14 -07:00
Andrew G. Morgan
c8a101dc9d Up the release version to 2.49
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-13 16:26:47 -08:00
Andrew G. Morgan
d1445dd1e1 Comment fixes regarding new cap.Launcher features
Thanks to Gregory Fuchedzhy for requesting the feature(s) and kicking
the tires on it.

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-10 19:45:59 -08:00