Skip to content

Commit f6420c0

Browse files
author
Marius Burkard
committed
Merge branch '5947-restoreFileOwnership' into 'develop'
restoreFileOwnership() excludes system paths Closes #5947 See merge request ispconfig/ispconfig3!1354
2 parents 91a7ecb + 2e299c5 commit f6420c0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server/lib/classes/backup.inc.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,21 @@ protected static function getBackupWebExtension($format)
100100
* @param string $web_user
101101
* @author Ramil Valitov <ramilvalitov@gmail.com>
102102
*/
103-
protected static function restoreFileOwnership($web_document_root, $web_user)
103+
protected static function restoreFileOwnership($web_document_root, $web_user, $web_group)
104104
{
105105
global $app;
106106

107+
$blacklist = array('bin', 'dev', 'etc', 'home', 'lib', 'lib32', 'lib64', 'log', 'opt', 'proc', 'net', 'run', 'sbin', 'ssl', 'srv', 'sys', 'usr', 'var');
108+
109+
$find_excludes = '-not -path "." -and -not -path "./web/stats/*"';
110+
111+
foreach ( $blacklist as $dir ) {
112+
$find_excludes .= ' -and -not -path "./'.$dir.'" -and -not -path "./'.$dir.'/*"';
113+
}
114+
107115
$app->log('Restoring permissions for ' . $web_document_root, LOGLEVEL_DEBUG);
108-
$app->system->exec_safe('cd ? && find . -not -path "./web/stats/*" -and -not -path "./log" -and -not -path "./log/*" -and -not -path "./ssl" -and -not -path "./ssl/*" -and -not -path "." -exec chown ?:? {} \;', $web_document_root, $web_user, $web_user);
116+
$app->system->exec_safe('cd ? && find . '.$find_excludes.' -exec chown ?:? {} \;', $web_document_root, $web_user, $web_group);
117+
109118
}
110119

111120
/**
@@ -290,7 +299,7 @@ public static function restoreBackupWebFiles($backup_format, $password, $backup_
290299
*/
291300
$success = ($retval == 0 || $retval == 50);
292301
if ($success) {
293-
self::restoreFileOwnership($web_root, $web_user);
302+
self::restoreFileOwnership($web_root, $web_user, $web_group);
294303
}
295304
break;
296305
case 'rar':

0 commit comments

Comments
 (0)