Skip to content

Commit

Permalink
Automatically execute podman-remote if vars set
Browse files Browse the repository at this point in the history
If any of PODMAN_HOST or PODMAN_VARLINK_BRIDGE are set,
then execute "podman-remote" rather than this "podman".

Also support PODMAN_VARLINK_ADDRESS for tunneling, even
though there is no encryption support in such addresses.

Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Jan 26, 2020
1 parent c28af15 commit 4d097d1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cmd/podman/main_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"log/syslog"
"os"
"os/exec"
"runtime/pprof"
"strconv"
"strings"
Expand All @@ -31,7 +32,37 @@ import (

const remote = false

func runRemote(path string, args ...string) (int, error) {
c := exec.Command(path, args...)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
waitStatus := exitError.Sys().(syscall.WaitStatus)
return waitStatus.ExitStatus(), nil
}
return 1, err
}
return 0, nil
}

func init() {
host := os.Getenv("PODMAN_HOST")
bridge := os.Getenv("PODMAN_VARLINK_BRIDGE")
address := os.Getenv("PODMAN_VARLINK_ADDRESS")
if host != "" || bridge != "" || address != "" {
program := "podman-remote"
if path, err := exec.LookPath(program); err == nil {
if rc, err := runRemote(path, os.Args[1:]...); err == nil {
os.Exit(rc)
} else {
fmt.Fprintf(os.Stderr, "Error running %s: %v\n", path, err)
}
} else {
fmt.Fprintf(os.Stderr, "Error finding %s: %v\n", program, err)
}
}
cgroupManager := define.SystemdCgroupsManager
cgroupHelp := `Cgroup manager to use ("cgroupfs"|"systemd")`
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
Expand Down

0 comments on commit 4d097d1

Please sign in to comment.