/usr/bin/passwd 和 CAP_CHOWN 功能
我正在试验 Linux 功能,我注意到,要使 passwd
程序在没有 Set-UID root 的情况下工作,它需要具有 CAP_CHOWN 功能(除了一些其他的)。从逻辑上讲,为什么需要 CAP_CHOWN 呢?
顺便说一句,如果我删除该功能,passwd 会给我一个“令牌操作错误”。
编辑:我使用的是没有 SELinux 的 Ubuntu 11.04。我正在尝试让 passwd
在不成为 Set-UID root 的情况下工作。
I was experimenting with Linux Capabilities, and I noticed that for the passwd
program to work without being Set-UID root, it needs to have the CAP_CHOWN capability (in addition to some others). Logically, why would it need to have CAP_CHOWN at all?
Incidentally, passwd gives me a "token manipulation error" if I remove the capability.
Edit: I'm using Ubuntu 11.04 without SELinux. I'm trying to get passwd
to work without being Set-UID root.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
passwd
本身不需要cap_chown
。只需要更改与userID
关联的 /etc/shadow 文件。/etc/shadow 文件已设置为任何人都无法读取。
/etc/shadow 只能由 root 访问。因此,当 /etc/passwd 完成其身份验证模块并准备写入新的(编码的)密码时,它将创建一个令牌。它由 Linux-PAM 服务访问,该服务会将其 chown 到 root 并将其写入 /etc/shadow。
编辑:
passwd 使用文件 /etc/.pwd.lock 、 /etc/shadow 、 /etc/nshadow 。
由于passwd从/etc目录中读取和写入,因此需要w权限。请注意,/etc/shadow 永远不会由 passwd 写入。 passwd 实际上写入 /etc/nshadow 并将 /etc/nshadow 重命名为 /etc/shadow。
此外,我使用这个C程序确认了
/etc/nshadow
的存在。供参考,The
cap_chown
is not required for thepasswd
itself. It is only needed to change the /etc/shadow file associated with theuserID
.The /etc/shadow file is set so that it cannot be read by just anyone.
/etc/shadow is only accessible to root. So when /etc/passwd finishes it's authentication module and is ready to write a new (encoded) password, it will create a token. Which is accessed by the Linux-PAM service, which will chown it to root and write it into /etc/shadow.
Edit:
passwd uses the files /etc/.pwd.lock, /etc/shadow , /etc/nshadow.
Since passwd reads and writes from /etc directory, w permissions are requried by it. Note that, /etc/shadow is never written by passwd. passwd actually writes to /etc/nshadow and renames /etc/nshadow to /etc/shadow.
Furthermore, I confirmed the existence of
/etc/nshadow
using this C program. FYI,setuid
就是最初所需要的。SELinux(安全增强)的添加要求程序上下文是正确以及文件权限检查。
如果系统的 SE 功能被禁用,
passwd
将正常工作,无需任何CAP_...
。我在某处读到可以通过向/selinux/disable
写入“1”来禁用 SE。大概写“0”会重新启用它。请参阅NSA 的描述或Fedora 的。
setuid
is all that originally was needed.The additions of SELinux (Security Enhanced) requires the program context to be correct as well as file permission checks.
If the system's SE feature is disabled,
passwd
will work fine without anyCAP_...
. Somewhere I read that SE can be disabled by writing a "1" to/selinux/disable
. Presumably writing "0" reenables it.See NSA's description or Fedora's.