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

Simplify apivfs_cmd() and chroot_cmd() #2255

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

DaanDeMeyer
Copy link
Contributor

We move the setpgid logic to run(), avoiding the need to pass a tools argument to chroot_cmd() and apivfs_cmd().

We also try to remove as much logic from these functions as possible. Since we can't really assume that any logic we execute during the function will still hold true in the sandbox, so it's best to delay any logic execution until we're already in the sandbox (using the --ro-bind-try options of bubblewrap).

We also rework the /etc/resolv.conf handling to simply make sure that /run/systemd/resolve exists in the chroot since if /etc/resolv.conf is a symlink it'll always be to /run/systemd/resolve/stub-resolv.conf.

@DaanDeMeyer DaanDeMeyer force-pushed the simplify branch 5 times, most recently from 61d7b23 to 478f870 Compare January 9, 2024 08:59
Copy link
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

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

since if /etc/resolv.conf is a symlink it'll always be to /run/systemd/resolve/stub-resolv.conf

I'm not entirely sure this reasoning is correct. I've found these docs saying that having /etc/resolv.conf be a symlink is also a way to opt out of networkmanager configuring it. Though I don't think it should functionally change anything compared to before.

mkosi/config.py Show resolved Hide resolved
We move the setpgid logic to run(), avoiding the need to pass a tools
argument to chroot_cmd() and apivfs_cmd().

We also try to remove as much logic from these functions as possible.
Since we can't really assume that any logic we execute during the
function will still hold true in the sandbox, so it's best to delay
any logic execution until we're already in the sandbox (using the
--ro-bind-try options of bubblewrap).

We also rework the /etc/resolv.conf handling to simply make sure that
/run/systemd/resolve exists in the chroot since if /etc/resolv.conf
points to /run it'll almost certainly be to
/run/systemd/resolv/stub-resolv.conf.
Otherwise we run into virtiofsd errors when operating on non relabeled
directories with --security-label enabled.
Otherwise tests in the sandbox will think they have access to IPC
stuff when they actually don't.

Fixes systemd#2256
@DaanDeMeyer DaanDeMeyer linked an issue Jan 9, 2024 that may be closed by this pull request
@DaanDeMeyer DaanDeMeyer merged commit 69c3789 into systemd:main Jan 9, 2024
18 checks passed
@DaanDeMeyer DaanDeMeyer deleted the simplify branch January 9, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

systemd tests fail with mkosi HEAD
2 participants