Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当apache web服务器检查文件是否存在时,CentOS 5.7访问系统调用返回EACCES_Php_C++_Linux_Centos - Fatal编程技术网

Php 当apache web服务器检查文件是否存在时,CentOS 5.7访问系统调用返回EACCES

Php 当apache web服务器检查文件是否存在时,CentOS 5.7访问系统调用返回EACCES,php,c++,linux,centos,Php,C++,Linux,Centos,这是我们的Centos版本号 [marc disk5]$ cat /etc/redhat-release CentOS release 5.7 (Final) 下面是我们如何启动ApacheWeb服务器的 [marc php]$ sudo gdb /usr/sbin/httpd [sudo] password for marc: GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5_7.1) Copyright (C) 2009 Free

这是我们的Centos版本号

[marc disk5]$ cat /etc/redhat-release
CentOS release 5.7 (Final)
下面是我们如何启动ApacheWeb服务器的

[marc php]$ sudo gdb /usr/sbin/httpd
[sudo] password for marc: 
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5_7.1)
Copyright (C) 2009 Free Software Foundation, Inc.
Reading symbols from /usr/sbin/httpd...(no debugging symbols found)...done.
(gdb) run -X
下面是我们如何启动firefox web浏览器

[marc]$ sudo firefox
[sudo] password for marc: 
http MatchUpObjectPHPSample.php
这是我们在firefox web浏览器中输入的URL

[marc]$ sudo firefox
[sudo] password for marc: 
http MatchUpObjectPHPSample.php
当我们在web浏览器呈现的网页上激活提交请求时,我们会收到以下诊断消息:

Path /home/marc/data/mdMatchup.dat
throw exception /home/marc/data/mdMatchup.dat retval -1 errno 13
Errno 13是C/C++访问(“/home/marc/data/mdMatchup.dat”,F_OK)API调用返回的EACCESS,我们使用它来测试 文件存在。access的手册页声明:

每次请求的对文件的访问将被拒绝,或者对pathname的路径前缀中的一个目录的搜索权限将被拒绝

以下是我们的路径权限:

[marc /]$ ls -l
drwxr-xr-x   7 root root  4096 Jan  3 11:45 home

[marc home]$ ls -l
drwx------ 38 marc     users 4096 May 29 16:36 marc

[marc home]$ cd marc
[marc ~]$ ls -l
drwxrwxrwx  2 root   root       4096 May 29 19:20 data

[marc ~]$ cd data
[marc data]$ pwd
/home/marc/data
[marc data] ls -l 
-rwxrwxrwx 1 root root 244736 May 28 15:49 mdMatchup.dat
<>最后,这里是一个非常简短的C++代码片段:

cSQLite::cSQLite(char *File_,bool bMustExist_) {
  int retval(0);

  if (bMustExist_) {
     retval = access(File_,F_OK);

     if (retval != 0) {
       printf("throw exception %s retval %d errno %d\n",File_,retval,errno);
       throw cException(ERR_DBDATABASE,"cSQLite",File_);
     }

     if (sqlite3_open(File_,&Database)!=SQLITE_OK) {
       RecordError();
       throw cException(ERR_DBDATABASE,"cSQLite",LastError);
     }
  }

  Statement=0;
  Columns=0;
}

有人能告诉我们我们犯了什么错误,或者这是否是CentOS版本特定的问题吗?

您到底想在这里实现什么?为什么直接启动httpd而不是使用标准启动脚本?为什么要以root用户身份运行浏览器?根权限不通过HTTP连接传输


除此之外,问题是您的
marc
目录只能由
marc
用户读取。根据设计,Apache将放弃根权限,并以非特权用户(httpd、htdata等)的身份运行,因此它将无权访问/home/marc中的任何内容。

您在这里到底想做什么?为什么直接启动httpd而不是使用标准启动脚本?为什么要以root用户身份运行浏览器?根权限不通过HTTP连接传输


除此之外,问题是您的
marc
目录只能由
marc
用户读取。根据设计,Apache将放弃根权限,并以非特权用户(httpd、htdata等)的身份运行,因此它将无权访问/home/marc中的任何内容。

您是否检查了/etc/sudoers文件?您可能没有您认为的
marc
权限。你可能有一个愚蠢的Runas_规范或其他任何东西。@jnbneder,我刚刚检查了/etc/sudoers文件。下面是相关的行:root ALL=(ALL)ALL marc ALL=(ALL)ALL。谢谢您的帮助。您检查了/etc/sudoers文件了吗?您可能没有您认为的
marc
权限。你可能有一个愚蠢的Runas_规范或其他任何东西。@jnbneder,我刚刚检查了/etc/sudoers文件。下面是相关的行:root ALL=(ALL)ALL marc ALL=(ALL)ALL。感谢您的帮助。我尝试使用标准启动脚本并以marcuser的身份运行浏览器,此外,我将/home/marc子树添加到apache用户和用户组中,但access(path,F_OK)仍然返回-1,但没有返回EACCESS。我现在正在Centos服务器上运行yum更新,因为我记得Red Hat Linux 4.0没有此访问问题。感谢您的帮助。我尝试使用标准启动脚本并以marcuser的身份运行浏览器,此外,我将/home/marc子树添加到apache用户和用户组中,但access(path,F_OK)仍然返回-1,但没有返回EACCESS。我现在正在Centos服务器上运行yum更新,因为我记得Red Hat Linux 4.0没有此访问问题。谢谢你的帮助。