Files
podman/libpod/oci_conmon_attach_freebsd.go
Doug Rabson 054d647107 libpod: Build oci_conmon_common.go and oci_conmon_attach_common on FreeBSD
This also adds FreeBSD equivalents to the functions moved to
oci_conmon*_linux.go. For openUnixSocket, we create a temporary symlink
to shorten the path to something that fits into sockaddr_un.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-08-18 08:07:30 +01:00

22 lines
533 B
Go

package libpod
import (
"net"
"os"
"path/filepath"
)
func openUnixSocket(path string) (*net.UnixConn, error) {
// socket paths can be too long to fit into a sockaddr_un so we create a shorter symlink.
tmpdir, err := os.MkdirTemp("", "podman")
if err != nil {
return nil, err
}
defer os.RemoveAll(tmpdir)
tmpsockpath := filepath.Join(tmpdir, "sock")
if err := os.Symlink(path, tmpsockpath); err != nil {
return nil, err
}
return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: tmpsockpath, Net: "unixpacket"})
}