如何在两个 TTY 之间创建循环? [英] How can I create a loop between two TTYs?

查看:42
本文介绍了如何在两个 TTY 之间创建循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个Hello 都有一个响应.第二个 TTY 将向发件人 TTY 发送问候,反之亦然:

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

第一个接收者应该向原始发送者发送hello",但它没有.怎么了?

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

[澄清] 我有两个 shell 正在运行./dev/pts/1 是初始发送者.

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

推荐答案

当您将 echo 命令发送到 /dev/pts/0 时,您实际上只是将该 echo 的输出发送给另一个TTY 的输出 - 您将其发送到其他 TTY 的输入缓冲区.因此,您嵌套的 echo 命令只会显示在另一个 TTY 上,但不会执行.

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.

有一个 ioctl() 调用 TIOCSTI 可用于在另一个 TTY 上伪造输入,但前提是您对该另一个 TTY 具有写入"权限.

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.

许多年前,我记得一些朋友和我在某些版本的 UNIX 上发现了漏洞,这些漏洞没有正确执行 TIOCSTI 的安全权限.如果 root 将终端登录到某个地方,则可以让 root 用户的终端代表您输入命令...

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...

这篇关于如何在两个 TTY 之间创建循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