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

Quadlet - make sure the /etc/containers/systemd/users is traversed in rootless #24815

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ygalblum
Copy link
Contributor

Does this PR introduce a user-facing change?

No

None

Resolves: #24783

… rootless

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
Copy link
Contributor

openshift-ci bot commented Dec 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2024
@ygalblum
Copy link
Contributor Author

I'm not sure how to test this. The problem is that creating folders under /etc/containers/systemd/users requires root privileges

@vrothberg
Copy link
Member

I'm not sure how to test this. The problem is that creating folders under /etc/containers/systemd/users requires root privileges

That's usually done via env vars. Could you use QUADLET_UNIT_DIRS for the tests and point it to a directory the tests control? Besides the permission issue, I wouldn't want tests writing to /etc/ if possible.

@Luap99
Copy link
Member

Luap99 commented Dec 11, 2024

QUADLET_UNIT_DIRS

I don't think this can help here, it will not trigger the code path in question here as this does not change the root.

I think for testing it may be possible to run quadlet in a container where we can have full control over all dirs or just chroot() may be enough? But it still is no clear to me how we could integrate this into the existing e2e test.

@ygalblum
Copy link
Contributor Author

Yes, @Luap99 is correct. When QUADLET_UNIT_DIRS is set, the changed code is not reached.
@edsantiago can you think of a way to test this?
The problem is that the code in question traverses directories under /etc/containers/systemd which the test code cannot change (without root permissions)

@edsantiago
Copy link
Member

Containerized e2e could be a safe way to test, but not trivial (test fixtures would need to be set up outside the test itself). And, sorry, I can't remember if we run rootless containerized.

@Luap99
Copy link
Member

Luap99 commented Dec 12, 2024

Maybe in the e2e test instead of calling quadlet on the host we can wrap it in a container like this:

podman run --rm -v /:/host:ro -v /tmp/test/:/host/etc/containers/systemd:Z  quay.io/libpod/testimage:20241011 chroot /host /usr/libexec/podman/quadlet -dryrun

Where /tmp/test is the source of the quadlet files, that seems to work and we have full control where to place the files.
And with the podman run command we can test rootless by adding --user 1000:1000 so we even have a stable uid to check the uid matching logic as well.

@ygalblum
Copy link
Contributor Author

I've tried running this containerized, but I still see issues. While I would like to explore the idea, can we still merge this PR (by skipping the new tests requirement) as it does fix a real issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quadlets in subfolders not generated
4 participants