-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Only allow Rootless runs of Podman Machine #14706
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ashley-cui 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 |
No tests because this just disables running podman machine as root. Also, wasn't sure if it was a better idea to do this with annotations or by just copying and pasting |
I think it would be much less code if you just add it to the PersitentPreRunE function for the machine command: podman/cmd/podman/machine/machine.go Line 37 in 8e88abd
|
does it mean it crashes with any UID != UID in the VM? e.g. what happens if the UID on the local system is 1001? |
@giuseppe We create the root user and the core user in the machine by writing the UID to the ignition file. Podman machine checks your current UID on the host and sets the core user to that UID. If we were to use podman machine as root, we end up trying to create the core user and the root user with UID 0, which causes the machine not to boot. So, the root UID != core UID in order for the machine to properly boot. It shouldn't crash if user UID != core UID in the VM (I think..) |
Thanks @Luap99 ! Great idea, updated |
cmd/podman/machine/machine.go
Outdated
@@ -162,3 +164,10 @@ func closeMachineEvents(cmd *cobra.Command, _ []string) error { | |||
} | |||
return nil | |||
} | |||
|
|||
func rootlessOnly(cmd *cobra.Command, _ []string) error { | |||
if !rootless.IsRootless() || os.Getuid() == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getuid() check should not be needed sine it is already done in IsRootless()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
it makes sense. Thanks for the explanation |
System tests are angry |
Hmm, okay. Looks like putting the rootless check in |
Mhh, I don't think there is a way to avoid that. Code LGTM but you need to update the man pages. |
Updated, @containers/podman-maintainers PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to modify the machine tests in pkg/machine/e2e to make sure they only run as rootless?
@cdoern Those currently don't run in CI at all :) |
Podman Machine crashes if run as root. When creating the machine, we write the ignition so that the UID of the core user matches the UID of the user on the host. We by default, create the root user on the machine with UID 0. If the user on the host is root, the core UID and the Root UID collide, causing a the VM not to boot. [NO NEW TESTS NEEDED] Signed-off-by: Ashley Cui <[email protected]>
/lgtm |
Podman Machine crashes if run as root, as we need the UID of the core user to match the UID of the user on the host. If the user on the host is root, the core UID and the Root UID collide, causing a the VM not to boot.
[NO NEW TESTS NEEDED]
Signed-off-by: Ashley Cui [email protected]
Does this PR introduce a user-facing change?