diff options
author | cdoern <cdoern@redhat.com> | 2022-01-14 12:45:57 -0500 |
---|---|---|
committer | cdoern <cbdoer23@g.holycross.edu> | 2022-01-26 14:40:44 -0500 |
commit | 77cd38d40c00290873226d610fc47098232b7c7a (patch) | |
tree | 10c71b501157dfca74c8ad82ee1ad9009769bbe7 /cmd | |
parent | 09589fccfdd27478defc3e3e3827265d50fa9e33 (diff) | |
download | podman-77cd38d40c00290873226d610fc47098232b7c7a.tar.gz podman-77cd38d40c00290873226d610fc47098232b7c7a.tar.bz2 podman-77cd38d40c00290873226d610fc47098232b7c7a.zip |
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>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/images/scp.go | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/cmd/podman/images/scp.go b/cmd/podman/images/scp.go index 1481e71c7..81dcda123 100644 --- a/cmd/podman/images/scp.go +++ b/cmd/podman/images/scp.go @@ -17,7 +17,6 @@ import ( "github.com/containers/podman/v4/cmd/podman/system/connection" "github.com/containers/podman/v4/libpod/define" "github.com/containers/podman/v4/pkg/domain/entities" - "github.com/containers/podman/v4/pkg/rootless" "github.com/containers/podman/v4/utils" scpD "github.com/dtylman/scp" "github.com/pkg/errors" @@ -337,21 +336,9 @@ func GetServiceInformation(cliConnections []string, cfg *config.Config) (map[str // execPodman executes the podman save/load command given the podman binary func execPodman(podman string, command []string) error { - if rootless.IsRootless() { - cmd := exec.Command(podman) - utils.CreateSCPCommand(cmd, command[1:]) - logrus.Debug("Executing podman command") - return cmd.Run() - } - machinectl, err := exec.LookPath("machinectl") - if err != nil { - cmd := exec.Command("su", "-l", "root", "--command") - cmd = utils.CreateSCPCommand(cmd, []string{strings.Join(command, " ")}) - return cmd.Run() - } - cmd := exec.Command(machinectl, "shell", "-q", "root@.host") - cmd = utils.CreateSCPCommand(cmd, command) - logrus.Debug("Executing load command machinectl") + cmd := exec.Command(podman) + utils.CreateSCPCommand(cmd, command[1:]) + logrus.Debugf("Executing podman command: %q", cmd) return cmd.Run() } |