我遇到了一个令人困惑的问题,那就是在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
不知道是否相关,但是这里是挂载分区的fstab行(在这个testing运行的地方):
# Device name Mount point Type Attributes Dump Check /dev/mapper/vg00-test /test ext4 defaults,acl,user_xattr,nodev 0 3
实际上,这是按预期工作的。 'mv'由一个读操作组成,这个操作由o + r允许mike执行,一个写操作,mike被o + rwx允许在目录上执行,以及一个删除操作,允许mike通过o在目录上的rwx。 要获得您正在查找的行为,请将目录修改为模式1777。
你误解了权限的概念。
移动和删除操作在目录上,而不是在文件上。 而且麦克具有对目录的读/写权限。