MG 1.1 Some server error

Sunka

Well-known member
Any thoughts?

Code:
Server Error Log
Error Info
ErrorException: tempnam(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/nginx/domains/pijanitvor.com/public/:/usr/local/lib/php/:/tmp/) - library/XenGallery/Helper/Image.php:109
Generated By: Branko, A moment ago
Stack Trace

#0 [internal function]: XenForo_Application::handlePhpError(2, 'tempnam(): open...', '/home/nginx/dom...', 109, Array)
#1 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Helper/Image.php(109): tempnam('/', 'xfmg')
#2 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Helper/Image.php(44): XenGallery_Helper_Image->setPathToTempFiles('/home/nginx/dom...')
#3 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Model/File.php(75): XenGallery_Helper_Image->__construct('/tmp/xfmgFa8hq5')
#4 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/ControllerPublic/File.php(378): XenGallery_Model_File->insertUploadedAttachmentData(Object(XenForo_Upload), 4358)
#5 /home/nginx/domains/pijanitvor.com/public/library/XenForo/FrontController.php(351): XenGallery_ControllerPublic_File->actionDoDownload()
#6 /home/nginx/domains/pijanitvor.com/public/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#7 /home/nginx/domains/pijanitvor.com/public/index.php(13): XenForo_FrontController->run()
#8 {main}

Request State

