Update permissions skip dev/shm

This commit is contained in:
FusionPBX
2025-07-01 12:48:50 -06:00
committed by GitHub
parent cd892288e5
commit cb481c2d3e
2 changed files with 30 additions and 4 deletions

View File

@@ -576,12 +576,15 @@
function update_file_permissions($text, settings $settings) {
if (is_root()) {
//initialize the array
$directories = [];
//get the fusionpbx folder
$project_root = dirname(__DIR__, 2);
//adjust the project root
$directories[] = $project_root;
//adjust the /etc/freeswitch
$directories[] = $settings->get('switch', 'conf', null);
$directories[] = $settings->get('switch', 'call_center', null); //normally in conf but can be different
@@ -589,26 +592,36 @@ function update_file_permissions($text, settings $settings) {
$directories[] = $settings->get('switch', 'directory', null); //normally in conf but can be different
$directories[] = $settings->get('switch', 'languages', null); //normally in conf but can be different
$directories[] = $settings->get('switch', 'sip_profiles', null); //normally in conf but can be different
//adjust the /usr/share/freeswitch/{scripts,sounds}
$directories[] = $settings->get('switch', 'scripts', null);
$directories[] = $settings->get('switch', 'sounds', null);
//adjust the /var/lib/freeswitch/{db,recordings,storage,voicemail}
$directories[] = $settings->get('switch', 'db', null);
$directories[] = $settings->get('switch', 'recordings', null);
$directories[] = $settings->get('switch', 'storage', null);
$directories[] = $settings->get('switch', 'voicemail', null); //normally included in storage but can be different
//only set the xml_cdr directory permissions
$log_directory = $settings->get('switch', 'log', null);
if ($log_directory !== null) {
$directories[] = $log_directory . '/xml_cdr';
}
//update the auto_loader cache permissions file
$directories[] = sys_get_temp_dir() . '/' . auto_loader::CLASSES_FILE;
//execute chown command for each directory
foreach ($directories as $dir) {
//skip the empty directories
//skip empty directories
if (empty($dir)) { continue; }
//skip /dev/shm directory
if (strpos($dir, '/dev/shm') !== false) {
continue;
}
//execute
exec("chown -R www-data:www-data $dir");
}
@@ -674,4 +687,3 @@ function is_root(): bool {
return posix_getuid() === 0;
}
?>

View File

@@ -202,11 +202,15 @@ function do_file_permissions($text, settings $settings) {
echo ($text['label-header1'] ?? "Root account or sudo account must be used for this option") . "\n";
echo ($text['label-header2'] ?? "This option is used for resetting the permissions on the filesystem after executing commands using the root user account") . "\n";
if (is_root_user()) {
//initialize the array
$directories = [];
//get the fusionpbx folder
$project_root = dirname(__DIR__, 2);
//adjust the project root
$directories[] = $project_root;
//adjust the /etc/freeswitch
$directories[] = $settings->get('switch', 'conf', null);
$directories[] = $settings->get('switch', 'call_center', null); //normally in conf but can be different
@@ -214,26 +218,36 @@ function do_file_permissions($text, settings $settings) {
$directories[] = $settings->get('switch', 'directory', null); //normally in conf but can be different
$directories[] = $settings->get('switch', 'languages', null); //normally in conf but can be different
$directories[] = $settings->get('switch', 'sip_profiles', null); //normally in conf but can be different
//adjust the /usr/share/freeswitch/{scripts,sounds}
$directories[] = $settings->get('switch', 'scripts', null);
$directories[] = $settings->get('switch', 'sounds', null);
//adjust the /var/lib/freeswitch/{db,recordings,storage,voicemail}
$directories[] = $settings->get('switch', 'db', null);
$directories[] = $settings->get('switch', 'recordings', null);
$directories[] = $settings->get('switch', 'storage', null);
$directories[] = $settings->get('switch', 'voicemail', null); //normally included in storage but can be different
//only set the xml_cdr directory permissions
$log_directory = $settings->get('switch', 'log', null);
if ($log_directory !== null) {
$directories[] = $log_directory . '/xml_cdr';
}
//update the auto_loader cache permissions file
$directories[] = sys_get_temp_dir() . '/' . auto_loader::CLASSES_FILE;
//execute chown command for each directory
foreach ($directories as $dir) {
//skip the empty directories
//skip empty directories
if (empty($dir)) { continue; }
//skip /dev/shm directory
if (strpos($dir, '/dev/shm') !== false) {
continue;
}
//notify user
echo "chown -R www-data:www-data $dir\n";