summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDoug Rabson <dfr@rabson.org>2022-08-17 11:18:15 +0100
committerDoug Rabson <dfr@rabson.org>2022-08-18 08:05:42 +0100
commitcb4158889e7a115b4d8bb77c76cc99032d5e8363 (patch)
tree497174468a41e25962341aa3c28ee6f37a582677 /libpod
parentd43fac20f3025096cdfe45ae32f41886b39e4659 (diff)
downloadpodman-cb4158889e7a115b4d8bb77c76cc99032d5e8363.tar.gz
podman-cb4158889e7a115b4d8bb77c76cc99032d5e8363.tar.bz2
podman-cb4158889e7a115b4d8bb77c76cc99032d5e8363.zip
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>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/oci_conmon_attach_common.go9
-rw-r--r--libpod/oci_conmon_attach_linux.go17
2 files changed, 17 insertions, 9 deletions
diff --git a/libpod/oci_conmon_attach_common.go b/libpod/oci_conmon_attach_common.go
index aa55aa6f5..adc374503 100644
--- a/libpod/oci_conmon_attach_common.go
+++ b/libpod/oci_conmon_attach_common.go
@@ -29,15 +29,6 @@ const (
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.
// Does not check if state is appropriate.
// started is only required if startContainer is true.
diff --git a/libpod/oci_conmon_attach_linux.go b/libpod/oci_conmon_attach_linux.go
new file mode 100644
index 000000000..f1aa89d3e
--- /dev/null
+++ b/libpod/oci_conmon_attach_linux.go
@@ -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"})
+}