Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3793256

Browse files
committed
fix(cli/ssh): prevent stdin/stdout reads/writes in stdio mode
Fixes#11530
1 parentf2aef07 commit3793256

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎cli/ssh.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ func (r *RootCmd) ssh() *clibase.Cmd {
8787
}
8888
}()
8989

90+
// In stdio mode, we can't allow any writes to stdin or stdout
91+
// because they are used by the SSH protocol.
92+
stdioReader,stdioWriter:=inv.Stdin,inv.Stdout
93+
ifstdio {
94+
inv.Stdin=stdioWarnReader{inv.Logger}
95+
inv.Stdout=inv.Stderr
96+
}
97+
9098
// This WaitGroup solves for a race condition where we were logging
9199
// while closing the log file in a defer. It probably solves
92100
// others too.
@@ -234,7 +242,7 @@ func (r *RootCmd) ssh() *clibase.Cmd {
234242
iferr!=nil {
235243
returnxerrors.Errorf("connect SSH: %w",err)
236244
}
237-
copier:=newRawSSHCopier(logger,rawSSH,inv.Stdin,inv.Stdout)
245+
copier:=newRawSSHCopier(logger,rawSSH,stdioReader,stdioWriter)
238246
iferr=stack.push("rawSSHCopier",copier);err!=nil {
239247
returnerr
240248
}
@@ -987,3 +995,12 @@ func sshDisableAutostartOption(src *clibase.Bool) clibase.Option {
987995
Default:"false",
988996
}
989997
}
998+
999+
typestdioWarnReaderstruct {
1000+
l slog.Logger
1001+
}
1002+
1003+
func (rstdioWarnReader)Read(p []byte) (nint,errerror) {
1004+
r.l.Warn(context.Background(),"reading from stdin in stdio mode is not supported")
1005+
return0,io.EOF
1006+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp