summaryrefslogtreecommitdiff
path: root/libpod/container_attach.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-10-23 11:20:01 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2018-10-30 15:35:24 +0100
commitf77d846536718950575fa5206d9e3654ba140590 (patch)
treeba54d191b46aaafc30521d0f71cb55d5d055d248 /libpod/container_attach.go
parentf6e7807fa5970f328c1221c2e0c0aafe5f1c4b34 (diff)
downloadpodman-f77d846536718950575fa5206d9e3654ba140590.tar.gz
podman-f77d846536718950575fa5206d9e3654ba140590.tar.bz2
podman-f77d846536718950575fa5206d9e3654ba140590.zip
attach: fix attach when cuid is too long
conmon creates a symlink to avoid using a too long UNIX path. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1641800 There is still one issue when the path length of the symlink has the same length of the attach socket parent directory since conmon fails to create the symlink, but that must be addressed in conmon first. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/container_attach.go')
-rw-r--r--libpod/container_attach.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/libpod/container_attach.go b/libpod/container_attach.go
index 3c4e0775d..f925c3897 100644
--- a/libpod/container_attach.go
+++ b/libpod/container_attach.go
@@ -16,6 +16,10 @@ import (
"k8s.io/client-go/tools/remotecommand"
)
+//#include <sys/un.h>
+// extern int unix_path_length(){struct sockaddr_un addr; return sizeof(addr.sun_path) - 1;}
+import "C"
+
/* Sync with stdpipe_t in conmon.c */
const (
AttachPipeStdin = 1
@@ -81,11 +85,19 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi
logrus.Warnf("Failed to write to control file to resize terminal: %v", err)
}
})
- logrus.Debug("connecting to socket ", c.AttachSocketPath())
- conn, err := net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: c.AttachSocketPath(), Net: "unixpacket"})
+ socketPath := c.AttachSocketPath()
+
+ maxUnixLength := int(C.unix_path_length())
+ if maxUnixLength < len(socketPath) {
+ socketPath = socketPath[0:maxUnixLength]
+ }
+
+ logrus.Debug("connecting to socket ", socketPath)
+
+ conn, err := net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: socketPath, Net: "unixpacket"})
if err != nil {
- return errors.Wrapf(err, "failed to connect to container's attach socket: %v", c.AttachSocketPath())
+ return errors.Wrapf(err, "failed to connect to container's attach socket: %v", socketPath)
}
defer conn.Close()