Skip to content
Snippets Groups Projects
Commit 2c44aa67 authored by Raphaël Doursenaud's avatar Raphaël Doursenaud
Browse files

Add sensible default mode to directory creation

Fix #2632
parent 3b38949f
Branches
Tags
No related merge requests found
...@@ -3727,10 +3727,10 @@ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0) ...@@ -3727,10 +3727,10 @@ function get_exdir($num,$level=3,$alpha=0,$withoutslash=0)
* *
* @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir')
* @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used)
* @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0444' * @param int $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444'
* @return int < 0 if KO, 0 = already exists, > 0 if OK * @return int < 0 if KO, 0 = already exists, > 0 if OK
*/ */
function dol_mkdir($dir, $dataroot='', $newmask=0) function dol_mkdir($dir, $dataroot='', $newmask=null)
{ {
global $conf; global $conf;
...@@ -3768,7 +3768,9 @@ function dol_mkdir($dir, $dataroot='', $newmask=0) ...@@ -3768,7 +3768,9 @@ function dol_mkdir($dir, $dataroot='', $newmask=0)
umask(0); umask(0);
$dirmaskdec=octdec($newmask); $dirmaskdec=octdec($newmask);
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); if (empty($newmask)) {
$dirmaskdec = empty( $conf->global->MAIN_UMASK ) ? octdec( '0755' ) : octdec( $conf->global->MAIN_UMASK );
}
$dirmaskdec |= octdec('0111'); // Set x bit required for directories $dirmaskdec |= octdec('0111'); // Set x bit required for directories
if (! @mkdir($ccdir_osencoded, $dirmaskdec)) if (! @mkdir($ccdir_osencoded, $dirmaskdec))
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment