- check for 'chattr' command, and use 'chflags' (FreeBSD) if not found, fixes #339
- add license-header to function.storeDefaultIndex.php
This commit is contained in:
66
lib/functions/filedir/function.fileImmutable.php
Normal file
66
lib/functions/filedir/function.fileImmutable.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Functions
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the immutable flag for a file
|
||||||
|
*
|
||||||
|
* @param string $filename the file to set the flag for
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function setImmutable($filename = null)
|
||||||
|
{
|
||||||
|
safe_exec(_getImmutableFunction(false).escapeshellarg($filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes the immutable flag for a file
|
||||||
|
*
|
||||||
|
* @param string $filename the file to set the flag for
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function removeImmutable($filename = null)
|
||||||
|
{
|
||||||
|
safe_exec(_getImmutableFunction(true).escapeshellarg($filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* internal function to check whether
|
||||||
|
* to use chattr (Linux) or chflags (FreeBSD)
|
||||||
|
*
|
||||||
|
* @param boolean $remove whether to use +i|schg (false) or -i|noschg (true)
|
||||||
|
*
|
||||||
|
* @return string functionname + parameter (not the file)
|
||||||
|
*/
|
||||||
|
function _getImmutableFunction($remove = false)
|
||||||
|
{
|
||||||
|
$output = array();
|
||||||
|
$return_var = 0;
|
||||||
|
exec('which chattr 2>&1', $output, $return_var);
|
||||||
|
|
||||||
|
if((int)$return_var != 0)
|
||||||
|
{
|
||||||
|
// FreeBSD style
|
||||||
|
return 'chflags '.($remove === true) ? 'noschg ' : 'schg ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Linux style
|
||||||
|
return 'chattr '.($remove === true) ? '-i ' : '+i ';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@ function safe_exec($exec_string, &$return_value = false)
|
|||||||
'du',
|
'du',
|
||||||
'chmod',
|
'chmod',
|
||||||
'chattr',
|
'chattr',
|
||||||
|
'chflags', /* freebsd equivalent to linux' chattr */
|
||||||
$settings['system']['apachereload_command'],
|
$settings['system']['apachereload_command'],
|
||||||
$settings['system']['bindreload_command'],
|
$settings['system']['bindreload_command'],
|
||||||
$settings['dkim']['dkimrestart_command'],
|
$settings['dkim']['dkimrestart_command'],
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Functions
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store the default index-file in a given destination folder
|
* store the default index-file in a given destination folder
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class apache_fcgid extends apache
|
|||||||
|
|
||||||
if(file_exists($starter_filename))
|
if(file_exists($starter_filename))
|
||||||
{
|
{
|
||||||
safe_exec('chattr -i ' . escapeshellarg($starter_filename));
|
removeImmutable($starter_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$starter_file_handler = fopen($starter_filename, 'w');
|
$starter_file_handler = fopen($starter_filename, 'w');
|
||||||
@@ -157,7 +157,7 @@ class apache_fcgid extends apache
|
|||||||
fclose($starter_file_handler);
|
fclose($starter_file_handler);
|
||||||
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($starter_filename));
|
safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chattr +i ' . escapeshellarg($starter_filename));
|
setImmutable($starter_filename);
|
||||||
|
|
||||||
// define the php.ini
|
// define the php.ini
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ class apache_fcgid extends apache
|
|||||||
//remove +i attibute, so starter can be overwritten
|
//remove +i attibute, so starter can be overwritten
|
||||||
if(file_exists($starter_filename))
|
if(file_exists($starter_filename))
|
||||||
{
|
{
|
||||||
safe_exec('chattr -i ' . escapeshellarg($starter_filename));
|
removeImmutable($starter_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$starter_file_handler = fopen($starter_filename, 'w');
|
$starter_file_handler = fopen($starter_filename, 'w');
|
||||||
@@ -357,7 +357,7 @@ class apache_fcgid extends apache
|
|||||||
fclose($starter_file_handler);
|
fclose($starter_file_handler);
|
||||||
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($starter_filename));
|
safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chattr +i ' . escapeshellarg($starter_filename));
|
setImmutable($starter_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class lighttpd_fcgid extends lighttpd
|
|||||||
|
|
||||||
if(file_exists($starter_filename))
|
if(file_exists($starter_filename))
|
||||||
{
|
{
|
||||||
safe_exec('chattr -i ' . escapeshellarg($starter_filename));
|
removeImmutable($starter_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$starter_file_handler = fopen($starter_filename, 'w');
|
$starter_file_handler = fopen($starter_filename, 'w');
|
||||||
@@ -181,7 +181,7 @@ class lighttpd_fcgid extends lighttpd
|
|||||||
fclose($starter_file_handler);
|
fclose($starter_file_handler);
|
||||||
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
safe_exec('chmod 750 ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($starter_filename));
|
safe_exec('chown ' . $domain['guid'] . ':' . $domain['guid'] . ' ' . escapeshellarg($starter_filename));
|
||||||
safe_exec('chattr +i ' . escapeshellarg($starter_filename));
|
setImmutable($starter_filename);
|
||||||
|
|
||||||
// define the php.ini
|
// define the php.ini
|
||||||
|
|
||||||
|
|||||||
@@ -254,13 +254,13 @@ $awstatsclean['headerold']) {
|
|||||||
|
|
||||||
// iterate through all subdirs,
|
// iterate through all subdirs,
|
||||||
// look for php-fcgi-starter files
|
// look for php-fcgi-starter files
|
||||||
// and take chattr +i away from them
|
// and take immutable-flag away from them
|
||||||
// so we can delete them :)
|
// so we can delete them :)
|
||||||
foreach ($its as $fullFileName => $it )
|
foreach ($its as $fullFileName => $it )
|
||||||
{
|
{
|
||||||
if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter')
|
if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter')
|
||||||
{
|
{
|
||||||
safe_exec('chattr -i ' . escapeshellarg($its->getPathname()));
|
removeImmutable($its->getPathname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now get rid of old stuff
|
// now get rid of old stuff
|
||||||
|
|||||||
Reference in New Issue
Block a user