Problem creating directory when download/installing new themes and modules, BUG or?

spiffen

Joined: 2010-01-17
Posts: 8
Posted: Tue, 2010-08-31 12:44

Hi.

I'm having problems trying to download and install new themes and modules.

The Modules and Themes directories both have correct access rights (0770).

When trying to install I get the following error

Quote:
Error (ERROR_PLATFORM_FAILURE) : Couldn't create directory [/usr/home/web/album/themes/fluid/] in modules/core/classes/GalleryRepository.class at line 601 (GalleryCoreApi::error)
in modules/core/classes/GalleryRepository.class at line 663 (GalleryRepository::downloadAndUnpack)
in modules/core/classes/AdminRepositoryDownloadAndInstallController.class at line 93 (GalleryRepository::downloadPackagesForPlugin)
in ??? at line 0 (AdminRepositoryDownloadAndInstallController::performDownloadAndInstallation)
in modules/core/classes/GalleryTemplateAdapter.class at line 1092
in g2data/smarty/templates_c/%%301620551/lofblom/%%C3^C3C^C3C22032%%theme.tpl.php at line 112 (GalleryTemplateAdapter::trailer)
in lib/smarty/Smarty.class.php at line 1255
in modules/core/classes/GallerySmarty.class at line 61 (Smarty::fetch)
in modules/core/classes/GalleryTemplate.class at line 241 (GallerySmarty::fetch)
in main.php at line 506 (GalleryTemplate::display)
in main.php at line 104
in main.php at line 88

After some debugging I found out that the problem is method "mkdir()" in GalleryPlatform.class. It seems the PHP can't create the directory if the $path string includes a trailing slash. Not sure if this is unique to my host or not, because I think this has worked before without any problems.

What I did to fix this was to add an Regexp to the function call to PHP's "mkdir()" function that removes trailing slashes.

Quote:
// $results = mkdir($path, $octalPerms);
$results = mkdir(preg_replace('/\/$/', '', $path), $octalPerms);

BR
Emil

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Tue, 2010-08-31 13:30

This works on almost all other platforms, so I doubt it's much of a bug otherwise we've have heard about this by now. Since this doesn't sound like a major security issue not much will be done about it since G2 is no longer in active development and all new development efforts are currently focused on G3.

But for reference and so we have it documented could you post your system information? What OS you're using, web server, version of Gallery, version of PHP, etc? I think most of that can be gathered from Site Admin > Maintenance > System Info.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
spiffen

Joined: 2010-01-17
Posts: 8
Posted: Tue, 2010-08-31 19:39

I tried to add new albums and that works without any problems, perhaps the $path string is sent without the trailing slash in that situation.

Here's the systeminfo:

Quote:
Gallery URL = http://www...
Gallery version = 2.3.1 core 1.3.0.1
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.5 apache2handler
Webserver = Apache/2.0.63 (FreeBSD) PHP/5.2.5 with Suhosin-Patch
Database = mysqlt 5.1.30-log, lock.system=flock
Toolkits = Gd
Acceleration = none/0, none/0
Operating system = FreeBSD 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Wed Jan 16 04:45:45 UTC 2008

:/usr/obj/usr/src/sys/SMP i386
Default theme = lofblom
gettext = enabled
Locale = sv_SE
Browser = Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4
Rows in GalleryAccessMap table = 26
Rows in GalleryAccessSubscriberMap table = 2538
Rows in GalleryUser table = 3
Rows in GalleryItem table = 2538
Rows in GalleryAlbumItem table = 36
Rows in GalleryCacheMap table = 0

 
spiffen

Joined: 2010-01-17
Posts: 8
Posted: Tue, 2010-08-31 19:38

Hi.

Did some searches on internet and I think I found out what caused this.

It's a combination between Safe Mode Enabled and PHP version.

Safe Mode has always been enabled on my host. Before I didn't have this problem, but it was when my host upgraded the PHP version it started.

So there are three ways to fix the problem:
1. Remove the trailing slash from the script code
2. Downgrade to < PHP 5.1.6
3. Turn safe mode off

I had to go with option 1, since I'm not authorized to change the other two.

Perhaps you should have this in mind, remove the trailing slash, when developing Gallery3 to make it more compatible with different platform configuration.

BR
Emil

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Tue, 2010-08-31 19:58

No official or officially supported version of Gallery has ever ran under safe_mode, nor will safe_mode ever be supported. Safe_mode is a 100% flawed system/hack and the PHP devs have finally come to that realization. It's being removed from future versions of PHP. Secure the system properly, not through hacks like safe_mode. If they allow ANY other language on their servers, python, perl, cgi, etc every single "security" feature of safe_mode has just been bypassed.

We will not spend any time troubleshooting any systems or problems crippled by safe_mode.

If your host is relying on safe_mode to "secure" their system, they are living under a false sense of security.

So, no this isn't a bug or a problem with Gallery. It's a problem with hosts who rely on bad practices.

See the warning here:
http://php.net/manual/en/features.safe-mode.php
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here