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

Share podman sock bindings with other WSL distros #19705

Merged
merged 2 commits into from
Aug 25, 2023

Conversation

n1hility
Copy link
Member

Resolves #15190

Registers a rootless and rootful socket underneath /mnt/wsl/podman-sockets/[machine name]/ This allows podman remote clients on other Linux distributions to access podman.

This also registers the podman root socket under the wheel group, to allow for rootful linking against /var/run/docker.sock, a use case expected by some clients and APIs. While this is not recommended practice on a Linux host, a WSL guest is user-isolated and already enables escalation trivially.

Registers shared socket bindings on Windows, to allow other WSL distributions easy remote access

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 22, 2023
@n1hility
Copy link
Member Author

PTAL @containers/podman-maintainers

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Code LGTM but I have no means to test it at the moment

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

The whole disconnect between the constant and the use worries me, this is hard to follow.
What uses printf() stlye what uses the weird [USER] syntax. AT the caller it is impossible to know I would have to look this up every single time.

The me a much easier to understand approach would be to create functions that return the string, i.e. create function getBindMountUserService(dist string) string then I automatically know what argument to use.

pkg/machine/wsl/machine.go Show resolved Hide resolved
pkg/machine/wsl/machine.go Outdated Show resolved Hide resolved
pkg/machine/wsl/machine.go Outdated Show resolved Hide resolved
pkg/machine/wsl/machine.go Outdated Show resolved Hide resolved
@n1hility
Copy link
Member Author

The whole disconnect between the constant and the use worries me, this is hard to follow. What uses printf() stlye what uses the weird [USER] syntax. AT the caller it is impossible to know I would have to look this up every single time.

The me a much easier to understand approach would be to create functions that return the string, i.e. create function getBindMountUserService(dist string) string then I automatically know what argument to use.

This file is definitely due some cleanup. There was originally a very small number of constants and a very limited number of replacements, but it's grown over time to be a lot. In a future PR I want to refactor this a bit and split things up so it's easier to follow. For this PR I will improve the aspects related to this change though

@Luap99
Copy link
Member

Luap99 commented Aug 23, 2023

Yes, I am not blocking on that I am only adding these comments because it costs me time to understand/review the change because I constantly need jump around to see what arg is given, etc...
If you like to clean up this in the future this would be much appreciated.

@mheon
Copy link
Member

mheon commented Aug 23, 2023

LGTM once comments from @Luap99 are addressed

@n1hility
Copy link
Member Author

Yes, I am not blocking on that I am only adding these comments because it costs me time to understand/review the change because I constantly need jump around to see what arg is given, etc...
If you like to clean up this in the future this would be much appreciated.

Yeah agree, the code should aim to minimize review time. I did some improvements for this change, will definitely look at a more complete follow-up in the future.

@n1hility
Copy link
Member Author

It looks like the bud and centos stream failures are unrelated.

All feedback should be addressed

RemainAfterExit=true
Type=oneshot
# Ensure user services can register sockets as well
ExecStartPre=mkdir -p -m 777 /mnt/wsl/podman-sockets
Copy link
Member

Choose a reason for hiding this comment

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

is 777 realy correct? Seems way to open to me, but....

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it’s certainly an odd setup. So in this case /mnt/wsl (outside of our control is 777) since it’s a shaded space (sorta like /tmp) where all WSl distros cross (different Linux distributions, each running in a linux namespace). This subdir underneath just mirrors that permission scheme, and is also necessary since there is both a user systemd service and a root systemd service writing into the same directory.

Signed-off-by: Jason T. Greene <[email protected]>
Registers a rootless and rootful socket underneath /mnt/wsl/podman-sockets/[machine name]/
This allows podman remote clients on other Linux distributions to access podman.

This also registers the podman root socket under the wheel group, to allow for rootful
linking against /var/run/docker.sock, a use case expected by some clients and APIs.
While this is not recommended practice on a Linux host, a WSL guest is user-isolated
and already enables escalation trivially.

[NO NEW TESTS NEEDED]

Signed-off-by: Jason T. Greene <[email protected]>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: n1hility, vrothberg

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-merge-robot openshift-merge-robot merged commit be38046 into containers:main Aug 25, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Nov 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Allow to automatically set podman connection for other WSL2 instances
6 participants