FIX Infinite loop on deletion of temp file when there is symbolic links

This commit is contained in:
Laurent Destailleur 2018-03-03 11:22:15 +01:00
parent 63eecb46a9
commit d6b782e5ef
3 changed files with 9 additions and 4 deletions

View File

@ -86,7 +86,7 @@ if (! empty($conf->syslog->enabled))
$filelogparam=$filelog; $filelogparam=$filelog;
if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog)))
{ {
$filelogparam ='<a href="'.DOL_URL_ROOT.'/document.php?modulepart=logs&file='; $filelogparam ='<a class="wordbreak" href="'.DOL_URL_ROOT.'/document.php?modulepart=logs&file=';
$filelogparam.=basename($filelog); $filelogparam.=basename($filelog);
$filelogparam.='">'.$filelog.'</a>'; $filelogparam.='">'.$filelog.'</a>';
} }

View File

@ -67,7 +67,7 @@ class Utils
// Delete temporary files // Delete temporary files
if ($dolibarr_main_data_root) if ($dolibarr_main_data_root)
{ {
$filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$','','','',2); $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2, 0, '', 1); // Do not follow symlinks
if ($choice == 'tempfilesold') if ($choice == 'tempfilesold')
{ {
$now = dol_now(); $now = dol_now();

View File

@ -52,10 +52,11 @@ function dol_basename($pathfile)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
* @param int $nohook Disable all hooks * @param int $nohook Disable all hooks
* @param string $relativename For recursive purpose only. Must be "" at first call. * @param string $relativename For recursive purpose only. Must be "" at first call.
* @param string $donotfollowsymlinks Do not follow symbolic links
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
* @see dol_dir_list_indatabase * @see dol_dir_list_indatabase
*/ */
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="") function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
{ {
global $db, $hookmanager; global $db, $hookmanager;
global $object; global $object;
@ -159,7 +160,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
// if we're in a directory and we want recursive behavior, call this function again // if we're in a directory and we want recursive behavior, call this function again
if ($recursive) if ($recursive)
{ {
$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file)); if (empty($donotfollowsymlinks) || ! is_link($path."/".$file))
{
//var_dump('eee '. $path."/".$file. ' '.is_dir($path."/".$file).' '.is_link($path."/".$file));
$file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks));
}
} }
} }
else if (! $isdir && (($types == "files") || ($types == "all"))) else if (! $isdir && (($types == "files") || ($types == "all")))