Hello openssh developers, Instead of just playing nethack, I've been building a client that would log in to nethack at alt.org and using a pipe to get the login data from pwsafe directly onto the server. All of this works brilliantly after playing with some stty magic (full script in [0]), however, this way the terminal size is burned into 80x24, which is way smaller than my graphical terminal. Anyway, I proceeded grepping some of the openssh source code and wrote this patch [1], which I have locally tested with great success. cheers! mar77i [0] https://gist.github.com/mar77i/15040d227ec9f7311f25 [1] https://gist.github.com/mar77i/673b0338a90bd53bb32e
On Tue, 1 Sep 2015, Martti K?hne wrote:> Hello openssh developers, > > Instead of just playing nethack, I've been building a client that > would log in to nethack at alt.org and using a pipe to get the login data > from pwsafe directly onto the server. > All of this works brilliantly after playing with some stty magic (full > script in [0]), however, this way the terminal size is burned into > 80x24, which is way smaller than my graphical terminal. > > Anyway, I proceeded grepping some of the openssh source code and wrote > this patch [1], which I have locally tested with great success.The problem with doing it via enviornment variables is that they will become invalid if the client ever changes the size of their window. TTYs support sending SIGWINCH for this and OpenSSH handles this already. Your program should be able to get the correct window size at any time using: struct winsize ws; if (ioctl(ttyfd, TIOCGWINSZ, &ws) != 0) error(...); -d
> > Instead of just playing nethack, I've been building a client that > > would log in to nethack at alt.org and using a pipe to get the login data > > from pwsafe directly onto the server. > > All of this works brilliantly after playing with some stty magic (full > > script in [0]), however, this way the terminal size is burned into > > 80x24, which is way smaller than my graphical terminal. > > > > Anyway, I proceeded grepping some of the openssh source code and wrote > > this patch [1], which I have locally tested with great success. > > The problem with doing it via enviornment variables is that they > will become invalid if the client ever changes the size of their > window. TTYs support sending SIGWINCH for this and OpenSSH handles > this already. > > Your program should be able to get the correct window size at any > time using: > > struct winsize ws; > if (ioctl(ttyfd, TIOCGWINSZ, &ws) != 0) > error(...);The "script" version of that is calling "tput cols" and "tput lines", parsing the text output as integers...
On Tue, Sep 1, 2015 at 2:00 AM, Damien Miller <djm at mindrot.org> wrote:> The problem with doing it via enviornment variables is that they > will become invalid if the client ever changes the size of their > window. TTYs support sending SIGWINCH for this and OpenSSH handles > this already. > > Your program should be able to get the correct window size at any > time using: > > struct winsize ws; > if (ioctl(ttyfd, TIOCGWINSZ, &ws) != 0) > error(...); > > -dThe issue I have is the redirection of stdin/fd0 which is equal to in_fd in the function where the patch applied. It must be a pipe, or no data will be received by the program due to how file descriptors work. An alternative, probably more agreeable solution would be to open /dev/tty exclusively for the ioctl. Thanks for your consideration. cheers! mar77i