summaryrefslogtreecommitdiff
path: root/libpod/oci_conmon_attach_freebsd.go
blob: de00543814a6958f72bac781f9f26bb2c176f61e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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"})
}