mirror of
https://github.com/containers/podman.git
synced 2025-06-18 15:39:08 +08:00
Merge pull request #21266 from baude/remotenocore
Set up podman machine remote user correctly
This commit is contained in:
@ -991,7 +991,7 @@ func (m *MacMachine) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.Gvp
|
|||||||
}
|
}
|
||||||
|
|
||||||
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", m.UID)
|
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", m.UID)
|
||||||
forwardUser := "core"
|
forwardUser := m.RemoteUsername
|
||||||
|
|
||||||
if m.Rootful {
|
if m.Rootful {
|
||||||
destSock = "/run/podman/podman.sock"
|
destSock = "/run/podman/podman.sock"
|
||||||
|
@ -856,7 +856,7 @@ func (m *HyperVMachine) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.
|
|||||||
}
|
}
|
||||||
|
|
||||||
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", m.UID)
|
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", m.UID)
|
||||||
forwardUser := "core"
|
forwardUser := m.RemoteUsername
|
||||||
|
|
||||||
if m.Rootful {
|
if m.Rootful {
|
||||||
destSock = "/run/podman/podman.sock"
|
destSock = "/run/podman/podman.sock"
|
||||||
|
@ -73,6 +73,51 @@ func (ign *DynamicIgnition) Write() error {
|
|||||||
return os.WriteFile(ign.WritePath, b, 0644)
|
return os.WriteFile(ign.WritePath, b, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ign *DynamicIgnition) getUsers() []PasswdUser {
|
||||||
|
var (
|
||||||
|
users []PasswdUser
|
||||||
|
)
|
||||||
|
|
||||||
|
isCoreUser := ign.Name == DefaultIgnitionUserName
|
||||||
|
|
||||||
|
// if we are not using the 'core' user, we need to tell ignition to
|
||||||
|
// not add it
|
||||||
|
if !isCoreUser {
|
||||||
|
coreUser := PasswdUser{
|
||||||
|
Name: DefaultIgnitionUserName,
|
||||||
|
ShouldExist: BoolToPtr(false),
|
||||||
|
}
|
||||||
|
users = append(users, coreUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding the user
|
||||||
|
user := PasswdUser{
|
||||||
|
Name: ign.Name,
|
||||||
|
SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
|
||||||
|
UID: IntToPtr(ign.UID),
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are not using the core user, we need to make the user part
|
||||||
|
// of the following groups
|
||||||
|
if !isCoreUser {
|
||||||
|
user.Groups = []Group{
|
||||||
|
Group("sudo"),
|
||||||
|
Group("adm"),
|
||||||
|
Group("wheel"),
|
||||||
|
Group("systemd-journal")}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set root SSH key
|
||||||
|
root := PasswdUser{
|
||||||
|
Name: "root",
|
||||||
|
SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
|
||||||
|
}
|
||||||
|
// add them all in
|
||||||
|
users = append(users, user, root)
|
||||||
|
|
||||||
|
return users
|
||||||
|
}
|
||||||
|
|
||||||
// GenerateIgnitionConfig
|
// GenerateIgnitionConfig
|
||||||
func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
|
func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
|
||||||
if len(ign.Name) < 1 {
|
if len(ign.Name) < 1 {
|
||||||
@ -82,18 +127,7 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
|
|||||||
Version: "3.2.0",
|
Version: "3.2.0",
|
||||||
}
|
}
|
||||||
ignPassword := Passwd{
|
ignPassword := Passwd{
|
||||||
Users: []PasswdUser{
|
Users: ign.getUsers(),
|
||||||
{
|
|
||||||
Name: ign.Name,
|
|
||||||
SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
|
|
||||||
// Set the UID of the core user inside the machine
|
|
||||||
UID: IntToPtr(ign.UID),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "root",
|
|
||||||
SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ignStorage := Storage{
|
ignStorage := Storage{
|
||||||
|
@ -1127,8 +1127,8 @@ func (v *MachineVM) startHostNetworking() (string, machine.APIForwardingState, e
|
|||||||
cmd.Debug = true
|
cmd.Debug = true
|
||||||
logrus.Debug(cmd)
|
logrus.Debug(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := cmd.Cmd(binary)
|
c := cmd.Cmd(binary)
|
||||||
|
logrus.Debugf("gvproxy args: %v", c.Args)
|
||||||
if err := c.Start(); err != nil {
|
if err := c.Start(); err != nil {
|
||||||
return "", 0, fmt.Errorf("unable to execute: %q: %w", cmd.ToCmdline(), err)
|
return "", 0, fmt.Errorf("unable to execute: %q: %w", cmd.ToCmdline(), err)
|
||||||
}
|
}
|
||||||
@ -1143,7 +1143,8 @@ func (v *MachineVM) setupAPIForwarding(cmd gvproxy.GvproxyCommand) (gvproxy.Gvpr
|
|||||||
}
|
}
|
||||||
|
|
||||||
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", v.UID)
|
destSock := fmt.Sprintf("/run/user/%d/podman/podman.sock", v.UID)
|
||||||
forwardUser := "core"
|
|
||||||
|
forwardUser := v.RemoteUsername
|
||||||
|
|
||||||
if v.Rootful {
|
if v.Rootful {
|
||||||
destSock = "/run/podman/podman.sock"
|
destSock = "/run/podman/podman.sock"
|
||||||
|
Reference in New Issue
Block a user