fix quota on freebsd, thanks to skotti's patch. fixes #1377

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2014-02-21 08:04:26 +01:00
parent c59fe0e4ad
commit e650be3814
4 changed files with 67 additions and 20 deletions

View File

@@ -22,8 +22,7 @@
*
* @return boolean
*/
function setImmutable($filename = null)
{
function setImmutable($filename = null) {
safe_exec(_getImmutableFunction(false).escapeshellarg($filename));
}
@@ -34,8 +33,7 @@ function setImmutable($filename = null)
*
* @return boolean
*/
function removeImmutable($filename = null)
{
function removeImmutable($filename = null) {
safe_exec(_getImmutableFunction(true).escapeshellarg($filename));
}
@@ -47,19 +45,12 @@ function removeImmutable($filename = null)
*
* @return string functionname + parameter (not the file)
*/
function _getImmutableFunction($remove = false)
{
$output = array();
$return_var = 0;
exec('which chattr 2>&1', $output, $return_var);
function _getImmutableFunction($remove = false) {
if((int)$return_var != 0)
{
if (isFreeBSD()) {
// FreeBSD style
return 'chflags '.(($remove === true) ? 'noschg ' : 'schg ');
}
else
{
} else {
// Linux style
return 'chattr '.(($remove === true) ? '-i ' : '+i ');
}