Ger*_*mar 14 users permissions chown
重现步骤:
germar@host:~$ cd /tmp/
germar@host:/tmp$ touch test && chmod u+s test && ls -la test
-rwSr--r-- 1 germar germar 0 Nov 2 20:11 test
germar@host:/tmp$ chown germar:germar test && ls -la test
-rw-r--r-- 1 germar germar 0 Nov 2 20:11 test
Run Code Online (Sandbox Code Playgroud)
使用 Debian 挤压和 Ubuntu 12.04 进行测试
jll*_*gre 18
根据 chown 文档,这不是错误:
$ info coreutils 'chown invocation'
The `chown' command sometimes clears the set-user-ID or set-group-ID
permission bits. This behavior depends on the policy and functionality
of the underlying `chown' system call, which may make system-dependent
file mode modifications outside the control of the `chown' command.
For example, the `chown' command might not affect those bits when
invoked by a user with appropriate privileges, or when the bits signify
some function other than executable permission (e.g., mandatory
locking). When in doubt, check the underlying system behavior.
Run Code Online (Sandbox Code Playgroud)
Gil*_*il' 12
这是设计使然,这是标准行为。引用POSIX 标准:
除非 chown 由具有适当权限的进程调用,否则常规文件的 set-user-ID 和 set-group-ID 位应在成功完成后清除;可以清除其他文件类型的 set-user-ID 和 set-group-ID 位。
(s
顺便说一下,是setuid(或组列中的setgid),不粘。)
此行为遵循底层系统调用的行为(除了在某些系统上,setxid 位仅针对可执行文件清除)。
删除 setuid 位的原因是更改所有者也会更改哪个用户将成为进程的有效用户 ID。特别是,在用户可以放弃文件的系统上,cp /bin/sh foo; chmod u+s foo; chown joe foo
会创建一个属于 joe 的 setuid 可执行文件,这是一个巨大的安全漏洞。
归档时间: |
|
查看次数: |
5522 次 |
最近记录: |