Ian,
I wish it were the way you say.
Unfortunately the truth is different:
-
Continuously changing permissions
Even if you set them up correctly permissions keep on changing to any figure. (most of them are similar, but some have completely different values)
So the only solution is a:
-
Cronjob to reset them back to the initial starting point.
I have made a script (see below), which I run every ten minutes and it takes just under 10 seconds to execute.
Unfortunately, as you say it will leave me uncovered for 10 minutes and this is a true problem, because, when something happens because of bad permissions, it has happened to me that the damage was irreparable and Iâve hade to proceed with a fresh install (which takes a long time and it is quite hard to back everything up once the system is broken so some data gets lost!)
-
Fatal vs non Fatal issue
Xar says that, for him, âAlthough not fatal, this issue is really present and anoying.â.
I cannot disagree more!
In a production envirnment with users who have not a clue of how the system works the undefined error is not admissible and it is Fatal!!! If it continues, after sometime everybody will want to throw this system away!!!
The worst thing is that the undefined error is not the only one. Most of the times wrong permissions lead to huge problems in SugarCRM.
For these two reasons (1. Make the system usable by non technichal people and 2. Avoid really fatal errors) for me this is the number one priority within SugarCRM and its derivative forks, including SuiteCRM.
I bet you that IBM, which recently switched to SugarCRM (pro), has obliged them to solve this issue in the Pro edition so, if it has been solved there it can be solved also in the Community Edition. The problem is that SugarCRM is a company and if the Community Edition was perfect nobody would buy their pro editions!!!
As I promised here is the code of my cronjob which runs every 10 minutes:
<?php
// $script_time_start = microtime(true);
function chmod_file_folder($dir) {
global $perms;
$dh=@opendir($dir);
if ($dh) {
while (false !==($file = readdir($dh))) {
if($file != "." && $file != ".." && !in_array($file, $perms['exclude_folders']) && !in_array($file, $perms['exclude_files'])) {
$fullpath = $dir .'/'. $file;
if(!is_dir($fullpath)) {
chmod($fullpath, $perms['file_perms']);
}else {
chmod($fullpath, $perms['dir_perms']);
chmod_file_folder($fullpath);
}
}
}
closedir($dh);
}
}
$change_folders = array();
$change_folders[]=array('change_dir' => '.',
'file_perms' => 0755,
'dir_perms' => 0755,
'exclude_folders' => array('cache', 'custom', 'data', 'modules', 'themes', 'themes'),
'exclude_files' => array('config_override.php')
);
$change_folders[]=array('change_dir' => 'cache',
'file_perms' => 0775,
'dir_perms' => 0775,
'exclude_folders' => array(),
'exclude_files' => array()
);
$change_folders[]=array('change_dir' => 'custom',
'file_perms' => 0775,
'dir_perms' => 0775,
'exclude_folders' => array(),
'exclude_files' => array()
);
$change_folders[]=array('change_dir' => 'data',
'file_perms' => 0775,
'dir_perms' => 0775,
'exclude_folders' => array(),
'exclude_files' => array()
);
$change_folders[]=array('change_dir' => 'modules',
'file_perms' => 0775,
'dir_perms' => 0775,
'exclude_folders' => array(),
'exclude_files' => array()
);
$change_folders[]=array('change_dir' => 'themes',
'file_perms' => 0775,
'dir_perms' => 0775,
'exclude_folders' => array(),
'exclude_files' => array()
);
foreach ($change_folders as $this_folder)
{
if(isset($perms))
unset($perms);
$perms = array();
$perms['file_perms'] = $this_folder['file_perms']; // chmod value for files don't enclose value in quotes.
$perms['dir_perms'] = $this_folder['dir_perms']; // chmod value for folders don't enclose value in quotes.
$perms['exclude_folders'] = $this_folder['exclude_folders']; // list of folders to exclude
$perms['exclude_files'] = $this_folder['exclude_files']; // list of files to exclude
chmod_file_folder($this_folder['change_dir']);
// echo "Changed permissions to: " . $this_folder['change_dir'] . " with : " . $perms['dir_perms'] . "<br>";
}
chmod('config_override.php', 0775);
// $script_time_total = microtime(true) - $script_time_start;
// echo "The script was executed in: " . $script_time_total . " seconds";
?>