tags:

views:

349

answers:

2

Every Hello has a response. Second TTY will send a hello to the sender TTY and vice versa:

echo 'echo hello > /dev/pts/1' > /dev/pts/0

The 1st receiver should send "hello" to the original sender, but it does not. What is wrong?

[Clarification] I have two shells running. /dev/pts/1 is the initial sender.

A: 

Do you have a shell running at /dev/pts/0?

Charlie Martin
Yes, I have two shells running. The initial sender is /dev/pts/1.
Masi
+2  A: 

When you send your echo command to /dev/pts/0 you are literally just sending the output of that echo to the other TTY's output - you are not sending it to the other TTY's input buffers. Therefore your nested echo command will simply be displayed on the other TTY, but not executed.

There is an ioctl() call TIOCSTI which can be used to fake input on another TTY, but only if you have "write" permission to that other TTY.

Many years ago I recall that some friends and I discovered holes on some versions of UNIX which didn't correctly enforce the security permissions on TIOCSTI. If root had left a terminal logged in somewhere it was possible to make the root user's terminal type in commands on your behalf...

Alnitak