mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
switch podman image scp from depending on machinectl to just os/exec
machinectl does not propogate error messages and adds extra lines in the output, exec.Cmd is able to clear the env besides PATH and TERM, and use the given UID and GID to execute the command properly. machinectl is still used to create a user session. Ubuntu support is limited by this. Signed-off-by: cdoern <cdoern@redhat.com>
This commit is contained in:
@ -238,3 +238,18 @@ func CreateSCPCommand(cmd *exec.Cmd, command []string) *exec.Cmd {
|
||||
cmd.Stdout = os.Stdout
|
||||
return cmd
|
||||
}
|
||||
|
||||
// LoginUser starts the user process on the host so that image scp can use systemd-run
|
||||
func LoginUser(user string) (*exec.Cmd, error) {
|
||||
sleep, err := exec.LookPath("sleep")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
machinectl, err := exec.LookPath("machinectl")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd := exec.Command(machinectl, "shell", "-q", user+"@.host", sleep, "inf")
|
||||
err = cmd.Start()
|
||||
return cmd, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user