Permissions problem runninge executable from PHP script

Discussion in 'Apache' started by EricFowler, Aug 23, 2009.

  1. #1
    I am a relative noob to Apache and PHP. I have a small executable that I wrote myself that I wish to execute from PHP using the system() function. For lack of any better ideas, I put it in /var/www/html with my PHP script.

    When I attempt execute it, I (not surprisingly) get a complaint from SELinux ('SELinux is preventing the phptest from using potentially mislabeled files anon_inode (anon_inodefs_t). ').

    It tells me what I can do to allow access. ... but I am wondering: is there a 'stock' way to grant execute access to files? Is there a particular place they should live? I wrote the executable and I trust it.

    Eric
     
    EricFowler, Aug 23, 2009 IP
  2. bulkemailpp

    bulkemailpp Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If safe_mode (PHP) is On, you must place your applications to the folder set in safe_mode_exec_dir directive.
     
    bulkemailpp, Aug 24, 2009 IP
  3. EricFowler

    EricFowler Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Duh, I don't even know how to check. phpinfo() is not telling me it is on, and this code does not work:

    if(safe_mode(PHP))
    print "Safe mode is ON";
    else
    print "Safe mode is OFF";


    But the PHP man page is telling me that using safe_mode() is lame and deprecated.
     
    EricFowler, Aug 24, 2009 IP
  4. EricFowler

    EricFowler Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Eh, I just figured it out. Safe mode is OFF.
     
    EricFowler, Aug 24, 2009 IP
  5. fbnewtz

    fbnewtz Peon

    Messages:
    160
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That is a SELinux issue. The explanation they give is the correct way to enable files to be executed by a webserver. That is why it is called SELinux. It is designed to give you fine granular control over what can and cannot happen on your box. I know it is a PITA, but there is not really much you can do about it. SELinux needs a four year degree all in itself. Too complicated for us feeble minded folks. But if the NSA uses it, they use it for a reason.
     
    fbnewtz, Aug 24, 2009 IP