array(3) {
  ["url"] => string(172) "https://www.pijanitvor.com/media/files/do-download?hash=163b5033b927410496f7a8a52c0e1340&content_type=xengallery_media&content_data[category_id]=18&upload_type=image_upload"
  ["_GET"] => array(5) {
    ["/media/files/do-download"] => string(0) ""
    ["hash"] => string(32) "163b5033b927410496f7a8a52c0e1340"
    ["content_type"] => string(16) "xengallery_media"
    ["content_data"] => array(1) {
      ["category_id"] => string(2) "18"
    }
    ["upload_type"] => string(12) "image_upload"
  }
  ["_POST"] => array(5) {
    ["image_url"] => string(44) "http://s20.postimg.org/5khh8lf4d/dsc0123.jpg"
    ["_xfRequestUri"] => string(25) "/media/add?category_id=17"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
Have you recently changed anything? It looks like there's a call to realpath that's failing which might indicate there's a permission issue somewhere in the hierarchy (this might need to be something for us to handle).
 
Have you recently changed anything? It looks like there's a call to realpath that's failing which might indicate there's a permission issue somewhere in the hierarchy (this might need to be something for us to handle).
There is indeed a call to realpath here which is likely superfluous...

Any thoughts?

Code:
Server Error Log
Error Info
ErrorException: tempnam(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/nginx/domains/pijanitvor.com/public/:/usr/local/lib/php/:/tmp/) - library/XenGallery/Helper/Image.php:109
Generated By: Branko, A moment ago
Stack Trace

#0 [internal function]: XenForo_Application::handlePhpError(2, 'tempnam(): open...', '/home/nginx/dom...', 109, Array)
#1 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Helper/Image.php(109): tempnam('/', 'xfmg')
#2 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Helper/Image.php(44): XenGallery_Helper_Image->setPathToTempFiles('/home/nginx/dom...')
#3 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/Model/File.php(75): XenGallery_Helper_Image->__construct('/tmp/xfmgFa8hq5')
#4 /home/nginx/domains/pijanitvor.com/public/library/XenGallery/ControllerPublic/File.php(378): XenGallery_Model_File->insertUploadedAttachmentData(Object(XenForo_Upload), 4358)
#5 /home/nginx/domains/pijanitvor.com/public/library/XenForo/FrontController.php(351): XenGallery_ControllerPublic_File->actionDoDownload()
#6 /home/nginx/domains/pijanitvor.com/public/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#7 /home/nginx/domains/pijanitvor.com/public/index.php(13): XenForo_FrontController->run()
#8 {main}

Request State

array(3) {
  ["url"] => string(172) "https://www.pijanitvor.com/media/files/do-download?hash=163b5033b927410496f7a8a52c0e1340&content_type=xengallery_media&content_data[category_id]=18&upload_type=image_upload"
  ["_GET"] => array(5) {
    ["/media/files/do-download"] => string(0) ""
    ["hash"] => string(32) "163b5033b927410496f7a8a52c0e1340"
    ["content_type"] => string(16) "xengallery_media"
    ["content_data"] => array(1) {
      ["category_id"] => string(2) "18"
    }
    ["upload_type"] => string(12) "image_upload"
  }
  ["_POST"] => array(5) {
    ["image_url"] => string(44) "http://s20.postimg.org/5khh8lf4d/dsc0123.jpg"
    ["_xfRequestUri"] => string(25) "/media/add?category_id=17"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}
If you were to edit the file library/XenGallery/Helper/Image.php and simply remove line 107, does it work as expected without the error?
 
@Mike, @Chris D - I think that error is connected with open_basedir restrictions setting on Centmin mod.
@eva2000 solution is below:

Code:
Centmin Mod 1.2.3-eva2000.08+ and higher have open_basedir enabled in /usr/local/nginx/conf/php.conf include file. This file is included in each created Nginx vhost config file i.e. /usr/local/nginx/conf/conf.d/newdomain.com.conf. The relevant line is the 9th line in /usr/local/nginx/conf/php.conf

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass   127.0.0.1:9000;
    #fastcgi_pass   unix:/tmp/php5-fpm.sock;
    fastcgi_index  index.php;
    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME    $request_filename;
    fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;

This line locks you to each Nginx vhost's document web root i.e. /home/nginx/domains/newdomain.com/public.

    fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;

You can disable this globally across all Nginx vhosts, by commenting out the line and restarting Nginx and PHP-FPM services.

    #fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;


Similiar error show with @SneakyDave backup addon:

Code:
Server Error Log
Error Info
ErrorException: fopen(): open_basedir restriction in effect. File(/home/nginx/domains/pijanitvor.com/backup/auto_xen_mod/.ForumBackup_c2d825a.cnf) is not within the allowed path(s): (/home/nginx/domains/pijanitvor.com/public/:/usr/local/lib/php/:/tmp/) - library/SolidMean/ForumBackup/CronEntry/Backup.php:218
Generated By: Unknown Account, 24 minutes ago
Stack Trace

#0 [internal function]: XenForo_Application::handlePhpError(2, 'fopen(): open_b...', '/home/nginx/dom...', 218, Array)
#1 /home/nginx/domains/pijanitvor.com/public/library/SolidMean/ForumBackup/CronEntry/Backup.php(218): fopen('/home/nginx/dom...', 'w')
#2 /home/nginx/domains/pijanitvor.com/public/library/SolidMean/ForumBackup/CronEntry/Backup.php(46): SolidMean_ForumBackup_CronEntry_Backup::writeTempConfig('/home/nginx/dom...', Object(SolidMean_ForumBackup_Helper_Log))
#3 [internal function]: SolidMean_ForumBackup_CronEntry_Backup::saveDatabase(Array)
#4 /home/nginx/domains/pijanitvor.com/public/library/XenForo/Model/Cron.php(357): call_user_func(Array, Array)
#5 /home/nginx/domains/pijanitvor.com/public/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#6 /home/nginx/domains/pijanitvor.com/public/library/XenForo/Model/Deferred.php(295): XenForo_Deferred_Cron->execute(Array, Array, 7.9999971389771, '')
#7 /home/nginx/domains/pijanitvor.com/public/library/XenForo/Model/Deferred.php(429): XenForo_Model_Deferred->runDeferred(Array, 7.9999971389771, '', false)
#8 /home/nginx/domains/pijanitvor.com/public/library/XenForo/Model/Deferred.php(374): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#9 /home/nginx/domains/pijanitvor.com/public/deferred.php(23): XenForo_Model_Deferred->run(false)
#10 {main}

Request State

array(3) {
  ["url"] => string(39) "https://www.pijanitvor.com/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(3) {
    ["_xfRequestUri"] => string(84) "/threads/kratki-izvjestaji-sto-trenutno-grize-gdje-grize-i-na-sta-grize.1410/page-94"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}


When I commented that line,
Code:
#fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;

and restart Nginx and php-fpm, I tried run manually cron for database backup and all went OK, so I think that same will be OK with Gallery addon too. I can not reproduce gallery error cause it is come from my user, and I do not know what he he did exactly.
 
Yeah, certainly it is that config that is the culprit, but at the same time we may well be able to change the code slightly to avoid that cropping up for others when using the gallery.

The user appears to have triggered it by using the "Upload an image from a URL" option if that helps, though it does sound like your best solution might be to adjust the open_basedir setting.
 
Back
Top Bottom