LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   A program to send a character to another tty fails in 64-bit (https://www.linuxquestions.org/questions/linux-software-2/a-program-to-send-a-character-to-another-tty-fails-in-64-bit-4175631886/)

RandomTroll 06-13-2018 05:33 PM

A program to send a character to another tty fails in 64-bit
 
I wrote a small program to send a character to a terminal other than my own. I moved to 64-bit recently and the program fails.

I open a terminal with:
Code:

        hTTY = open(/dev/tty3, O_WRONLY|O_NONBLOCK);
then send a character with:
Code:

result=ioctl(hTTY, TIOCSTI, argv[2]);
The open succeeds but the ioctl fails with errno=1, Operation not permitted.

If I send to its own tty it works. Ownership and permissions of the target terminal don't matter. If I do it as root it works.
What's the difference between 32 and 64 bit?

smallpond 06-14-2018 12:42 PM

Most likely you are hitting capabilities. My guess would be you need CAP_SYS_TTYCONFIG.

http://man7.org/linux/man-pages/man7...ilities.7.html

RandomTroll 06-14-2018 01:49 PM

Quote:

Originally Posted by smallpond (Post 5867626)
Most likely you are hitting capabilities. My guess would be you need CAP_SYS_TTYCONFIG.

Thanks. I didn't know about this; BTW it's CAP_SYS_TTY_CONFIG. I wrote the program a few years ago. I worked until I switched to 64-bit, same kernel version.

keefaz 06-15-2018 02:24 PM

You updated system to 64 bits keeping same group settings for user?

RandomTroll 06-16-2018 09:36 AM

Quote:

Originally Posted by keefaz (Post 5868055)
You updated system to 64 bits keeping same group settings for user?

Yes.

RandomTroll 06-16-2018 01:19 PM

Setting the sticky bit makes it work.


All times are GMT -5. The time now is 08:18 AM.