Background:
when the 'ssh' command is run, its stdin and stdout are often connected
to pipes. Think about rsync, git, scp, ...
ssh-ident internally calls ssh-add. If ssh-add does not have a terminal
for stdin and stdout, it can't read a password, so it invokes ssh-askpass,
and FAILS if ssh-askpass cannot be found.
Which is annoying for a few reasons:
- ssh-askpass becomes a requirement to use ssh-ident.
ssh-add will fail if it can't find it :(
- ssh-askpass is invoked even in cases where, well, a terminal
would normally be used.
In this change:
- when running ssh-add, connect its stdin and stdout to a suitable
terminal.
- add code to detect a 'suitable' terminal.
The logic to determine what 'suitable' here is more complex than
it should be. Normally one would just check if stdin / stdout are
terminals. But this does not work here (see background).
So instead the code checks if 1) there is a /dev/tty, and 2) this
/dev/tty is an usable tty. 2) is necessary because in some cases
/dev/tty exists, is readable and writable, it is a character device,
but using it as a terminal returns ENXIO or ENODEV.
So the detection code does a 'noop' tty ioctl, in order to detect
ENXIO and ENODEV. If no error is returned, then it is a dvice.
Terminals are black magic.
This (hopefully) closes#29, and closes#32.
"ASSIGNMENT" syntax everywhere.
For some reason, when I wrote the documentation I was assuming a dict
was used for configuration parameters. Closes#20.
ssh-ident, where it was supposed to be to begin with, move from future
... after the file docstring (otherwise pydoc doesn't generate / show
the documentation correctly), and update the README with pydoc ssh-ident
> README.