use safe_exec from class now

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-19 17:19:56 +01:00
parent c4024c8107
commit 549ccda166
17 changed files with 85 additions and 86 deletions

View File

@@ -356,12 +356,12 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$perlsymlink = \Froxlor\FileDir::makeCorrectFile($result['path'] . '/cgi-bin');
// remove symlink
if (file_exists($perlsymlink)) {
safe_exec('rm -f ' . escapeshellarg($perlsymlink));
\Froxlor\FileDir::safe_exec('rm -f ' . escapeshellarg($perlsymlink));
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_DEBUG, "[API] deleted suexecworkaround symlink '" . $perlsymlink . "'");
}
// remove folder in suexec-path
if (file_exists($suexecpath)) {
safe_exec('rm -rf ' . escapeshellarg($suexecpath));
\Froxlor\FileDir::safe_exec('rm -rf ' . escapeshellarg($suexecpath));
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_DEBUG, "[API] deleted suexecworkaround path '" . $suexecpath . "'");
}
}

View File

@@ -33,7 +33,7 @@ class Bind extends DnsBase
// check for subfolder in bind-config-directory
if (! file_exists(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
$this->_logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
}
$domains = $this->getDomainList();

View File

@@ -170,7 +170,7 @@ abstract class DnsBase
// reload DNS daemon
$cmd = Settings::Get('system.bindreload_command');
$cmdStatus = 1;
safe_exec(escapeshellcmd($cmd), $cmdStatus);
\Froxlor\FileDir::safe_exec(escapeshellcmd($cmd), $cmdStatus);
if ($cmdStatus === 0) {
$this->_logger->logAction(CRON_ACTION, LOG_INFO, Settings::Get('system.dns_server') . ' daemon reloaded');
} else {
@@ -183,7 +183,7 @@ abstract class DnsBase
if (Settings::Get('dkim.use_dkim') == '1') {
if (! file_exists(\Froxlor\FileDir::makeCorrectDir(Settings::Get('dkim.dkim_prefix')))) {
$this->_logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('dkim.dkim_prefix'))));
}
$dkimdomains = '';
@@ -203,13 +203,13 @@ abstract class DnsBase
$max_dkim_id = $max_dkim_id_stmt->fetch(\PDO::FETCH_ASSOC);
$domain['dkim_id'] = (int) $max_dkim_id['max_dkim_id'] + 1;
$privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']);
safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength'));
\Froxlor\FileDir::safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength'));
$domain['dkim_privkey'] = file_get_contents($privkey_filename);
safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
\Froxlor\FileDir::safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
$pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public');
safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename));
\Froxlor\FileDir::safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename));
$domain['dkim_pubkey'] = file_get_contents($pubkey_filename);
safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));
\Froxlor\FileDir::safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
`dkim_id` = :dkimid,
@@ -230,14 +230,14 @@ abstract class DnsBase
$privkey_file_handler = fopen($privkey_filename, "w");
fwrite($privkey_file_handler, $domain['dkim_privkey']);
fclose($privkey_file_handler);
safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
\Froxlor\FileDir::safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
}
if (! file_exists($pubkey_filename) && $domain['dkim_pubkey'] != '') {
$pubkey_file_handler = fopen($pubkey_filename, "w");
fwrite($pubkey_file_handler, $domain['dkim_pubkey']);
fclose($pubkey_file_handler);
safe_exec("chmod 0644 " . escapeshellarg($pubkey_filename));
\Froxlor\FileDir::safe_exec("chmod 0644 " . escapeshellarg($pubkey_filename));
}
$dkimdomains .= $domain['domain'] . "\n";
@@ -253,7 +253,7 @@ abstract class DnsBase
fwrite($dkimkeys_file_handler, $dkimkeys);
fclose($dkimkeys_file_handler);
safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
\Froxlor\FileDir::safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command')));
$this->_logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded');
}
}

View File

