diff options
author | Simon Rettberg | 2020-12-10 14:01:18 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-12-10 14:01:18 +0100 |
commit | cdf414bf6a999788d4d70e997f8c413e96ef7bb1 (patch) | |
tree | 3c05b78ffd5133fafaf110b4dd392294399d788e /modules-available/sysconfig/addmodule_custommodule.inc.php | |
parent | [rebootcontrol] rename scheduler table and associated queries (diff) | |
download | slx-admin-cdf414bf6a999788d4d70e997f8c413e96ef7bb1.tar.gz slx-admin-cdf414bf6a999788d4d70e997f8c413e96ef7bb1.tar.xz slx-admin-cdf414bf6a999788d4d70e997f8c413e96ef7bb1.zip |
[sysconfig] CustomModule: Add check for file ownership, add "fix" option
The fix option will change the owner/group of every file and directory
in the archive to root:root
Previously, the client changed the ownership of the config.tgz contents
to root when extracting, but in some cases it's desired to deliver files
with specific owner and group settings.
The version of the CustomModule module has been bumped to 2, so we can
automatically convert old modules when upgrading or importing a backup,
to be compatible to the old "root everything on the client" logic.
Diffstat (limited to 'modules-available/sysconfig/addmodule_custommodule.inc.php')
-rw-r--r-- | modules-available/sysconfig/addmodule_custommodule.inc.php | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/modules-available/sysconfig/addmodule_custommodule.inc.php b/modules-available/sysconfig/addmodule_custommodule.inc.php index 0c3c299d..7830b8ed 100644 --- a/modules-available/sysconfig/addmodule_custommodule.inc.php +++ b/modules-available/sysconfig/addmodule_custommodule.inc.php @@ -57,6 +57,7 @@ class CustomModule_ProcessUpload extends AddModule_Base { $status = Taskmanager::waitComplete($this->taskId); Taskmanager::release($this->taskId); + $userGroupWarn = false; $tempfile = Session::get('mod_temp'); if (!isset($status['statusCode'])) { unlink($tempfile); @@ -66,36 +67,21 @@ class CustomModule_ProcessUpload extends AddModule_Base unlink($tempfile); $this->taskError($status); } - // Sort files for better display - $dirs = array(); - foreach ($status['data']['entries'] as $file) { - if ($file['isdir']) continue; - $dirs[dirname($file['name'])][] = $file; - } - ksort($dirs); - $list = array(); - foreach ($dirs as $dir => $files) { - $list[] = array( - 'name' => $dir, - 'isdir' => true - ); - sort($files); - foreach ($files as $file) { - $file['size'] = Util::readableFileSize($file['size']); - $list[] = $file; - } - } - if ($this->edit !== false) + $list = SysConfig::archiveContentsFromTask($status, $userGroupWarn); + + if ($this->edit !== false) { $title = $this->edit->title(); - elseif (isset($_FILES['modulefile']['name'])) + } else if (isset($_FILES['modulefile']['name'])) { $title = basename($_FILES['modulefile']['name']); - else + } else { $title = ''; + } Render::addDialog(Dictionary::translate('config-module', 'custom_title'), false, 'custom-fileselect', array( 'step' => 'CustomModule_CompressModule', 'files' => $list, 'edit' => $this->edit ? $this->edit->id() : false, - 'title' => $title + 'title' => $title, + 'userGroupWarn' => $userGroupWarn, )); Session::save(); } @@ -121,7 +107,8 @@ class CustomModule_CompressModule extends AddModule_Base Taskmanager::submit('RecompressArchive', array( 'id' => $this->taskId, 'inputFiles' => [$tempfile => false], - 'outputFile' => $destFile + 'outputFile' => $destFile, + 'forceRoot' => Request::post('force-owner', 0, 'int') !== 0, ), true); $status = Taskmanager::waitComplete($this->taskId, 5000); unlink($tempfile); |