From b32c017f33cbece12fb99c67118428b32238303c Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 16 Jul 2015 13:19:56 +0100 Subject: [PATCH] fix detection of host netns when weave script runs inside container $$ refers to the pid in the container's process namespace, so using it as a reference into /hostproc is entirely wrong. Fixes #1162. --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index eee61860..37ee8210 100755 --- a/weave +++ b/weave @@ -359,7 +359,7 @@ netnsenter() { } connect_container_to_bridge() { - if [ -h "$PROCFS/$CONTAINER_PID/ns/net" -a -h "$PROCFS/$$/ns/net" -a "$(readlink $PROCFS/$CONTAINER_PID/ns/net)" = "$(readlink $PROCFS/$$/ns/net)" ] ; then + if [ -h "$PROCFS/$CONTAINER_PID/ns/net" -a -h "/proc/$$/ns/net" -a "$(readlink $PROCFS/$CONTAINER_PID/ns/net)" = "$(readlink /proc/$$/ns/net)" ] ; then echo "Container is running in the host network namespace, and therefore cannot be" >&2 echo "connected to weave. Perhaps the container was started with --net=host." >&2 return 1