From 94ec1de54a0815b756e2d9c021e8ef0b27e13fcc Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 1 Jun 2015 07:55:41 +0200 Subject: [PATCH] src: no hay pcntl --- src/etc/inc/util.inc | 19 +++--------- src/etc/rc.php_ini_setup | 2 +- .../mvc/app/library/OPNsense/Core/Shell.php | 31 ++++++------------- .../app/models/OPNsense/CaptivePortal/ARP.php | 2 +- .../OPNsense/CaptivePortal/CPClient.php | 24 +++++++------- src/www/system_firmware_check.php | 4 +-- .../widgets/system_information.widget.php | 2 +- 7 files changed, 33 insertions(+), 51 deletions(-) diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index 73133cb30..7de086635 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -986,7 +986,7 @@ function exec_command($command) { } /* wrapper for mwexec() ;) */ -function mwexecf($format, $args = array(), $mute = false, $clearsigmask = false) +function mwexecf($format, $args = array(), $mute = false) { if (!is_array($args)) { /* just in case there's only one argument */ @@ -997,27 +997,18 @@ function mwexecf($format, $args = array(), $mute = false, $clearsigmask = false) $args[$id] = escapeshellarg($arg); } - return mwexec(vsprintf($format, $args), $mute, $clearsigmask); + return mwexec(vsprintf($format, $args), $mute); } /* wrapper for exec() */ -function mwexec($command, $mute = false, $clearsigmask = false) +function mwexec($command, $mute = false) { $oarr = array(); $retval = 0; - if ($clearsigmask) { - $oldset = array(); - pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); - } - $garbage = exec("{$command} 2>&1", $oarr, $retval); unset($garbage); - if ($clearsigmask) { - pcntl_sigprocmask(SIG_SETMASK, $oldset); - } - if ($retval != 0 && $mute == false) { $output = implode(' ', $oarr); log_error(sprintf(gettext("The command '%s' returned exit code '%d', the output was '%s'"), $command, $retval, $output)); @@ -1030,9 +1021,9 @@ function mwexec($command, $mute = false, $clearsigmask = false) } /* wrapper for exec() in background */ -function mwexec_bg($command, $mute = false, $clearsigmask = false) +function mwexec_bg($command, $mute = false) { - mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask); + mwexec("/usr/sbin/daemon -f {$command}", $mute); } /* make a global alias table (for faster lookups) */ diff --git a/src/etc/rc.php_ini_setup b/src/etc/rc.php_ini_setup index 31b04dd3f..bc42e4d27 100755 --- a/src/etc/rc.php_ini_setup +++ b/src/etc/rc.php_ini_setup @@ -42,7 +42,7 @@ PHPMODULES="$PHPMODULES curl" # Internationalization PHPMODULES="$PHPMODULES gettext" # User manager -PHPMODULES="$PHPMODULES ldap openssl pcntl" +PHPMODULES="$PHPMODULES ldap openssl" PHPMODULES="$PHPMODULES hash mcrypt" # Login sessions PHPMODULES="$PHPMODULES session" diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php b/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php index e818442f2..618e535a0 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Shell.php @@ -1,4 +1,5 @@ execSingle($comm, $mute, $clearsigmask, $output); - } - } else { - $this->execSingle($command, $mute, $clearsigmask, $output); - } + if (!is_array($command)) { + $command = array($command); + } + foreach ($command as $comm) { + $this->execSingle($comm, $mute, $output); + } } /** * execute shell command * @param string $command command to execute * @param bool $mute - * @param bool $clearsigmask * @param Array() &$output * @return int */ - private function execSingle($command, $mute = false, $clearsigmask = false, &$output = null) + private function execSingle($command, $mute = false, &$output = null) { $oarr = array(); $retval = 0; @@ -100,11 +99,6 @@ class Shell // only execute actual command if not in simulation mode if (!$this->simulate) { - if ($clearsigmask) { - $oldset = array(); - pcntl_sigprocmask(SIG_SETMASK, array(), $oldset); - } - exec("$command 2>&1", $output, $retval); if (($retval <> 0) && ($mute === false)) { @@ -114,11 +108,6 @@ class Shell unset($output); } - - if ($clearsigmask) { - pcntl_sigprocmask(SIG_SETMASK, $oldset); - } - unset($oarr); return $retval; } diff --git a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php index 434e794c5..0f78474e1 100644 --- a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php +++ b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php @@ -86,7 +86,7 @@ class ARP $result = array(); $shell_output = array(); // execute arp shell command and collect (only valid) info into named array - if ($this->shell->exec("arp -an", false, false, $shell_output) == 0) { + if ($this->shell->exec('arp -an', false, $shell_output) == 0) { foreach ($shell_output as $line) { $line_parts = explode(" ", $line); if (sizeof($line_parts) >= 4) { diff --git a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php index b278eda70..7f4f5367e 100644 --- a/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php +++ b/src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php @@ -1,4 +1,5 @@ shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // update administration $db->upsertFixedIP($ip, $pipeno_in, $pipeno_out); // save bandwidth data @@ -211,7 +213,7 @@ class CPClient ); // execute all ipfw actions - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // TODO : cleanup $record->pipeno_in, $record->pipeno_out ; $db->dropFixedIP($ip); } @@ -311,7 +313,7 @@ class CPClient ); // execute all ipfw actions - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // update administration $db->upsertPassthruMAC( $tagcontent->mac, @@ -334,7 +336,7 @@ class CPClient "/sbin/ipfw table ". $ipfw_tables["out"] . " add " . $arp_maclist[$mac]['ip']. " " . $pipeno_out, ); - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); $db->upsertPassthruMAC( $tagcontent->mac, @@ -364,7 +366,7 @@ class CPClient "/sbin/ipfw table ". $ipfw_tables["out"] . " delete ". $db_maclist[$mac]->ip, ); - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // TODO : cleanup $record->pipeno_in, $record->pipeno_out ; $db->dropPassthruMAC($mac); } @@ -410,7 +412,7 @@ class CPClient // TODO: check processing speed, this might need some improvement // check if our ip is already in the list and collect first free rule number to place it there if necessary $shell_output=array(); - $this->shell->exec("/sbin/ipfw show", false, false, $shell_output); + $this->shell->exec('/sbin/ipfw show', false, $shell_output); $prev_id = 0; $new_id = null; foreach ($shell_output as $line) { @@ -442,7 +444,7 @@ class CPClient ); // execute all ipfw actions - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); } } @@ -559,7 +561,7 @@ class CPClient // add commands for access tables, and execute all collected $exec_commands[] = "/sbin/ipfw table ". $ipfw_tables["in"] ." add ". $clientip . " ".$pipeno_in; $exec_commands[] = "/sbin/ipfw table ". $ipfw_tables["out"] ." add ". $clientip . " ".$pipeno_out; - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // lock the user/ip to it's MAC address using arp $arp->setStatic($clientip, $clientmac); @@ -633,7 +635,7 @@ class CPClient "/sbin/ipfw -f table ".$this->rules->getAuthMACTables($zoneid)["out"]." flush", "/sbin/ipfw delete set ".$zoneid, ); - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); } } } @@ -725,7 +727,7 @@ class CPClient $filter_cmd =" | /usr/bin/grep ' " . $ipaddr ." '" ; } - if ($this->shell->exec("/sbin/ipfw -aT list ".$filter_cmd, false, false, $shell_output) == 0) { + if ($this->shell->exec("/sbin/ipfw -aT list ".$filter_cmd, false, $shell_output) == 0) { foreach ($shell_output as $line) { if (strpos($line, ' count ip from') !== false) { $parts = preg_split('/\s+/', $line); @@ -790,7 +792,7 @@ class CPClient // only handle disconnect if we can find a client in our database $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["in"] . " delete " . $db_clients[0]->ip; $exec_commands[] = "/sbin/ipfw table " . $ipfw_tables["out"] . " delete " . $db_clients[0]->ip; - $this->shell->exec($exec_commands, false, false); + $this->shell->exec($exec_commands); // TODO: cleanup dummynet pipes $db_clients[0]->pipeno_in/out // TODO: log removal // ( was : captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "DISCONNECT");) diff --git a/src/www/system_firmware_check.php b/src/www/system_firmware_check.php index 8794d8673..97c5466a2 100644 --- a/src/www/system_firmware_check.php +++ b/src/www/system_firmware_check.php @@ -55,13 +55,13 @@ if (file_exists($file_pkg_status)) { if ($_POST['action'] == 'pkg_upgrade') { // execute shell command and collect (only valid) info into named array $cmd = '/usr/sbin/daemon -f /usr/local/opnsense/scripts/pkg_upgrade.sh ' . escapeshellarg($package); - $shell->exec($cmd, false, false, $shell_output); + $shell->exec($cmd, false, $shell_output); exit; } if ($_POST['action'] == 'pkg_update') { // execute shell command and collect (only valid) info into named array - $shell->exec('/usr/local/opnsense/scripts/pkg_updatecheck.sh', false, false, $shell_output); + $shell->exec('/usr/local/opnsense/scripts/pkg_updatecheck.sh', false, $shell_output); } if ($_POST['action'] == 'update_status') { diff --git a/src/www/widgets/widgets/system_information.widget.php b/src/www/widgets/widgets/system_information.widget.php index b94a49c19..bb1565d7c 100644 --- a/src/www/widgets/widgets/system_information.widget.php +++ b/src/www/widgets/widgets/system_information.widget.php @@ -42,7 +42,7 @@ if ($_POST['action'] == 'pkg_update') { $shell_output = array(); $shell = new OPNsense\Core\Shell(); // execute shell command and collect (only valid) info into named array - $shell->exec("/usr/local/opnsense/scripts/pkg_updatecheck.sh", false, false, $shell_output); + $shell->exec('/usr/local/opnsense/scripts/pkg_updatecheck.sh', false, $shell_output); } if (file_exists($file_pkg_status)) {