mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 16:14:40 +00:00
src: no hay pcntl
This commit is contained in:
parent
fb97ab7c6d
commit
94ec1de54a
@ -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) */
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
*
|
||||
@ -26,6 +27,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Core;
|
||||
|
||||
use \Phalcon\DI\FactoryDefault;
|
||||
@ -65,30 +67,27 @@ class Shell
|
||||
*
|
||||
* @param string/Array() $command command to execute
|
||||
* @param bool $mute
|
||||
* @param bool $clearsigmask
|
||||
* @param Array() &$output
|
||||
*/
|
||||
public function exec($command, $mute = false, $clearsigmask = false, &$output = null)
|
||||
public function exec($command, $mute = false, &$output = null)
|
||||
{
|
||||
if (is_array($command)) {
|
||||
foreach ($command as $comm) {
|
||||
$this->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;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
*
|
||||
@ -26,6 +27,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\CaptivePortal;
|
||||
|
||||
use \Phalcon\Logger\Adapter\Syslog;
|
||||
@ -183,7 +185,7 @@ class CPClient
|
||||
);
|
||||
|
||||
// execute all ipfw actions
|
||||
$this->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");)
|
||||
|
||||
@ -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') {
|
||||
|
||||
@ -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)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user