加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

debian – “无法在su期间将终端进程组设置为另一个用户作为登录

发布时间:2020-12-15 18:39:13 所属栏目:安全 来源:网络整理
导读:注意:请阅读本文中途附近“编辑”开头的更新信息 – 此问题的环境和背景已更改 我在这里安装了一个标准的Debian 6.0标准,我决定将其迁移到Debian Testing存储库.我通过在sources.list中交换对Squeeze repos的引用来改为使用Testing repos. 软件包安装和重新
注意:请阅读本文中途附近“编辑”开头的更新信息 – 此问题的环境和背景已更改

我在这里安装了一个标准的Debian 6.0标准,我决定将其迁移到Debian Testing存储库.我通过在sources.list中交换对Squeeze repos的引用来改为使用Testing repos.

软件包安装和重新启动后,尝试su – 另一个用户时出现以下错误:

root@skaia:~# su joebloggs -
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

如果省略 –,则不会发生这种情况.

请注意,用户可以正确地成为root用户,这似乎只有在从root用户切换到其他用户并使用 – 来获取该用户的环境时才会发生.

谷歌在这里几乎没用.我能找到的唯一的东西是2011年关于sux包的引用,它似乎已经在同一时间修复了.

这看起来和闻起来非常像升级错误,可以通过以正确的方式调整正确的包来解决.我不知道从哪里开始 – 除此之外,我的系统完全正常工作并且符合预期.

编辑

现在,如上所述,在Debian稳定机器上发生这种情况.这次没有升级或任何东西,只是直线上升稳定.

是的,一年后.仍然不知道问题是什么.

这就是现在的样子(没有太大变化):

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
terraria@skaianet:~$tty
/dev/pts/0
terraria@skaianet:~$ls -l /dev/pts/0
crw--w---- 1 root root 136,0 Oct 10 19:21 /dev/pts/0
terraria@skaianet:~$ls -l /dev/pts/
crw--w---- 1 root root 136,0 Oct 10 19:21 0
crw--w---- 1 root root 136,2 Sep 22 17:47 2
crw--w---- 1 root root 136,3 Sep 26 19:30 3
c--------- 1 root root   5,2 Sep  7 10:50 ptmx

像这样生成一个strace:

root@skaianet:~$strace -f -o tracelog su terraria -

..也会出现一些令人困惑的行为.这些消息相当令人困惑.一些选定的行:

readlink("/proc/self/fd/0","/dev/pts/0",4095) = 10
#Error code 10? 
15503 open("/dev/tty",O_RDWR|O_NONBLOCK) = -1 ENXIO (No such device or address)
#Yes there is,and I can interact with it normally
15503 ioctl(255,TIOCGPGRP,[32561])    = -1 ENOTTY (Inappropriate ioctl for device)

我已经链接了the full output of this strace session – 我所做的只是运行su命令,然后立即ctrl d离开终端.

> su – 用户名被su解释为“将用户名的shell作为交互式登录shell运行”
> su username – 由你的su解释为“运行以下非交互式命令( – )作为用户名”
>后者只能起作用,因为:

>你的su将尾随参数传递给sh进行解析
> sh take – 表示“作为登录shell运行(读取/ etc / profile,…)”

但你真正感兴趣的是:为什么不互动?在特权父级和非特权级子级之间共享控制终端会使您容易受到“TTY pushback privilege escalation”(即TIOCSTI错误)的攻击,因此除非您确实需要它,否则请使用su detaches from it.当您使用su用户名 – 表单时,请使用su inferred that you didn’t need a controlling terminal.

只有具有控制终端的进程才能拥有操作进程组的会话负责人(进行作业控制);你给的跟踪是bash检测到它不能成为会话领导者.

你提到:

Where it gets stranger is that both forms work fine on Ubuntu and CentOS 6,however on vanilla Debian,only the first form works without error.

忽略sux和sudo之类的变体,Linux上至少有三个[1]版本的su:coreutils,util-linux和shadow-utils来自Debian.后者的联机帮助指出:

This version of su has many compilation options,only some of which may be in use at any particular site.

和Debian的标志是old_debian_behavior;其他版本可能有类似的编译时/运行时选项.可变性的另一个原因可能是有一些debate [2]关于su是否应该用于以这种方式删除权限以及TIOCSTI bug是否因此是一个bug(Redhat最初是closed it “WONTFIX”).

[1]:编辑:添加SimplePAMApps和hardened-shadow.

[2]:Solar Designer有some (old) opinions there,我认为值得一读.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读