diff --git a/integration/410_container_control_test.sh b/integration/410_container_control_test.sh index b85a57a8b..5b898af52 100755 --- a/integration/410_container_control_test.sh +++ b/integration/410_container_control_test.sh @@ -16,7 +16,7 @@ PROBEID=$(docker_on $HOST1 logs weavescope 2>&1 | grep "probe starting" | sed -n # Execute 'echo foo' in a container tty and check its output PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_exec_container" | jq -r '.pipe' ) -assert "(sleep 1 && echo 'echo foo' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "/ # 6necho foo\nfoo\n/ # 6n" +assert "(sleep 1 && echo 'echo foo' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "alpine:/# 6necho foo\nfoo\nalpine:/# 6n" assert_raises "curl -f -X POST 'http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_stop_container'" diff --git a/probe/docker/controls.go b/probe/docker/controls.go index 5fc85a417..375d86a9d 100644 --- a/probe/docker/controls.go +++ b/probe/docker/controls.go @@ -111,7 +111,7 @@ func (r *registry) execContainer(containerID string, req xfer.Request) xfer.Resp AttachStdout: true, AttachStderr: true, Tty: true, - Cmd: []string{"/bin/sh", "-c", "TERM=xterm exec $( (type getent > /dev/null 2>&1 && getent passwd root | cut -d: -f7 2>/dev/null) || echo /bin/sh)"}, + Cmd: []string{"/bin/sh", "-l", "-c", "TERM=xterm exec $( (type getent > /dev/null 2>&1 && getent passwd root | cut -d: -f7 2>/dev/null) || echo /bin/sh)"}, Container: containerID, }) if err != nil { diff --git a/probe/host/controls_darwin.go b/probe/host/controls_darwin.go index cae9c363e..8171d4d10 100644 --- a/probe/host/controls_darwin.go +++ b/probe/host/controls_darwin.go @@ -1,5 +1,5 @@ package host func getHostShellCmd() []string { - return []string{"/bin/bash"} + return []string{"/bin/bash", "-l"} } diff --git a/probe/host/controls_linux.go b/probe/host/controls_linux.go index f4870c33d..bb3fc0cdc 100644 --- a/probe/host/controls_linux.go +++ b/probe/host/controls_linux.go @@ -23,12 +23,12 @@ func getHostShellCmd() []string { "/usr/bin/nsenter", "-t1", "-m", "-i", "-n", "-p", "--no-fork", "--setuid", uid, "--setgid", gid, - shell, + shell, "-l", } } _, _, shell := getRootUserDetails([]string{"cat", "/etc/passwd"}) - return []string{shell} + return []string{shell, "-l"} } func getRootUserDetails(readPasswdCmd []string) (uid, gid, shell string) {