我遇到了一个令人困惑的问题,即在 Linux 计算机上没有尊重用户权限。其他用户可以移动和删除不属于他们的文件。有没有办法限制这个?为什么会这样?这是一个例子。
# Become user jen
[root@localhost test]# su jen
# Display files in the current directory
[jen@localhost test]$ ls -al
total 24
drwxrwxrwx. 3 root root 4096 Apr 10 09:49 .
dr-xr-xr-x. 19 root root 4096 Apr 9 18:19 ..
drwx------. 2 root root 16384 Apr 9 16:15 lost+found
[jen@localhost test]$ touch jen_file
[jen@localhost test]$ ls -l
total 16
-rw-rw-r--. 1 jen jen 0 Apr 10 09:50 jen_file
drwx------. 2 root root 16384 Apr 9 16:15 lost+found
# Exit user jen and become user mike
[jen@localhost test]$ exit
[root@localhost test]# su mike
# Try to modify jen's file as mike. Permission denied, like normal.
[mike@localhost test]$ echo "test" > jen_file
bash: jen_file: Permission denied
# User mike can move jen's file! This should not happen.
[mike@localhost test]$ mv jen_file mike_file
[mike@localhost test]$ ls -l
total 16
-rw-rw-r--. 1 jen jen 0 Apr 10 09:50 mike_file
drwx------. 2 root root 16384 Apr 9 16:15 lost+found
# User mike can delete jen's file. This definately should not happen!
[mike@localhost test]$ rm -f mike_file
[mike@localhost test]$ ls -l
total 16
drwx------. 2 root root 16384 Apr 9 16:15 lost+found
Run Code Online (Sandbox Code Playgroud)
不确定它是否相关,但这里是已安装分区的 fstab 行(运行此测试的地方):
# Device name Mount point Type Attributes Dump Check
/dev/mapper/vg00-test /test ext4 defaults,acl,user_xattr,nodev 0 3
Run Code Online (Sandbox Code Playgroud)
实际上,这是按预期工作的。'mv' 包含一个读操作,mike 可以通过 o+r 执行,一个写操作,mike 可以通过 o+rwx 在目录中执行,以及一个删除操作,mike 可以通过o+rwx 在目录上。要获得您正在寻找的行为,请将目录 chmod 为模式 1777。
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |