Project

General

Profile

Actions

Bug #2496

closed

The use of php exec() and php system() with pipe '|' will fail if the first output of a os command is long enough.

Added by robert zelaya almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Operating System
Target version:
Start date:
06/14/2012
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.1
Affected Architecture:
All

Description

System:

uname -a

FreeBSD pfSense.localdomain 8.3-RELEASE-p2 FreeBSD 8.3-RELEASE-p2 #0: Mon Jun 11 02:55:34 EDT 2012
root@FreeBSD_8.3_pfSense_2.1.snaps.pfsense.org:/usr/obj./usr/pfSensesrc/src/sys/pfSense_SMP.8 amd64

Problem:

The use of php exec() and php system() with pipe '|' will fail if the first output of a os command is long enough.
Moreover, if the the output of the first os cmd grows over time (memory) you might see this on edge cases.

Example:

/* checks to see if barnyard2 is running yes/no */
function Running_Ck_b($snort_uuid, $if_real, $id) {

$option1 = shell_exec("pgrep -f 'barnyard.*{$snort_uuid}_{$if_real}'"); // pass
$option2 = exec("/bin/ps -aux | /usr/bin/grep -v grep | /usr/bin/grep -E 'barnyard2.*snort_49127_em0' | /usr/bin/awk '{print \$1;}'"); // fail
$option3 = exec("/bin/ps -aux | /usr/bin/grep 'lighttpd'"); // fail
$option4 = passthru("/bin/ps -aux"); // pass
return $option4;
}

Notes:

All code using FreeBSD '|' cmd should be reviewed. Thankfully there is not much code to fix.

Robert

Actions #1

Updated by Chris Buechler almost 12 years ago

  • Status changed from New to Feedback

Not sure what you're seeing, but none of us can replicate that with the exact same thing you're doing substituting different processes for barnyard. If this were true we'd have other things broken that work fine. Seriously doubt the problem described here exists, likely it's somewhere else in your code.

Actions #2

Updated by robert zelaya almost 12 years ago

Hi Chris

I don't know why you guys can't reproduce this.

The code is being watched live through Xdebug v2.1.3 and I can not see exec returning anything.
Also, tested this issue with a empty file with only the above function.

My setup:

VMware workstation:
x64
512 mb

Robert

Actions #3

Updated by Ermal Luçi almost 12 years ago

Maybe xdebug issue or something else.

Actions #4

Updated by Chris Buechler over 11 years ago

  • Status changed from Feedback to Closed

the issue as described doesn't really exist.

Actions

Also available in: Atom PDF