mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-28 03:52:35 +00:00
ssh/tailssh: set DBUS_SESSION_BUS_ADDRESS and SSH_TTY variables
Updates #3802 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
6d61b7906e
commit
bf3559171f
@ -22,6 +22,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -119,6 +120,8 @@ func beIncubator(args []string) error {
|
|||||||
euid := uint64(os.Geteuid())
|
euid := uint64(os.Geteuid())
|
||||||
// Inform the system that we are about to log someone in.
|
// Inform the system that we are about to log someone in.
|
||||||
// We can only do this if we are running as root.
|
// We can only do this if we are running as root.
|
||||||
|
// This is best effort to still allow running on machines where
|
||||||
|
// we don't support starting session, e.g. darwin.
|
||||||
sessionCloser, err := maybeStartLoginSession(logf, uint32(*uid), *localUser, *remoteUser, *remoteIP, *ttyName)
|
sessionCloser, err := maybeStartLoginSession(logf, uint32(*uid), *localUser, *remoteUser, *remoteIP, *ttyName)
|
||||||
if err == nil && sessionCloser != nil {
|
if err == nil && sessionCloser != nil {
|
||||||
defer sessionCloser()
|
defer sessionCloser()
|
||||||
@ -334,6 +337,8 @@ func (srv *server) startWithPTY(cmd *exec.Cmd, ptyReq ssh.Pty) (ptyFile *os.File
|
|||||||
updateStringInSlice(cmd.Args, "--has-tty=false", "--has-tty=true")
|
updateStringInSlice(cmd.Args, "--has-tty=false", "--has-tty=true")
|
||||||
if ptyName, err := ptyName(ptyFile); err == nil {
|
if ptyName, err := ptyName(ptyFile); err == nil {
|
||||||
updateStringInSlice(cmd.Args, "--tty-name=", "--tty-name="+ptyName)
|
updateStringInSlice(cmd.Args, "--tty-name=", "--tty-name="+ptyName)
|
||||||
|
fullPath := filepath.Join("/dev", ptyName)
|
||||||
|
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_TTY=%s", fullPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if ptyReq.Term != "" {
|
if ptyReq.Term != "" {
|
||||||
|
@ -165,6 +165,7 @@ func maybeStartLoginSessionLinux(logf logger.Logf, uid uint32, localUser, remote
|
|||||||
logf("ssh: failed to CreateSession for user %q (%d) %v", localUser, uid, err)
|
logf("ssh: failed to CreateSession for user %q (%d) %v", localUser, uid, err)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
os.Setenv("DBUS_SESSION_BUS_ADDRESS", fmt.Sprintf("unix:path=%v/bus", resp.runtimePath))
|
||||||
if !resp.existing {
|
if !resp.existing {
|
||||||
return func() error {
|
return func() error {
|
||||||
return releaseSession(resp.sessionID)
|
return releaseSession(resp.sessionID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user