记住哦,本站网址是:http://www.7139.com
梦幻网络
导航图标
您现在的位置: 梦幻网络 >> 技术学院 >> 程序设计 >> C C语言 >> 正文

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

来源:互联网 收集:梦幻网络 本站网址:www.7139.com 点击数: 【字体:减小 增大


#include #include #include "ourhdr.h"int main (int argc , char *argv[] ){if (argc != 2) {printf("usage: a.out
\n");exit (0);}if (access(argv[1],R_OK) <0)printf("%s could not read \n",argv[1] );elseprintf("read access ok\n");if (open(argv[1], O_RDONLY ) <0)printf ("open error %s\n",argv[1]);elseprintf ("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 fstabread access okOS is redhat 9.0open for reading ok
分特你shell的提示符是#啊你在用root的身份来运行程序,当然可以访问啦不好意思。。。用ROOT用惯了,一时没注意。。 发现用非ROOT也是用样的提示符(完)计算机基础教程网


Google
【更新时间:2006-7-12 20:38:43】【打印此文】【关闭窗口
  • 上一篇教程:
  • 下一篇教程:
  • 搜索