mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Merge pull request #1821 from weaveworks/1698-make-shells-login
Use login shells in terminals
This commit is contained in:
@@ -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;<container>/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;<container>/docker_stop_container'"
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package host
|
||||
|
||||
func getHostShellCmd() []string {
|
||||
return []string{"/bin/bash"}
|
||||
return []string{"/bin/bash", "-l"}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user