@@ -66,7 +66,7 @@ class DomainSSL
$sslcertpath = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.customer_ssl_path'));
// create path if it does not exist
if (! file_exists($sslcertpath)) {
safe_exec('mkdir -p ' . escapeshellarg($sslcertpath));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($sslcertpath));
}
// make correct files for the certificates
$ssl_files = array(

View File

@@ -20,10 +20,9 @@ use Froxlor\Cron\Http\Php\PhpInterface;
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
*
* @todo ssl-redirect to non-standard port
*/
class Lighttpd extends HttpConfigBase
{
@@ -63,11 +62,11 @@ class Lighttpd extends HttpConfigBase
Fpm::createDummyPool($restart_cmd['config_dir']);
}
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: running ' . $restart_cmd['reload_cmd']);
safe_exec(escapeshellcmd($restart_cmd['reload_cmd']));
\Froxlor\FileDir::safe_exec(escapeshellcmd($restart_cmd['reload_cmd']));
}
}
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'lighttpd::reload: reloading lighttpd');
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
\Froxlor\FileDir::safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
}
public function createIpPort()
@@ -128,12 +127,12 @@ class Lighttpd extends HttpConfigBase
}
}
if (!$is_redirect) {
if (! $is_redirect) {
/**
* dirprotection, see #72
*
* @todo use better regex for this, deferred until 0.9.5
*
*
* $this->lighttpd_data[$vhost_filename].= ' $HTTP["url"] =~ "^/(.+)\/(.+)\.php" {' . "\n";
* $this->lighttpd_data[$vhost_filename].= ' url.access-deny = ("")' . "\n";
* $this->lighttpd_data[$vhost_filename].= ' }' . "\n";
@@ -211,10 +210,10 @@ class Lighttpd extends HttpConfigBase
if ($row_ipsandports['ssl'] == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
if (! file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
$this->logger->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "'.Settings::Get('system.ssl_cert_file').'" does not seem to exist. Disabling SSL-vhost for "'.Settings::Get('system.hostname').'"');
$this->logger->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
}
}
@@ -229,7 +228,7 @@ class Lighttpd extends HttpConfigBase
'loginname' => 'froxlor.panel',
'documentroot' => $mypath,
'customerroot' => $mypath,
'parentdomainid' => 0,
'parentdomainid' => 0
);
// override corresponding array values
@@ -253,10 +252,10 @@ class Lighttpd extends HttpConfigBase
} else {
$this->lighttpd_data[$vhost_filename] .= 'ssl.engine = "enable"' . "\n";
$this->lighttpd_data[$vhost_filename] .= 'ssl.use-compression = "disable"' . "\n";
if (!empty(Settings::Get('system.dhparams_file'))) {
if (! empty(Settings::Get('system.dhparams_file'))) {
$dhparams = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.dhparams_file'));
if (!file_exists($dhparams)) {
safe_exec('openssl dhparam -out '.escapeshellarg($dhparams).' 4096');
if (! file_exists($dhparams)) {
\Froxlor\FileDir::safe_exec('openssl dhparam -out ' . escapeshellarg($dhparams) . ' 4096');
}
$this->lighttpd_data[$vhost_filename] .= 'ssl.dh-file = "' . $dhparams . '"' . "\n";
$this->lighttpd_data[$vhost_filename] .= 'ssl.ec-curve = "secp384r1"' . "\n";
@@ -392,7 +391,7 @@ class Lighttpd extends HttpConfigBase
foreach ($domains as $domain) {
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost') . '/vhosts/')));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost') . '/vhosts/')));
// determine correct include-path:
// e.g. '/etc/lighttpd/conf-enabled/vhosts/ has to become'
@@ -404,10 +403,10 @@ class Lighttpd extends HttpConfigBase
// maindomain
if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) {
$vhost_no = '50';
} // sub-but-main-domain
} // sub-but-main-domain
elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) {
$vhost_no = '51';
} // subdomains
} // subdomains
else {
// number of dots in a domain specifies it's position (and depth of subdomain) starting at 89 going downwards on higher depth
$vhost_no = (string) (90 - substr_count($domain['domain'], ".") + 1);
@@ -486,7 +485,7 @@ class Lighttpd extends HttpConfigBase
// Get domain's redirect code
$code = getDomainRedirectCode($domain['id']);
$vhost_content .= ' url.redirect-code = ' . $code. "\n";
$vhost_content .= ' url.redirect-code = ' . $code . "\n";
$vhost_content .= ' url.redirect = (' . "\n";
$vhost_content .= ' "^/(.*)$" => "' . $uri . '$1"' . "\n";
$vhost_content .= ' )' . "\n";
@@ -559,10 +558,10 @@ class Lighttpd extends HttpConfigBase
if ($ssl_vhost === true && $domain['ssl'] == '1' && (int) Settings::Get('system.use_ssl') == 1) {
if ($domain['ssl_cert_file'] == '') {
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($domain['ssl_cert_file'])) {
if (! file_exists($domain['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$domain['ssl_cert_file'] = "";
$this->logger->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "'.Settings::Get('system.ssl_cert_file').'" does not seem to exist. Disabling SSL-vhost for "'.$domain['domain'].'"');
$this->logger->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
}
}
@@ -573,12 +572,12 @@ class Lighttpd extends HttpConfigBase
if ($domain['ssl_cert_file'] != '') {
// ssl.engine only necessary once in the ip/port vhost (SERVER['socket'] condition)
//$ssl_settings .= 'ssl.engine = "enable"' . "\n";
// $ssl_settings .= 'ssl.engine = "enable"' . "\n";
$ssl_settings .= 'ssl.use-compression = "disable"' . "\n";
if (!empty(Settings::Get('system.dhparams_file'))) {
if (! empty(Settings::Get('system.dhparams_file'))) {
$dhparams = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.dhparams_file'));
if (!file_exists($dhparams)) {
safe_exec('openssl dhparam -out '.escapeshellarg($dhparams).' 4096');
if (! file_exists($dhparams)) {
\Froxlor\FileDir::safe_exec('openssl dhparam -out ' . escapeshellarg($dhparams) . ' 4096');
}
$ssl_settings .= 'ssl.dh-file = "' . $dhparams . '"' . "\n";
$ssl_settings .= 'ssl.ec-curve = "secp384r1"' . "\n";
@@ -927,10 +926,10 @@ class Lighttpd extends HttpConfigBase
} else {
$stats_text .= ' alias.url = ( "/webalizer/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['customerroot'] . '/webalizer/') . '" )' . "\n";
}
} // if the docroots are equal, we still have to set an alias for awstats
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
} // if the docroots are equal, we still have to set an alias for awstats
// because the stats are in /awstats/[domain], not just /awstats/
// also, the awstats-icons are someplace else too!
// -> webalizer does not need this!
elseif (Settings::Get('system.awstats_enabled') == '1') {
$stats_text .= ' alias.url = ( "/awstats/" => "' . \Froxlor\FileDir::makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '" )' . "\n";
$stats_text .= ' alias.url += ( "/awstats-icon" => "' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_icons')) . '" )' . "\n";
@@ -970,7 +969,7 @@ class Lighttpd extends HttpConfigBase
} else {
if (! file_exists(Settings::Get('system.apacheconf_vhost'))) {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
\Froxlor\FileDir::safe_exec('mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost

View File

@@ -126,7 +126,7 @@ class LighttpdFcgi extends Lighttpd
// all the files and folders have to belong to the local user
// now because we also use fcgid for our own vhost
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
\Froxlor\FileDir::safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new PhpInterface($domain);

View File

@@ -72,19 +72,19 @@ class Nginx extends HttpConfigBase
Fpm::createDummyPool($restart_cmd['config_dir']);
}
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: running ' . $restart_cmd['reload_cmd']);
safe_exec(escapeshellcmd($restart_cmd['reload_cmd']));
\Froxlor\FileDir::safe_exec(escapeshellcmd($restart_cmd['reload_cmd']));
}
}
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: reloading nginx');
safe_exec(Settings::Get('system.apachereload_command'));
\Froxlor\FileDir::safe_exec(Settings::Get('system.apachereload_command'));
/**
* nginx does not auto-spawn fcgi-processes
*/
if (Settings::Get('system.phpreload_command') != '' && (int) Settings::Get('phpfpm.enabled') == 0) {
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'nginx::reload: restarting php processes');
safe_exec(Settings::Get('system.phpreload_command'));
\Froxlor\FileDir::safe_exec(Settings::Get('system.phpreload_command'));
}
}
@@ -339,7 +339,7 @@ class Nginx extends HttpConfigBase
foreach ($domains as $domain) {
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
$vhost_filename = $this->getVhostFilename($domain);
@@ -647,7 +647,7 @@ class Nginx extends HttpConfigBase
if (! empty(Settings::Get('system.dhparams_file'))) {
$dhparams = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.dhparams_file'));
if (! file_exists($dhparams)) {
safe_exec('openssl dhparam -out ' . escapeshellarg($dhparams) . ' 4096');
\Froxlor\FileDir::safe_exec('openssl dhparam -out ' . escapeshellarg($dhparams) . ' 4096');
}
$sslsettings .= 'ssl_dhparam ' . $dhparams . ';' . "\n";
}
@@ -1159,7 +1159,7 @@ class Nginx extends HttpConfigBase
} else {
if (! file_exists(Settings::Get('system.apacheconf_vhost'))) {
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'nginx::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}
// Write a single file for every vhost

View File

@@ -95,7 +95,7 @@ class NginxFcgi extends Nginx
// all the files and folders have to belong to the local user
// now because we also use fcgid for our own vhost
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
\Froxlor\FileDir::safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost
$php = new PhpInterface($domain);

View File

@@ -102,8 +102,8 @@ class Fcgid
$starter_file_handler = fopen($this->getStarterFile(), 'w');
fwrite($starter_file_handler, $starter_file);
fclose($starter_file_handler);
safe_exec('chmod 750 ' . escapeshellarg($this->getStarterFile()));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($this->getStarterFile()));
\Froxlor\FileDir::safe_exec('chmod 750 ' . escapeshellarg($this->getStarterFile()));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($this->getStarterFile()));
setImmutable($this->getStarterFile());
}
@@ -173,8 +173,8 @@ class Fcgid
$phpini_file_handler = fopen($this->getIniFile(), 'w');
fwrite($phpini_file_handler, $phpini_file);
fclose($phpini_file_handler);
safe_exec('chown root:0 ' . escapeshellarg($this->getIniFile()));
safe_exec('chmod 0644 ' . escapeshellarg($this->getIniFile()));
\Froxlor\FileDir::safe_exec('chown root:0 ' . escapeshellarg($this->getIniFile()));
\Froxlor\FileDir::safe_exec('chmod 0644 ' . escapeshellarg($this->getIniFile()));
}
/**
@@ -190,8 +190,8 @@ class Fcgid
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if (! is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
@@ -210,9 +210,9 @@ class Fcgid
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $this->_domain['loginname'] . '/');
if (! is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
}
return $tmpdir;

View File

@@ -290,7 +290,7 @@ class Fpm
$config = \Froxlor\FileDir::makeCorrectFile($configdir . '/' . $this->_domain['domain'] . '.conf');
if (! is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
}
return $config;
@@ -311,8 +311,8 @@ class Fpm
$socket = strtolower(\Froxlor\FileDir::makeCorrectFile($socketdir . '/' . $this->_domain['fpm_config_id'] . '-' . $this->_domain['loginname'] . '-' . $this->_domain['domain'] . '-php-fpm.socket'));
if (! is_dir($socketdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($socketdir));
safe_exec('chown -R ' . Settings::Get('system.httpuser') . ':' . Settings::Get('system.httpgroup') . ' ' . escapeshellarg($socketdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($socketdir));
\Froxlor\FileDir::safe_exec('chown -R ' . Settings::Get('system.httpuser') . ':' . Settings::Get('system.httpgroup') . ' ' . escapeshellarg($socketdir));
}
return $socket;
@@ -331,9 +331,9 @@ class Fpm
$tmpdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->_domain['loginname'] . '/');
if (! is_dir($tmpdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
\Froxlor\FileDir::safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
}
return $tmpdir;
@@ -357,8 +357,8 @@ class Fpm
$configdir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.aliasconfigdir') . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if (! is_dir($configdir) && $createifnotexists) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
@@ -373,7 +373,7 @@ class Fpm
public static function createDummyPool($configdir)
{
if (! is_dir($configdir)) {
safe_exec('mkdir -p ' . escapeshellarg($configdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($configdir));
}
$config = \Froxlor\FileDir::makeCorrectFile($configdir . '/dummy.conf');
$dummy = "[dummy]

View File

@@ -28,7 +28,7 @@ class MailboxsizeCron extends \Froxlor\Cron\FroxlorCron
$maildirs_stmt = \Froxlor\Database\Database::query("
SELECT `id`, CONCAT(`homedir`, `maildir`) AS `maildirpath` FROM `" . TABLE_MAIL_USERS . "` ORDER BY `id`
");
$upd_stmt = \Froxlor\Database\Database::prepare("
UPDATE `" . TABLE_MAIL_USERS . "` SET `mboxsize` = :size WHERE `id` = :id
");
@@ -40,7 +40,7 @@ class MailboxsizeCron extends \Froxlor\Cron\FroxlorCron
if (file_exists($_maildir) && is_dir($_maildir)) {
// mail-address allows many special characters, see http://en.wikipedia.org/wiki/Email_address#Local_part
$return = false;
$back = safe_exec('du -sk ' . escapeshellarg($_maildir), $return, array(
$back = \Froxlor\FileDir::safe_exec('du -sk ' . escapeshellarg($_maildir), $return, array(
'|',
'&',
'`',

View File

@@ -373,7 +373,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// Use the old fashioned way with "du"
if (file_exists($row['documentroot']) && is_dir($row['documentroot'])) {
$back = safe_exec('du -sk ' . escapeshellarg($row['documentroot']) . '');
$back = \Froxlor\FileDir::safe_exec('du -sk ' . escapeshellarg($row['documentroot']) . '');
foreach ($back as $backrow) {
$webspaceusage = explode(' ', $backrow);
}
@@ -393,7 +393,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$maildir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
if (file_exists($maildir) && is_dir($maildir)) {
$back = safe_exec('du -sk ' . escapeshellarg($maildir) . '');
$back = \Froxlor\FileDir::safe_exec('du -sk ' . escapeshellarg($maildir) . '');
foreach ($back as $backrow) {
$emailusage = explode(' ', $backrow);
}
@@ -515,7 +515,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$stringdata = "0 " . $current_diskspace['all'] * 1024 . "";
fwrite($fh, $stringdata);
fclose($fh);
safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($quotafile) . '');
\Froxlor\FileDir::safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($quotafile) . '');
}
}
}
@@ -623,7 +623,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$staticOutputdir = \Froxlor\FileDir::makeCorrectDir($outputdir . '/' . date('Y') . '-' . date('m'));
if (! is_dir($staticOutputdir)) {
safe_exec('mkdir -p ' . escapeshellarg($staticOutputdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($staticOutputdir));
}
// check for correct path of awstats_buildstaticpages.pl
@@ -637,7 +637,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '" . $domain . "' (Output: '" . $staticOutputdir . "')");
safe_exec($awbsp . ' -awstatsprog=' . escapeshellarg($awprog) . ' -update -month=' . date('m') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir=' . escapeshellarg($staticOutputdir));
\Froxlor\FileDir::safe_exec($awbsp . ' -awstatsprog=' . escapeshellarg($awprog) . ' -update -month=' . date('m') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir=' . escapeshellarg($staticOutputdir));
// update our awstats index files
awstatsGenerateIndex($domain, $outputdir);
@@ -645,7 +645,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// the default selection is 'current',
// so link the latest dir to it
$new_current = \Froxlor\FileDir::makeCorrectFile($outputdir . '/current');
safe_exec('ln -fTs ' . escapeshellarg($staticOutputdir) . ' ' . escapeshellarg($new_current));
\Froxlor\FileDir::safe_exec('ln -fTs ' . escapeshellarg($staticOutputdir) . ' ' . escapeshellarg($new_current));
// statistics file looks like: 'awstats[month][year].[domain].txt'
$file = \Froxlor\FileDir::makeCorrectFile($outputdir . '/awstats' . date('mY', time()) . '.' . $domain . '.txt');
@@ -833,7 +833,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$outputdir = \Froxlor\FileDir::makeCorrectDir($outputdir);
if (! file_exists($outputdir)) {
safe_exec('mkdir -p ' . escapeshellarg($outputdir));
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg($outputdir));
}
if (file_exists($outputdir . 'webalizer.hist.1')) {
@@ -841,7 +841,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
if (file_exists($outputdir . 'webalizer.hist') && ! file_exists($outputdir . 'webalizer.hist.1')) {
safe_exec('cp ' . escapeshellarg($outputdir . 'webalizer.hist') . ' ' . escapeshellarg($outputdir . 'webalizer.hist.1'));
\Froxlor\FileDir::safe_exec('cp ' . escapeshellarg($outputdir . 'webalizer.hist') . ' ' . escapeshellarg($outputdir . 'webalizer.hist.1'));
}
$verbosity = '';
@@ -859,7 +859,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '" . $caption . "'");
safe_exec($we . ' ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($logfile));
\Froxlor\FileDir::safe_exec($we . ' ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($logfile));
/**
* Format of webalizer.hist-files:

View File

@@ -1,7 +1,7 @@
<?php
namespace Froxlor;
use Froxlor\Database as Database;
use Froxlor\Database\Database;
class FileDir
{
@@ -346,7 +346,7 @@ class FileDir
*/
public static function setImmutable($filename = null)
{
safe_exec(self::getImmutableFunction(false) . escapeshellarg($filename));
\Froxlor\FileDir::safe_exec(self::getImmutableFunction(false) . escapeshellarg($filename));
}
/**
@@ -359,7 +359,7 @@ class FileDir
*/
public static function removeImmutable($filename = null)
{
safe_exec(self::getImmutableFunction(true) . escapeshellarg($filename));
\Froxlor\FileDir::safe_exec(self::getImmutableFunction(true) . escapeshellarg($filename));
}
/**

View File

@@ -49,6 +49,6 @@ function makeChownWithNewStats($row) {
// only run chown if directory exists
if (file_exists($dir)) {
// run chown
safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(\Froxlor\FileDir::makeCorrectDir($dir)));
\Froxlor\FileDir::safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(\Froxlor\FileDir::makeCorrectDir($dir)));
}
}

View File

@@ -65,7 +65,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
if ($logger !== null) {
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
}
safe_exec('cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
\Froxlor\FileDir::safe_exec('cp -a ' . \Froxlor\Froxlor::getInstallDir() . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
}
}
return;

View File

@@ -34,14 +34,14 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
$awstats_dir = \Froxlor\FileDir::makeCorrectDir($customerDocroot.'/awstats/'.$siteDomain.'/');
if (!is_dir($awstats_dir)) {
safe_exec('mkdir -p '.escapeshellarg($awstats_dir));
\Froxlor\FileDir::safe_exec('mkdir -p '.escapeshellarg($awstats_dir));
}
// chown created folder, #258
makeChownWithNewStats($awstats_params);
// weird but could happen...
if (!is_dir(Settings::Get('system.awstats_conf'))) {
safe_exec('mkdir -p '.escapeshellarg(Settings::Get('system.awstats_conf')));
\Froxlor\FileDir::safe_exec('mkdir -p '.escapeshellarg(Settings::Get('system.awstats_conf')));
}
// These are the variables we will replace

View File

@@ -64,7 +64,7 @@ if (function_exists('exec')) {
// error log
if (file_exists($error_log)) {
$result = safe_exec('tail -n ' . $last_n . ' ' . escapeshellarg($error_log));
$result = \Froxlor\FileDir::safe_exec('tail -n ' . $last_n . ' ' . escapeshellarg($error_log));
$error_log_content = implode("\n", $result) . "</textarea>";
} else {
$error_log_content = "Error-Log" . (AREA == 'admin' ? " '" . $error_log . "'" : "") . " does not seem to exist";
@@ -72,7 +72,7 @@ if (function_exists('exec')) {
// access log
if (file_exists($access_log)) {
$result = safe_exec('tail -n ' . $last_n . ' ' . escapeshellarg($access_log));
$result = \Froxlor\FileDir::safe_exec('tail -n ' . $last_n . ' ' . escapeshellarg($access_log));
$access_log_content = implode("\n", $result);
} else {
$access_log_content = "Access-Log" . (AREA == 'admin' ? " '" . $access_log . "'" : "") . " does not seem to exist";