Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for symlink folders #3

Closed
camjac251 opened this issue Jun 14, 2020 · 4 comments · Fixed by #4
Closed

Support for symlink folders #3

camjac251 opened this issue Jun 14, 2020 · 4 comments · Fixed by #4

Comments

@camjac251
Copy link

Is it possible to use this script with symlinked folders?
I get this error when trying to enter a folder /directory/to/folder/symlink that is linked to /directory/to/mount/FOLDER/foldername. Although symlink and foldername are the same foldername on disk. In this example it's just to hopefully clarify which is which.

 Fatal error: Uncaught Exception: requested path is below the public working directory. in /directory/to/folder/symlink/indexer.php:89 Stack trace: #0 /directory/to/folder/symlink/indexer.php(396): Indexer->__construct('/symlink/', Array) #1 {main} thrown in /directory/to/folder/symlink/indexer.php on line 89
@sixem sixem mentioned this issue Jun 14, 2020
@sixem
Copy link
Owner

sixem commented Jun 14, 2020

I've created a fix for this here #4.

Basically, the script would use realpath to check if the current folder was above the directory of the indexer.php, this is an attempt to avoid backwards directory traversal.

Problem is that the realpath also returns the real path of any symbolic links. I tried using is_link which would work for the directory but not any subdirectories inside of it.

So, instead i added a path_checking option, which when set to weak will check if the directory is a symbolic link, if it isn't, then it'll use a similar function to realpath that just works with strings instead of actual file paths, thus not resolving the symbolic link.

Let me know if it works for you.

@camjac251
Copy link
Author

It didn't work for me sadly. I double checked to make sure I had the right code downloaded too

I noticed a mistake I made with obfuscating the paths in the last code snippet so hopefully this one is less confusing. I have a base folder as the root in nginx, and inside that are symlinked folders
Fatal error: Uncaught Exception: requested path (is_dir) is below the public working directory. (1) in /directory/to/folder/userfolder/indexer.php:92 Stack trace: #0 /directory/to/folder/userfolder/indexer.php(441): Indexer->__construct('/symlinkedfolder/', Array) #1 {main} thrown in /directory/to/folder/userfolder/indexer.php on line 92

@sixem
Copy link
Owner

sixem commented Jun 14, 2020

Did you remember to set the path_checking option to weak after updating the code? That error code tells me that it was still set to strict.

@camjac251
Copy link
Author

camjac251 commented Jun 14, 2020

I completely missed that part. I should have read it closer. setting it to weak and it works flawlessly. Thank you very much.

@sixem sixem closed this as completed in #4 Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants