v1.09 TIOCSCTTY error
Brought to you by:
thesun
Hi,
Version 1.09 is not working at all (also with -p
switch)
:; /usr/bin/sshpass -V | head -1
sshpass 1.09
:; SSHPASS=*** /usr/bin/sshpass -e ssh -t ...
sshpass: Failed to set controlling terminal in child (TIOCSCTTY): Inappropriate ioctl for device
Version 1.08 does.
Best regards
Can you please provide relevant details. What OS is this, where is the package from (i.e. - compiled by you or pre-packaged. If the later, by whom)?
It is OpenIndiana (fork from OpenSolaris):
Packaged by team: https://github.com/OpenIndiana/oi-userland/tree/oi/hipster/components/network/sshpass
I have compiled v 1.08 from source file found here, with GCC 10:
UPDATE:
Last edit: Predrag Zečević 2022-05-04
I tried installing it inside a VM, but I don't know how to install the dependencies. Can you explain the steps needed to turn a bare install to one that is capable of compiling sshpass?
Hi,
you have to install build-essential meta package (it will install all development tools, full list of included packages at https://pkg.openindiana.org/hipster/manifest/0/metapackages%2Fbuild-essential%401.0%2C5.11-2022.0.0.1%3A20220117T192224Z)
GCC suite is installed under
/usr/gcc
directory, so you have to adjust your environment variables.For example, I have installed several compilers:
e.g.
So, issue:
Best regards.
Last edit: Predrag Zečević 2022-05-30
Any news on this?
In fact, looks like there are two bugs in the code:
1) per tty_ioctl's documentation, the TIOCSCTTY option requires an int argument, while none is provided here. Adding a zero solves the invalid argument problem (the only value mentioned is 1 and it is for root only)
NOTE: because of the way the documentation is formatted, it is easy to treat the description for TIOCNOTTY - which says about a void argument - as the second part for TIOCSCTTY.
3) Once the invalid argument is resolved, we'll face the 'operation not permitted' error. This is because, per tty_ioctl doc:
The calling process must be a session leader and not have a controlling terminal already. If this terminal is already the controlling terminal of a different session group then the ioctl fails with EPERM
Now, the condition is false because a call to open only specified the O_RDWR flag - while the documentation to open includes the O_NOCTTY flag which is described as:
O_NOCTTY
If pathname refers to a terminal device—see tty(4)—it will
not become the process's controlling terminal even if the
process does not have one.
So in the absence of that flag, the open() must have already assigned the slave terminal as the controlling terminal and then a call to ioctl failed.
A resolution is to add the O_NOCTTY flag to the call to open(); my working code is this:
HI!
I have tested this patch, and it has worked!
Many thanks.
Adding patch file (NOTE: it was tested only on OpenIndiana platform):
Patch file was created by comparing original and modified file:
Regards.
This patch helps to fix well known issue also for msys/mingw too. As I can see, there are no obvious reasons for regression with this change. Thanks.
Fix is pushed to repo. Thank you, everyone.
Release 1.10 now has the fix.