Hi all.
I have an error im my apache's error.log saying:
Code:
/bin/grep: writing output: Broken pipe
I've traced the source of the problem to this line:
Code:
shell_exec("/bin/netstat -e -p --tcp -n 2> /dev/null | /bin/grep -v root | /bin/grep -v 127.0.0.1 | /bin/grep -cE '.*(python|transmissionc|wget|nzbperl|java).*'");
I replaced (just for test) the upper line with:
Code:
shell_exec("ls | ls | ls | ls");
and now I get:
Code:
ls: write error: Broken pipe
My conclusion was that something is wrong with PHP handling pipes or some linux's security feature is preventing php script to execute that pipe, because when I try the same from shell, I don't get such errors.
I've tried with
su -c "ls | ls | ls | ls" www-data and also with
su - www-data followed with
ls | ls | ls | ls without errors.
I also get the same error if I make a test.php file containing just:
Code:
<?
shell_exec('ls | ls | ls | ls');
and running it with
php -f test.php 2>&1, gave me the same error:
Code:
# php -f test.php 2>&1
ls: write error: Broken pipe
(I even tried with just
ls | ls and it gave out the same error but not always (1 out of 6 tries).
Can you please just shoot out any idea that first gets to your mind of what the problem could actually be?
I have torrentflux-b4rt installed on my debian machine (stable, squeeze 6.0.3, "Linux ninja 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64 GNU/Linux") with apache web server (apache2 2.2.16-6+squeeze4) and php5 (libapache2-mod-php5 5.3.3-7+squeeze3) installed.
I'm not sure if I've chosen the correct forum, but I hope mods will point this out to me if I'm wrong.