Always allow app to inherit redirected fds from flatpak-run(1) #5626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Always allow app to inherit redirected fds from flatpak-run(1)
As noticed on Limit the usage of WAYLAND_SOCKET to an opt-in feature #5615, under normal circumstances, flatpak-run(1) replaces itself with the bwrap process via execve(), and does not close any fds that it might have inherited from its parent. This allows for patterns like:
However, using execve() is annoying when trying to analyze code coverage, because the coverage instrumentation does not get the opportunity to write out its data during exit, so it is possible to set FLATPAK_TEST_COVERAGE=1 to make flatpak run the app as a child process and wait for it. This puts us on the code path normally used for apps launched in the background by flatpak_installation_launch_full(), which don't inherit arbitrary fds from their parent.
Detect this situation and use a different child setup function, avoiding closing fds that we were meant to inherit.
Fixes: 88a928e "run: Avoid execve() when measuring test coverage"
test-run.sh: Assert that fd redirections pass through into the app
Before the previous commit, this would normally work, but would fail if we had FLATPAK_TEST_COVERAGE=1 in the environment.