Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a RootDirectory API #54

Merged
merged 1 commit into from
Jul 16, 2024
Merged

Add a RootDirectory API #54

merged 1 commit into from
Jul 16, 2024

Conversation

cgwalters
Copy link
Member

Right now cap-std uses RESOLVE_BENEATH, not RESOLVE_IN_ROOT which means absolute symlinks can't work.

It's really handy to use cap-std where we can; I particularly like doing so in unit tests for example.

However...we really do need to support absolute
symlinks for many cases. Add a handy RootDirectory which exposes just a read-only subset of APIs - in particular we basically just want open() (and convenience wrappers like read_to_string() on this).

For other writing cases right now, one needs to construct a regular Dir.

Note that unlike the rest of cap-std, absolutely¹ no attempt is made to handle cases where openat2 isn't accessible (non-Linux, cases where the kernel is too old, etc.)

¹ Pun not intended

@cgwalters cgwalters force-pushed the open-rooted branch 2 times, most recently from 61162a1 to 0049879 Compare July 13, 2024 15:06
cgwalters added a commit to cgwalters/ostree-rs-ext that referenced this pull request Jul 15, 2024
Use the API from coreos/cap-std-ext#54
to fix absolute symlinks for `/etc/ostree/auth.json`.

cc containers/bootc#679

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters
Copy link
Member Author

Usage in ostreedev/ostree-rs-ext#650

Copy link
Collaborator

@jeckersb jeckersb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, probably want to fix the docstring thing before publishing

src/dirext.rs Outdated Show resolved Hide resolved
tests/it/main.rs Show resolved Hide resolved
Right now cap-std uses `RESOLVE_BENEATH`, not `RESOLVE_IN_ROOT`
which means absolute symlinks can't work.

It's really handy to use cap-std where we can; I particularly
like doing so in unit tests for example.

However...we really do need to support absolute
symlinks for many cases. Add a handy `RootDirectory` which
exposes just a read-only subset of APIs - in particular
we basically just want `open()` (and convenience wrappers
like `read_to_string()` on this).

For other writing cases right now, one needs to construct
a regular `Dir`.

Note that unlike the rest of cap-std, absolutely¹ no attempt
is made to handle cases where `openat2` isn't accessible
(non-Linux, cases where the kernel is too old, etc.)

¹ Pun not intended

Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters merged commit d6b9abc into coreos:main Jul 16, 2024
6 checks passed
cgwalters added a commit to cgwalters/ostree-rs-ext that referenced this pull request Jul 16, 2024
Use the API from coreos/cap-std-ext#54
to fix absolute symlinks for `/etc/ostree/auth.json`.

cc containers/bootc#679

Signed-off-by: Colin Walters <walters@verbum.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants