【问题标题】:Semget Permission denied when not root, server config issue?不是root时Semget权限被拒绝,服务器配置问题?
【发布时间】:2013-07-31 16:49:36
【问题描述】:

我有一个 C++ 应用程序,它使用我试图通过 PHP“exec”命令调用的信号量。从终端以“root”身份登录时,我可以成功运行该应用程序,但是当 apache 尝试运行它(作为用户 apache)时,它会失败并出现“Permission denied”错误。

我做了一个 "chwon apache:apache prog" 和 777 它的权限来测试,它仍然失败。

奇怪的是,这个确切的应用程序在我的本地开发环境中通过 apache 运行得非常好。两个环境都是 Centos 6.4 (Final) x86_64 并以同一用户身份运行 PHP。

我没有想法,我不确定我还能做什么。

这是我的代码的相关部分。

void landw(char* path, char* retType)
{
startLocking:
    int semid,count;
    struct sembuf op;
    semid = semget((key_t)KEY,10,0666|IPC_CREAT);//Fails here
    if(semid==-1)
    {
      perror("error in creating semaphore, Reason:");
    }
...

我什至把“semget”这一行改成了测试,还是不行。

semid = semget((key_t)KEY,10,0666|IPC_CREAT|S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);

谢谢

【问题讨论】:

    标签: c++ configuration centos semaphore


    【解决方案1】:

    我终于解决了这个问题,问题是 SELinux。

    SELinux 在我的两台开发机器上都被禁用,但在生产服务器上启用。

    【讨论】:

      猜你喜欢
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 2018-06-11
      • 2015-01-28
      • 2015-05-24
      • 2021-08-30
      相关资源
      最近更新 更多