diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-02-17 14:26:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 14:26:39 -0500 |
commit | 93e8c39834edd08c502d18c3d0b96948ec865a37 (patch) | |
tree | 4acd6685d8525aa0177f5f819a8d841337ed01ad /pkg/machine/qemu/claim_darwin.go | |
parent | a34f27959a6125dc3e27d962cf0ec8715c30eb3b (diff) | |
parent | d59749d64dc0d86a06b953b8fe41bb6d102b8556 (diff) | |
download | podman-93e8c39834edd08c502d18c3d0b96948ec865a37.tar.gz podman-93e8c39834edd08c502d18c3d0b96948ec865a37.tar.bz2 podman-93e8c39834edd08c502d18c3d0b96948ec865a37.zip |
Merge pull request #13255 from mheon/bump_400_final
Bump to v4.0.0 final
Diffstat (limited to 'pkg/machine/qemu/claim_darwin.go')
-rw-r--r-- | pkg/machine/qemu/claim_darwin.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/pkg/machine/qemu/claim_darwin.go b/pkg/machine/qemu/claim_darwin.go new file mode 100644 index 000000000..66aed9ad8 --- /dev/null +++ b/pkg/machine/qemu/claim_darwin.go @@ -0,0 +1,63 @@ +package qemu + +import ( + "fmt" + "io/ioutil" + "net" + "os" + "os/user" + "path/filepath" + "time" +) + +func dockerClaimSupported() bool { + return true +} + +func dockerClaimHelperInstalled() bool { + u, err := user.Current() + if err != nil { + return false + } + + labelName := fmt.Sprintf("com.github.containers.podman.helper-%s", u.Username) + fileName := filepath.Join("/Library", "LaunchDaemons", labelName+".plist") + info, err := os.Stat(fileName) + return err == nil && info.Mode().IsRegular() +} + +func claimDockerSock() bool { + u, err := user.Current() + if err != nil { + return false + } + + helperSock := fmt.Sprintf("/var/run/podman-helper-%s.socket", u.Username) + con, err := net.DialTimeout("unix", helperSock, time.Second*5) + if err != nil { + return false + } + _ = con.SetWriteDeadline(time.Now().Add(time.Second * 5)) + _, err = fmt.Fprintln(con, "GO") + if err != nil { + return false + } + _ = con.SetReadDeadline(time.Now().Add(time.Second * 5)) + read, err := ioutil.ReadAll(con) + + return err == nil && string(read) == "OK" +} + +func findClaimHelper() string { + exe, err := os.Executable() + if err != nil { + return "" + } + + exe, err = filepath.EvalSymlinks(exe) + if err != nil { + return "" + } + + return filepath.Join(filepath.Dir(exe), "podman-mac-helper") +} |