This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

PHP exec() and shell_exec() functions cause hanging
#1
PHP exec() and shell_exec() functions cause hanging
Hi guys,

I'm having a problem with the PHP functions exec() and shell_exec(). Nothing in the php after the exec will execute. Even a simple 
PHP Code:
exec("echo 'hello'"); 

causes it.

Things that could be the problem, and what I've tried:
  • The apache user may not have sufficient permissions. Though as the root user I did run 
    sudo -H -u www-data bash -c 'echo "I am $USER, with uid $UID"'
which worked fine.
  • The exec functions may still be blocked somehow, even though I have already erased everything in the disable_functions entry in  /etc/php5/apache2/php.ini, and restarted apache2:
[Image: 2be9c41387.png]

I've also tried including 'sudo', like exec("sudo echo 'hello'"); , but it didn't make a difference.

The problem only occurs on my DigitalOcean server that's running Ubuntu 12.04 with Sentora. On my local copy of the website, which is ran on Windows 10, I don't have this problem.

Edit: I'm aware that it's not great to use exec() as it leaves the website vulnerable. The reason why I'm using it is because my website works like this: User uploads an image, and a program written in C++ (on the server) runs on the image, extracting information. The information is then stored in a database, and the image is deleted. So, I use exec() to get the C++ program to run on the image. Is there a smarter way to go about doing this?

Any help would be appreciated. Thank you for your time!
Reply
Thanks given by: angelorocha
#2
RE: PHP exec() and shell_exec() functions cause hanging
That is because they are disabled for security purposes. You could try disabling suhosin for that domain only.
Module Admin > Apache Config > Override a virtual host > [select domain] >uncheck Suhosin box > Save > wait ~5 mins for daemon to run and update the httpd-vhosts.conf and try again.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by: steve_nf , angelorocha
#3
RE: PHP exec() and shell_exec() functions cause hanging
(08-11-2015, 04:15 AM)TGates Wrote: That is because they are disabled for security purposes. You could try disabling suhosin for that domain only.
Module Admin > Apache Config > Override a virtual host > [select domain] >uncheck Suhosin box > Save > wait ~5 mins for daemon to run and update the httpd-vhosts.conf and try again.

Thanks! This solved it.
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
shell_exec worksmarter 1 4 ,240 01-16-2018, 01:39 AM
Last Post: Ron-e
PHP exec disabled - problem enabling. asobiek 2 8 ,459 07-07-2016, 05:33 AM
Last Post: Me.B
PHP disable functions sunardi 9 35 ,103 04-11-2016, 07:53 PM
Last Post: Kevvo

Forum Jump:


Users browsing this thread: 2 Guest(s)