Welcome Guest, Not a member yet? Register   Sign In
exec in PHP
#1

[eluser]Guntars[/eluser]
Hi
I have Debian Linux VPS
For some reason function exec not works on my server, I can't execute files, but when I type this function, and type print_r becomes an empty array.
Then I try to put this
Code:
if(function_exists(exec)){echo 'function exists';}
else{echo 'function not exists';}

Come back as function not exists
Any ideas how to I can enable exec function, in php.in I can't find anything about disable this function.
#2

[eluser]jedd[/eluser]
It'll be your safe_mode_exec_dir setting in your php.ini.

If you don't have a real machine, but are hosted instead, you may not have access to change this.

Oh, do a phpinfo.php page and look for the two relevant settings: safe_mode (bool) and safe_mode_exec_dir (string)
#3

[eluser]Guntars[/eluser]
Here is my phpinfo Safe mode is off. Snything else need to check.
#4

[eluser]jedd[/eluser]
So if you go down to this line:
Code:
safe_mode_exec_dir          /usr/lib/php5/libexec         /usr/lib/php5/libexec

You can see that you have safe_mode_exec_dir enabled, so only files located in that directory can be exec()'d.

If you have ssh access to that box, try copying some binary - /bin/ls for example - into there, and then do an exec ('ls') through PHP.
#5

[eluser]Guntars[/eluser]
When I copy to this directory it works, you recomend me leave as it is, and just, which functions need to execute copy here, or change the directory?
#6

[eluser]jedd[/eluser]
[quote author="Guntars" date="1245193782"]When I copy to this directory it works[/quote]

Is that a confirmation or a follow-up question?

Quote:, you recomend me leave as it is, and just, which functions need to execute copy here, or change the directory?

You have a range of options. Modify the PHP setting to allow you to run binaries from anywhere, or maintain a set of binaries (or symlinks to same) in that directory.

On my own system I use the former, though a) I don't use exec calls very often, b) I'm very cautious. It's probably one of those 'if you have to ask how this works, then choose the safer option'. My gut feel here is that you should proceed with maintaining the directory's contents with binaries that you trust, and (obviously) retain the safe exec setting as it is.
#7

[eluser]Guntars[/eluser]
Thank's a lot.
I don't use exec function often as well. That's means If I need some exec files, just copy in current directory.
#8

[eluser]newbie boy[/eluser]
i have the same problem with this...

see, i'm hoping to run a ffmpeg on which i put on my safe_mode_exec_dir...

but still doesn't gives out an ouput...

hope you could me guys...

thanks...
#9

[eluser]newbie boy[/eluser]
someone, guys?
#10

[eluser]Guntars[/eluser]
Can you write bit more about your problem?




Theme © iAndrew 2016 - Forum software by © MyBB