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

IIS bug. "Directory path '/' is invalid" #299

Closed
7 of 17 tasks
Guanche opened this issue Mar 9, 2018 · 3 comments
Closed
7 of 17 tasks

IIS bug. "Directory path '/' is invalid" #299

Guanche opened this issue Mar 9, 2018 · 3 comments
Labels

Comments

@Guanche
Copy link

Guanche commented Mar 9, 2018

In raising this issue, I confirm the following (please check boxes):

  • I have read and understood the Wiki. Especially deploy and configuration articles.
  • I have checked that the bug I am reporting can be replicated, or that the feature I am suggesting isn't already present.
  • I have checked the pull requests tab for existing solutions/implementations to my issue/suggestion.
  • I realise that server-side connectors are provided by various contributors. The implementations are vary due to programming language features/limitations or other factors. Thus a particular connector may not implement, or partially implement, the API features.
  • I realise that any changes in configuration options and/or plugin parameters affect the plugin behavior. I specified all the differences from defaults in details.

I use the following server-side connector (check one):

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

Hi, an error happens when using the plugin with IIS.
After a correct instalation this message appears everytime: "Directory path '/' is invalid".

The problem is into ItemModel.php, at connectors\php\vendor\servocoder\richfilemanager-php\src\Repository\Local, at this lines:

$realPathItem = realpath($this->pathAbsolute);
$realPathRoot = realpath($this->storage->getRoot());
array_unshift($allowedPaths, $realPathRoot);

// clean up paths for more accurate comparison
$allowedPaths = array_map([$this->storage, 'cleanPath'], $allowedPaths);
$match = starts_with($realPathItem, $allowedPaths);
        
if (!$match) {
		Log::info('Item path validation FAILED');            
		Log::info('Absolute path "' . $this->pathAbsolute . '"');            
		Log::info('Real path: "' . $realPathItem . '"');            
		Log::info('Tested paths: "' . json_encode($allowedPaths) . '"');
}
return $match;

What I did to solve it was replacing this lines:

/*
$realPathItem = realpath($this->pathAbsolute);
$realPathRoot = realpath($this->storage->getRoot());
*/
				
$realPathItem = $this->pathAbsolute;        
$realPathRoot = $this->storage->getRoot();

realpath function returns the path in windows format, using \ as separator. While method cleanPath turns \ into /. And then they don't match.

Now it seems that works fine. I've not had any problems till now.

Greetings from the Canary Islands.

@psolom
Copy link
Owner

psolom commented Mar 9, 2018

I'm glad you solved your issue, but realpath is important security check. Using it we can make sure that there are no symlinks linked to restricted locations outside userfiles folder. So I strongly don't recommend you to avoid it.

What if you rewrite it in the following way:

$match = starts_with($this->storage->cleanPath($realPathItem), $allowedPaths);

This is appropriate solution that I can include in the next release.

I believe this should work for you. Let me know if so.

@Guanche
Copy link
Author

Guanche commented Mar 10, 2018

Thanks. As you say it works ok.

@Guanche Guanche changed the title IIS bug solved. "Directory path '/' is invalid" IIS bug. "Directory path '/' is invalid" Mar 10, 2018
@psolom
Copy link
Owner

psolom commented Mar 10, 2018

Fixed. Will be included in the next release.

@psolom psolom closed this as completed Mar 10, 2018
@psolom psolom added the bug label Mar 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants