tailssh: fix platform SFTP session teardown
This commit is contained in:
@@ -28,6 +28,7 @@ func (b *platformShellBackend) OpenSession(request shellRequest) (shellSession,
|
|||||||
return &platformShellSession{
|
return &platformShellSession{
|
||||||
session: session,
|
session: session,
|
||||||
master: master,
|
master: master,
|
||||||
|
isPty: request.Term != "",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ func (b *platformShellBackend) Close() error {
|
|||||||
type platformShellSession struct {
|
type platformShellSession struct {
|
||||||
session adapter.ShellSession
|
session adapter.ShellSession
|
||||||
master *os.File
|
master *os.File
|
||||||
|
isPty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *platformShellSession) Read(p []byte) (int, error) {
|
func (s *platformShellSession) Read(p []byte) (int, error) {
|
||||||
@@ -53,8 +55,10 @@ func (s *platformShellSession) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *platformShellSession) CloseWrite() error {
|
func (s *platformShellSession) CloseWrite() error {
|
||||||
// The platform owns the master fd lifecycle; rely on Close for teardown.
|
if s.isPty {
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
return syscall.Shutdown(int(s.master.Fd()), syscall.SHUT_WR)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *platformShellSession) Resize(rows, cols uint16) error {
|
func (s *platformShellSession) Resize(rows, cols uint16) error {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ func StartSocketpairProcess(shell string, args, env []string, dir string, uid, g
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, E.Cause(err, "socketpair")
|
return nil, nil, E.Cause(err, "socketpair")
|
||||||
}
|
}
|
||||||
|
syscall.CloseOnExec(fds[0])
|
||||||
|
syscall.CloseOnExec(fds[1])
|
||||||
childFile := os.NewFile(uintptr(fds[1]), "socketpair-child")
|
childFile := os.NewFile(uintptr(fds[1]), "socketpair-child")
|
||||||
cmd := exec.Command(shell)
|
cmd := exec.Command(shell)
|
||||||
cmd.Args = args
|
cmd.Args = args
|
||||||
|
|||||||
Reference in New Issue
Block a user