源代码已经在Fedora 15,16和Ubuntu 10,11,12中测试过了,没有问题。在firebreath npplugin中拒绝文件写入权限
但是在Fedora 17中,文件写入功能不起作用。
1)
int fd;
if (0 < (fd = open("/home/test/temp/opentest.html", O_CREAT | O_EXCL, 0777))) {
write(fd, "test", strlen("test"));
close(fd);
return "Success";
} else {
return "Error";
}
返回值:错误
2)
FILE *pFile;
pFile = fopen("/home/test/temp/opentest.html", "w+");
if (pFile == NULL) {
return "Pointer is NULL";
} else {
fputs("fopen test", pFile);
fclose(pFile);
return "Success";
}
返回值: “指针为空”
我猜目录的权限,使错误和设置777权限。 但没有什么改变。
相同的代码在正常的C程序中工作。
为什么它没有在firebreath npPlugin中工作?
关于权限有什么区别吗?
是否有任何其他目的的mktemp函数没有创建临时文件?我应该创建html文件并设置我想要的文件名。 – Oz6848
糟糕,我实际上是想链接['mkstemp(3)'](http://linux.die.net/man/3/mkstemp)。如果它只是一个临时文件,命名应该没有关系,所以目的是在分发与预期不同的情况下不要硬编码临时目录。 –
谢谢你的建议。但它不仅仅是一个临时文件,并且名称是作为来自javascript的参数传递的。它不能改变。 – Oz6848