文件无法打开,是配置问题么?

base64 2003-09-15 02:35:46
用c写个简单的cgi程序

里面有一句:FILE * f;
f=fopen("../data/data.txt","a");
if(f==NULL)
printf("error");
else
.........

我编译如过 gcc -o test test.c 然后 ./test 可以正常打开

但是如果编译为cgi程序,用brower打开,就会显示 error,显然 f为NULL

这是什么原因呢?
...全文
76 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
base64 2003-09-15
  • 打赏
  • 举报
回复
For the codes, they are okay. The problem is that I didn't chmod the ~/public_html/cgi-bin 's privilige before I want to run the cgi script on an explorer. The vision is that when you excute it on the server, you may be the root user, but when you run the script through an explorer, you are a non-root user, so maybe you don't have the right to change anything inside the cgi-bin directory. And for my code, I want to use the function: fopen(), that's a kind of function depending on the user's privlige. So after doing "chmod a+w cgi-bin" action, I can run the script through an explorer. But the most disadvantage is that this kind of setting has much potential and monster danger. For that some hacker may damage your system by some dangerous cgi-script because of the high privilge you gave them. Have fun....

23,115

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