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

Importing photos step 2 not working open_basedir restriction #79

Closed
HonkXL opened this issue Aug 17, 2016 · 5 comments
Closed

Importing photos step 2 not working open_basedir restriction #79

HonkXL opened this issue Aug 17, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@HonkXL
Copy link
Contributor

HonkXL commented Aug 17, 2016

I tried to import images from a zip file. Uploading and unpacking the zip works. Then I see the images and when I click one image and try to import I gut an php error.

Error message is below. For me it seems that it tries to create a directory in / - but I do not want to allow php to access everywhere. I granted access to the own webroot and to /etc/zoph.ini

Can something changed to make open_basedir working?

Warning: file_exists(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/vhosts/weiland24.de/:/tmp/:/etc/zoph.ini:/usr/share/file/magic.mgc) in /var/www/vhosts/weiland24.de/httpdocs/fotomanager/util.inc.php on line 482
Verzeichnis konnte nicht erstellt werden: /

Fatal error: Uncaught exception 'FileDirCreationFailedException' with message 'Verzeichnis konnte nicht erstellt werden: /<br> ' in /var/www/vhosts/weiland24.de/httpdocs/fotomanager/util.inc.php:489 Stack trace: #0 /var/www/vhosts/weiland24.de/httpdocs/fotomanager/util.inc.php(502): create_dir('/') #1 /var/www/vhosts/weiland24.de/httpdocs/fotomanager/classes/photo.inc.php(425): create_dir_recursive('/var/www/vhosts...') #2 /var/www/vhosts/weiland24.de/httpdocs/fotomanager/import.inc.php(129): photo->import(Object(file)) #3 /var/www/vhosts/weiland24.de/httpdocs/fotomanager/webimport.inc.php(59): Import::photos(Array, Array) #4 /var/www/vhosts/weiland24.de/httpdocs/fotomanager/import.php(147): WebImport::photos(Array, Array) #5 {main} thrown in /var/www/vhosts/weiland24.de/httpdocs/fotomanager/util.inc.php on line 489
@jeroenrnl
Copy link
Owner

I think this is caused by Zoph making sure the entire directory path exists, starting from /, moving down into the path. I will have to look into this on my development system.

@jeroenrnl jeroenrnl added the bug label Aug 17, 2016
@jeroenrnl jeroenrnl added this to the v0.9.4 milestone Aug 17, 2016
@jeroenrnl jeroenrnl self-assigned this Aug 17, 2016
@HonkXL
Copy link
Contributor Author

HonkXL commented Aug 17, 2016

Great - thank you. I think the best is to change this, because in general it is no good idea to grant access for php outside the webroot. It's ok for a single file like the zoph.ini in /etc/ but not for the entire root path.

@jeroenrnl
Copy link
Owner

I agree. In fact Zoph does only need access to /etc/zoph.ini, the webroot and the location of the photos (which should be outside the webroot). However, when Zoph is creating directories during import, it will start at / to make sure every directory in the path exists. open_basedir prevents Zoph from "seeing" the directory - which leads to Zoph assuming it does not exist, hence trying to create it. I will need to see what can be done to prevent this.

@jeroenrnl
Copy link
Owner

I have reproduced the issue on my dev system. Now working on a fix.

jeroenrnl added a commit that referenced this issue Aug 23, 2016
Changed the order in which recursive creation of directories is
executed. The 'old' way was to start at the root and work the way up to
the dir to be created. This caused problems when open_basedir
restriction is activated. The 'new' behaviour is to start at the dir to
be created, then work up to the first dir that needs to be created and
then work back down. As long as the "basedir" exists, this will keep
Zoph from trying to pry on the filesystem outside of the basedir.

Also, did some refactoring, moving a few related function out of
util.inc.php into the file class.

Issue #79
@jeroenrnl
Copy link
Owner

Changed the order in which recursive creation of directories is
executed. The 'old' way was to start at the root and work the way up to
the dir to be created. This caused problems when open_basedir
restriction is activated. The 'new' behaviour is to start at the dir to
be created, then work up to the first dir that needs to be created and
then work back down. As long as the "basedir" exists, this will keep
Zoph from trying to pry on the filesystem outside of the basedir.

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