Why Program Execution Functions do not work correctly ?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
OmidReza
Forum Newbie
Posts: 3
Joined: Tue Aug 08, 2006 11:16 pm

Why Program Execution Functions do not work correctly ?

Post by OmidReza »

Hello,
My problem is :
Why Program Execution Functions do not work correctly ?
I attempt to run exec(),system(),shell_exec(),passthru()
but these functions do not work correctly although I use from filtering functions such as escapeshellarg() and escapeshellcmd() !!!
for example shell_exec('ls /') work correctly BUT shell_exec('ls /mnt') do not work !
Please help to me.
Thanks alot.

O.R.B
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

usually it's a permissions problem.
OmidReza
Forum Newbie
Posts: 3
Joined: Tue Aug 08, 2006 11:16 pm

Thanks about your answer BUT...

Post by OmidReza »

feyd wrote:usually it's a permissions problem.
-------------------------------------------------------------------------------------------
Hello,
Why the command exec( " ls / " ) works correctly but exec( " ls /mnt " ) or exec( " mkdir /newDir " ) or ... do not works ?
and for example : Why the return of system( " sendsms $telNum $msg " ) is 127 ? what is mean 127 ???
since I am in root I think it is not a permissions problem.
Thanks again.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

You might want to read up on it...

http://us2.php.net/manual/en/ref.exec.php

The server can LIMIT what directories and executables you have access. You probably do not have permission to access those directories. Also, if the server has SELinux enabled then accessing files and executables is SEVERELY restricted. Safe Mode also adds access restrictions as well.

In many cases PHP is limited to accessing directories in the webroot. This is especially true on servers offering virtual hosting. Most do not like anyone having access to executables via PHP and block most of it. :)
Post Reply