summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-10-30 14:22:01 -0700
committerGitHub <noreply@github.com>2018-10-30 14:22:01 -0700
commitee513cca8612bebfda36e31203ab215aa682e8c0 (patch)
tree1d9e212c5d3a24608a075882760434d7818278f3 /libpod
parent319a7a7043c581c9227a07dd98588a0cdf1e7027 (diff)
parentc65b3599cc3ab6972f1b5d96f3e712cd86d74833 (diff)
downloadpodman-ee513cca8612bebfda36e31203ab215aa682e8c0.tar.gz
podman-ee513cca8612bebfda36e31203ab215aa682e8c0.tar.bz2
podman-ee513cca8612bebfda36e31203ab215aa682e8c0.zip
Merge pull request #1704 from giuseppe/attach-cuid-too-long
attach: fix attach when cuid is too long
Diffstat (limited to 'libpod')
-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()