mirror of https://github.com/containers/podman.git
libpod: Move openUnixSocket to oci_conmon_attach_linux.go
This function depends on linux-specific functionality in /proc/fd to allow connecting to local domain sockets with pathnames too long for sockaddr_un. [NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
parent
d43fac20f3
commit
cb4158889e
|
@ -29,15 +29,6 @@ const (
|
||||||
AttachPipeStderr = 3
|
AttachPipeStderr = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
func openUnixSocket(path string) (*net.UnixConn, error) {
|
|
||||||
fd, err := unix.Open(path, unix.O_PATH, 0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer unix.Close(fd)
|
|
||||||
return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach to the given container.
|
// Attach to the given container.
|
||||||
// Does not check if state is appropriate.
|
// Does not check if state is appropriate.
|
||||||
// started is only required if startContainer is true.
|
// started is only required if startContainer is true.
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package libpod
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func openUnixSocket(path string) (*net.UnixConn, error) {
|
||||||
|
fd, err := unix.Open(path, unix.O_PATH, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer unix.Close(fd)
|
||||||
|
return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"})
|
||||||
|
}
|
Loading…
Reference in New Issue