Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
94ec1de5
Commit
94ec1de5
authored
Jun 01, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: no hay pcntl
parent
fb97ab7c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
51 deletions
+33
-51
util.inc
src/etc/inc/util.inc
+5
-14
rc.php_ini_setup
src/etc/rc.php_ini_setup
+1
-1
Shell.php
src/opnsense/mvc/app/library/OPNsense/Core/Shell.php
+10
-21
ARP.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php
+1
-1
CPClient.php
...nsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php
+13
-11
system_firmware_check.php
src/www/system_firmware_check.php
+2
-2
system_information.widget.php
src/www/widgets/widgets/system_information.widget.php
+1
-1
No files found.
src/etc/inc/util.inc
View file @
94ec1de5
...
...
@@ -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) */
...
...
src/etc/rc.php_ini_setup
View file @
94ec1de5
...
...
@@ -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"
...
...
src/opnsense/mvc/app/library/OPNsense/Core/Shell.php
View file @
94ec1de5
<?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
;
}
...
...
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php
View file @
94ec1de5
...
...
@@ -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
)
{
...
...
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php
View file @
94ec1de5
<?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");)
...
...
src/www/system_firmware_check.php
View file @
94ec1de5
...
...
@@ -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'
)
{
...
...
src/www/widgets/widgets/system_information.widget.php
View file @
94ec1de5
...
...
@@ -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
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment