Fedora Linux Support Community & Resources Center
Old 7th August 2012, 05:46 AM
davewithheld Offline
Registered User
Join Date: Nov 2005
Posts: 17
php shell_exec can't see system files

I've used system($cmd) for years with very reliable results until F17 and PHP 5.4.4. The programs execute, ok, but they can't see any files in directories owned by root, regardless of permissions. PHP itself can read root-owned files, but not shell_exec() programs. I run apache as a specific user and when I log in as that user, the commands work fine from the command line, but when they execute from the shell_exec() call, they can't find files the programs are trying to read from.

For example,

$tmplist = `/bin/ls /tmp`;

total 0


$tmplist = `/bin/ls /`;

returns a full listing of the root directory.

There are many files in /tmp when I execute "/bin/ls /tmp" from the command line, but they don't show up when ls is executed from PHP. I have tried system(), shell_exec(), backticks, and exec(). All have the same result. Commands execute. "/bin/env" lists the environment variables the shell_exec() runs with, "/bin/whoami" outputs the web server's user name. It's just when the executed program tries to read a file in a directory owned by root, it thinks they don't exist. I first saw this when a program errored with "No such file or directory" when trying to read from a file that I KNEW was there (same command found it from the login shell).

I'm assuming this is a security "feature" of the new PHP or F17, but I can't find anything about it in the Google machine. Sounds like an Selinux thing, but Selinux is disabled. Anyone know what's causing this?

EDIT: I just tried CGI script (perl) and same problem, so it's apache/system config, not PHP! Still looking...

Last edited by davewithheld; 9th August 2012 at 06:02 AM.
Reply With Quote
Old 11th August 2012, 06:01 PM
davewithheld Offline
Registered User
Join Date: Nov 2005
Posts: 17
Re: php shell_exec can't see system files

Found it! Turns out that F16 intruduced the concept of a private /tmp and /var/tmp directory (which were the two directories I looked at) for services that keeps their temp files from being visible to other processes. Makes sense for security, but makes it difficult for services to share files with users and breaks my scripts. It can be disabled, though, which is fine for my home media/web/file server.

Explained under 2.3.3. Services Private

and http://fedoraproject.org/wiki/Featur...icesPrivateTmp
Reply With Quote

files, php, shellexec

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell_exec-PHP and sudo httpd reload LaKing Servers & Networking 3 8th October 2010 09:21 PM
Sharing Files by Connecting to a Linux System from a Windows System rvs1st Servers & Networking 2 20th October 2006 01:50 PM
File system and > 2TB Files Squeesh Using Fedora 3 31st July 2006 07:08 PM

Current GMT-time: 20:21 (Friday, 18-08-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat