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

repo: Add an API to init OstreeSePolicy from commit directly #2447

Merged
merged 2 commits into from
Sep 30, 2021

Conversation

cgwalters
Copy link
Member

This is part of OstreeCommitModifier, but I'm not using
that in some of the ostree-ext Rust code.

It just makes more sense as a direct policy API, where it should
have been in the first place. There's already support for
setting a policy object on a commit modifier, so that's all the
old API needs to do now.

cgwalters added a commit to cgwalters/ostree-rs-ext that referenced this pull request Sep 28, 2021
Using `--selinux-policy-from-base` is very convenient but wrong
here because it means that each derived commit also has the whole
base filesystem tree, which greatly obscures its logical content.

Instead, we get the base when we dynamically union things at the end.

As noted the API we really want here is
ostreedev/ostree#2447
but it will take a bit for ostree to release with it.
And even once it does, we need to do some other changes to switch
over to parsing the tarball directly too.
src/libostree/ostree-sepolicy.c Outdated Show resolved Hide resolved
src/libostree/ostree-sepolicy.c Outdated Show resolved Hide resolved
@cgwalters cgwalters force-pushed the sepolicy-for-commit branch 2 times, most recently from 92770f7 to 41a8d6a Compare September 29, 2021 13:38
src/libostree/ostree-sepolicy.c Outdated Show resolved Hide resolved
GCancellable *cancellable,
GError **error)
{
GLNX_AUTO_PREFIX_ERROR ("setting sepolicy from commit", error);
Copy link
Member

Choose a reason for hiding this comment

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

strjoina hack to include commit hash?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been trying to be more careful about adding checksums into error messages, because we now have several codepaths that log the checksum twice just inside ostree, and if the caller does it too the error message can become hard to read.

@cgwalters
Copy link
Member Author

Hooray for useful CI coverage, I had missed that we supported passing refs and not just commits into this API.
(I should clearly have actually tested this locally too)
Anyways, should be fixed now.

@lucab
Copy link
Member

lucab commented Sep 30, 2021

Re-surfacing a comment I made somewhere else, I think ostree_sepolicy_get_path() may become less than useful after this. Maybe a good candidate for deprecation?

src/libostree/ostree-sepolicy.c Outdated Show resolved Hide resolved
@cgwalters
Copy link
Member Author

Re-surfacing a comment I made somewhere else, I think ostree_sepolicy_get_path() may become less than useful after this.
Maybe a good candidate for deprecation?

Sure, done

cgwalters added a commit to cgwalters/ostree that referenced this pull request Sep 30, 2021
cgwalters added a commit to cgwalters/ostree-rs-ext that referenced this pull request Sep 30, 2021
Using `--selinux-policy-from-base` is very convenient but wrong
here because it means that each derived commit also has the whole
base filesystem tree, which greatly obscures its logical content.

Instead, we get the base when we dynamically union things at the end.

As noted the API we really want here is
ostreedev/ostree#2447
but it will take a bit for ostree to release with it.
And even once it does, we need to do some other changes to switch
over to parsing the tarball directly too.
GLNX_AUTO_PREFIX_ERROR ("setting sepolicy from commit", error);
g_autoptr(GFile) root = NULL;
g_autofree char *commit = NULL;
if (!ostree_repo_read_commit (repo, commit, &root, &commit, cancellable, error))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!ostree_repo_read_commit (repo, commit, &root, &commit, cancellable, error))
if (!ostree_repo_read_commit (repo, rev, &root, &commit, cancellable, error))

Copy link
Member Author

@cgwalters cgwalters Sep 30, 2021

Choose a reason for hiding this comment

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

Thanks!

This is part of `OstreeCommitModifier`, but I'm not using
that in some of the ostree-ext Rust code.

It just makes more sense as a direct policy API, where it should
have been in the first place.  There's already support for
setting a policy object on a commit modifier, so that's all the
old API needs to do now.
@cgwalters cgwalters merged commit 5bf4b1d into ostreedev:main Sep 30, 2021
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.

3 participants