finally removed super-old syscp-update-procedures, we now require the last available syscp for upgrading; migrate some functions to PDO database class, refs #1287
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -20,101 +20,33 @@
|
||||
/**
|
||||
* Wrapper around the exec command.
|
||||
*
|
||||
* @author Martin Burchert <eremit@adm1n.de>
|
||||
* @version 1.2
|
||||
* @param string exec_string String to be executed
|
||||
*
|
||||
* @return string The result of the exec()
|
||||
*
|
||||
* History:
|
||||
* 1.0 : Initial Version
|
||||
* 1.1 : Added |,&,>,<,`,*,$,~,? as security breaks.
|
||||
* 1.2 : Removed * as security break
|
||||
*/
|
||||
function safe_exec($exec_string, &$return_value = false) {
|
||||
|
||||
function safe_exec($exec_string, &$return_value = false)
|
||||
{
|
||||
global $settings, $theme;
|
||||
|
||||
//
|
||||
// define allowed system commands
|
||||
//
|
||||
|
||||
$allowed_commands = array(
|
||||
'touch',
|
||||
'chown',
|
||||
'mkdir',
|
||||
'webalizer',
|
||||
'cp',
|
||||
'du',
|
||||
'chmod',
|
||||
'chattr',
|
||||
'chflags', /* freebsd equivalent to linux' chattr */
|
||||
$settings['system']['apachereload_command'],
|
||||
$settings['system']['bindreload_command'],
|
||||
$settings['dkim']['dkimrestart_command'],
|
||||
'openssl',
|
||||
'unzip',
|
||||
'php',
|
||||
'rm',
|
||||
'awstats_buildstaticpages.pl',
|
||||
'ln'
|
||||
);
|
||||
|
||||
//
|
||||
// check for ; in execute command
|
||||
//
|
||||
|
||||
if((stristr($exec_string, ';'))
|
||||
or (stristr($exec_string, '|'))
|
||||
or (stristr($exec_string, '&'))
|
||||
or (stristr($exec_string, '>'))
|
||||
or (stristr($exec_string, '<'))
|
||||
or (stristr($exec_string, '`'))
|
||||
or (stristr($exec_string, '$'))
|
||||
or (stristr($exec_string, '~'))
|
||||
or (stristr($exec_string, '?')))
|
||||
{
|
||||
// check for bad signs in execute command
|
||||
if ((stristr($exec_string, ';'))
|
||||
|| (stristr($exec_string, '|'))
|
||||
|| (stristr($exec_string, '&'))
|
||||
|| (stristr($exec_string, '>'))
|
||||
|| (stristr($exec_string, '<'))
|
||||
|| (stristr($exec_string, '`'))
|
||||
|| (stristr($exec_string, '$'))
|
||||
|| (stristr($exec_string, '~'))
|
||||
|| (stristr($exec_string, '?'))
|
||||
) {
|
||||
die('SECURITY CHECK FAILED!' . "\n" . 'The execute string "' . htmlspecialchars($exec_string) . '" is a possible security risk!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* This is not needed anymore, we allow all commands and just check for pipes and stuff
|
||||
//
|
||||
// check if command is allowed here
|
||||
//
|
||||
|
||||
$ok = false;
|
||||
foreach($allowed_commands as $allowed_command)
|
||||
{
|
||||
if(strpos($exec_string, $allowed_command) === 0
|
||||
&& (strlen($exec_string) === ($allowed_command_pos = strlen($allowed_command)) || substr($exec_string, $allowed_command_pos, 1) === ' '))
|
||||
{
|
||||
$ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$ok)
|
||||
{
|
||||
die('SECURITY CHECK FAILED!' . "\n" . 'Your command "' . htmlspecialchars($exec_string) . '" is not allowed!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
// execute the command and return output
|
||||
//
|
||||
// --- martin @ 08.08.2005 -------------------------------------------------------
|
||||
// fixing usage of uninitialised variable
|
||||
|
||||
$return = '';
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
if($return_value == false)
|
||||
{
|
||||
if ($return_value == false) {
|
||||
exec($exec_string, $return);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
exec($exec_string, $return, $return_value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user