Skip to content

add stdin remapping support - #23

Merged
chzyer merged 1 commit into
chzyer:masterfrom
lunixbochs:master
Dec 24, 2015
Merged

chzyer merged 1 commit into
chzyer:masterfrom
lunixbochs:master

Conversation

@lunixbochs

Copy link
Copy Markdown
Contributor

This allows replacing Stdin with a socket other file interface as requested in #14. I'm using this in my Usercorn project for a remote debugging interface. I made the API use a new FdReader interface for Stdin in lieu of using os.File for ease of wrapping. The connecting client is expected to manually place stdin into raw mode.

This shouldn't break any existing features as it falls back to the global Stdin object for normal use.

Here's what the server-side looks like: https://github.com/lunixbochs/usercorn/blob/master/go/usercorn/debugger.go#L40

Here's the client-side (where I manually set raw mode on stdin): https://github.com/lunixbochs/usercorn/blob/master/go/usercorn/cli.go#L74

Comment thread operation.go

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunixbochs, Maybe netfd is not working here? Have you tried this yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work and isn't likely to ever work. You're in raw mode for operations already. Why are you using the crypto/ssh/terminal library to read passwords? Just stop echoing characters for the line.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunixbochs I haven't dig out a lot about how it implement, I'm not sure it's as simple as stop echoing characters.
Anyway, it seems not breaking anything. Thanks for you pr!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my suggestion was a result of looking at the source for terminal. They literally just set t.echo = false then read a line:

https://github.com/golang/crypto/blob/master/ssh/terminal/terminal.go#L649

Also when I said "it doesn't work", I mean it throws an error about being unable to configure the device. The only way to fix this would be reading passwords from your own code (by disabling echo, then reading a line in raw mode).

chzyer added a commit that referenced this pull request Dec 24, 2015
add stdin remapping support
@chzyer
chzyer merged commit 94a7081 into chzyer:master Dec 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址