Skip to content

Commit

Permalink
Handles symlinks when checking paths of $boarddir, $sourcedir, etc.
Browse files Browse the repository at this point in the history
We can't just use `!is_dir()` in case there's a symlink, but we neither can we use `is_file()` in case the directory doesn't exist at all, nor can we use `file_exists()` in case it does exist but it is not a directory. So, this uses `!is_dir(realpath($whatever))` to resolve any symlinks or other weirdness in the path and then checks if the resolved path is in fact a directory.

Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Jan 11, 2020
1 parent 0b6bcb3 commit 022bec5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Sources/Subs-Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,13 @@ function updateSettingsFile($config_vars, $keep_quotes = null, $partial = false)
'text' => implode("\n", array(
'',
'# Make sure the paths are correct... at least try to fix them.',
'if (!is_dir($boarddir) && file_exists(dirname(__FILE__) . \'/agreement.txt\'))',
'if (!is_dir(realpath($boarddir)) && file_exists(dirname(__FILE__) . \'/agreement.txt\'))',
' $boarddir = dirname(__FILE__);',
'if (!is_dir($sourcedir) && is_dir($boarddir . \'/Sources\'))',
'if (!is_dir(realpath($sourcedir)) && is_dir($boarddir . \'/Sources\'))',
' $sourcedir = $boarddir . \'/Sources\';',
'if (!is_dir($taskdir) && is_dir($sourcedir . \'/tasks\'))',
'if (!is_dir(realpath($taskdir)) && is_dir($sourcedir . \'/tasks\'))',
' $taskdir = $sourcedir . \'/tasks\';',
'if (!is_dir($cachedir) && is_dir($boarddir . \'/cache\'))',
'if (!is_dir(realpath($cachedir)) && is_dir($boarddir . \'/cache\'))',
' $cachedir = $boarddir . \'/cache\';',
)),
),
Expand Down
8 changes: 4 additions & 4 deletions other/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@
$tasksdir = $sourcedir . '/tasks';

# Make sure the paths are correct... at least try to fix them.
if (!is_dir($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
if (!is_dir(realpath($boarddir)) && file_exists(dirname(__FILE__) . '/agreement.txt'))
$boarddir = dirname(__FILE__);
if (!is_dir($sourcedir) && is_dir($boarddir . '/Sources'))
if (!is_dir(realpath($sourcedir)) && is_dir($boarddir . '/Sources'))
$sourcedir = $boarddir . '/Sources';
if (!is_dir($tasksdir) && is_dir($sourcedir . '/tasks'))
if (!is_dir(realpath($tasksdir)) && is_dir($sourcedir . '/tasks'))
$tasksdir = $sourcedir . '/tasks';
if (!is_dir($cachedir) && is_dir($boarddir . '/cache'))
if (!is_dir(realpath($cachedir)) && is_dir($boarddir . '/cache'))
$cachedir = $boarddir . '/cache';

######### Legacy Settings #########
Expand Down

0 comments on commit 022bec5

Please sign in to comment.