LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 648|回复: 3

非ROOT用户能访问另一个非ROOT用户的文件,WHY?

[复制链接]
发表于 2003-12-20 16:45:44 | 显示全部楼层 |阅读模式
#include <sys/types.h>
#include <fcntl.h>
#include "ourhdr.h"
int main (int argc , char *argv[] )
{
if (argc != 2) {
printf("usage: a.out <pathname>\n");
exit (0);
}
if (access(argv[1],R_OK) <0)
        printf("%s could not read \n",argv[1] );
else
        printf("read access ok\n");
if (open(argv[1], O_RDONLY ) <0)
        printf ("open error %s\n",argv[1]);
else
        printf ("open for reading ok\n");
exit (0);
}


# ll a.out fstab
-rwxr-xr-x    1 ftp      ftp         12050 2003-12-20 16:16 a.out
-rw-r-----    1 mail     mail          626 2003-12-18 21:08 fstab
# ./a.out fstab
read access ok
open for reading ok


请大家帮我解释一下,先谢了!!! OS is redhat 9.0
发表于 2003-12-20 17:11:58 | 显示全部楼层
分特
你shell的提示符是#啊
你在用root的身份来运行程序,当然可以访问啦
发表于 2003-12-20 17:26:13 | 显示全部楼层
收藏。
 楼主| 发表于 2003-12-20 17:28:31 | 显示全部楼层
不好意思。。。用ROOT用惯了,一时没注意。。 :confused: :confused:

发现用非ROOT也是用样的提示符。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表