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 /utils | |
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 'utils')
-rw-r--r-- | utils/utils.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/utils.go b/utils/utils.go index caf63c975..52586b937 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -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 +} |