When I go to create a new node, change the input type to "Asset", and click "Insert Assets", the pop-up window shows this following error message:

    *  warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/www/00dfc27b839d9b2dc803b9e7f3aa44c4:/tmp:/opt/php/lib/php) in /home/www/00dfc27b839d9b2dc803b9e7f3aa44c4/web/newsite/includes/file.inc on line 286.
    * warning: realpath() [function.realpath]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/www/00dfc27b839d9b2dc803b9e7f3aa44c4:/tmp:/opt/php/lib/php) in /home/www/00dfc27b839d9b2dc803b9e7f3aa44c4/web/newsite/includes/file.inc on line 286.

I don't know much about the configuration of the server this is on, however I do know that Asset module should handle open_basedir restrictions properly, as this is a fairly common thing for administrators to do on their servers.

Why does Asset need access to directories below the user's home directory?

CommentFileSizeAuthor
#7 asset_212653_7.patch3.16 KBmfer

Comments

jmlane’s picture

This error is still happening, but I can hide it to the logs.

Asset 'seems' to be working fine, but I am curious about what might be causing this error message?

wmostrey’s picture

Hey Jonathan, I'll do some testing to see if I can replicate this. Asset doesn't try to access any files outside the web directory so it should be playing nicely with open_basedir restrictions (if they are correctly set of course, which they appear to be in your case). I think this is happening because asset is trying to check "/", by which Drupal's base_path is meant of course, not the root of the server.

jmlane’s picture

Every time the Asset UI is called at http://mysite.org/asset/wizard/tinymce, I get this same old PHP error in my logs:
realpath() [<a href='function.realpath'>function.realpath</a>]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/www/00dfc27b839d9b2dc803b9e7f3aa44c4:/tmp:/opt/php/lib/php) in /home/www/00dfc27b839d9b2dc803b9e7f3aa44c4/web/newsite/includes/file.inc on line 286.

I am having problems with the Asset UI as well, which I am assuming are part of this problem seeing as nobody else seems to have reported them:

  • I can't seem to delete folders from the Asset UI. Some empty folders are showing up in the UI, even though I've deleted the folders from the file system because I couldn't delete them from the UI.
  • Some folders are duplicated in the UI, with one of the folders pointing to the real directory, the other just seems to link back to the parent directory.

Any ideas if these issues are related, and even if not, any suggestions for the problems?

Thanks for all your help,

Jonathan M. Lane
OpenConcept Consulting Inc. http://www.openconcept.ca/

mfer’s picture

This has to do with sections of code like:

$asset->filepath = file_create_path($asset->dirname .'/'. $asset->filename);
$asset->url = file_create_url($asset->dirname .'/'. $asset->filename);

What happens when $asset->dirname is empty? You try to create a path at '/filename' which is outside of the allowed area. This throws the error.

I have a workaround for this. (Sorry, I have not had a chance to roll a patch for this yet.)

In asset_load of asset.module after the db_object_fetch and the check to make sure something loaded add the line that tests dirname and adds the / if it exists.

$asset = db_fetch_object(db_query('SELECT a.* FROM {asset} a WHERE '. $cond, $arguments));
if (!$asset) {
  return false;
}
$asset->dirname = $asset->dirname ? $asset->dirname .'/' : $asset->dirname; 

Then modify the filepath and url to look like:

$asset->filepath = file_create_path($asset->dirname . $asset->filename);
$asset->url = file_create_url($asset->dirname . $asset->filename);

A similar solution is needed where ever $form_values['parent'] is used with file_create_path. $form_values['parent'] may be empty.

Is it a good approach to modify $asset->dirname and $form_values['parent'] or should a new variable be created as a temp variable instead of the modification? Or should an if statement be used with:

$asset->filepath = file_create_path($asset->dirname . $asset->filename);
$asset->url = file_create_url($asset->dirname . $asset->filename);

????

mfer’s picture

I noticed this same problem in asset_bonus for embedded objects. Haven't traced the cause of it yet.

mfer’s picture

Version: 5.x-1.x-dev » 5.x-1.0-beta1

I have the problem in the 1.0-beta1 release. I'll roll a patch in the next day or so.

mfer’s picture

Status: Active » Needs review
StatusFileSize
new3.16 KB

Attached is a patch that removes this error for me.

mfer’s picture

Category: support » bug
Priority: Normal » Critical

I'm moving this over to bugs and upping the priority to critical. If you don't have your directory structure setup (for example a first tie install) you will get these errors because there is no root dirname.

wmostrey’s picture

Status: Needs review » Fixed

Committed to dev, thanks so much! You just brought Beta 2 a lot closer.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.