set_time_limit() and my host

fabioassis

Joined: 2004-09-28
Posts: 1
Posted: Tue, 2004-09-28 19:42

I have that problem with set_time_limit():

Warning: set_time_limit() has been disabled for security reasons in /home/restricted/home/vresportes/public_html/gallery2/modules/core/classes/Gallery.class on line 474

I know that I need my host to change some configs somewhere. But they told me they can't change anything because that's an "internal security issue"...

Anyway...I can't change my host, so I need a change in G2.

Any ideas?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2004-09-28 22:13

modules/core/classes/Gallery.class

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Thu, 2004-09-30 19:44

@fabioassis

I'm currently also 'evaluating' Gal2 with safe_mode=on - environments, 'cause most 'cheap' webspace has it turned on.

1. Backup your Gallery.class in dir /modules/core/classes/
2. Edit Gallery.class
3. Jump to line 465
Delete or comment it out:

//    function guaranteeTimeLimit($limit) {
//	if ($limit <= 0) {
//	    $limit = 30;
//	}
//	
//	$now = time();
//	if (empty($this->_timeLimit) || ($this->_timeLimit - $now < $limit)) {
//	    $this->debug("[$now] can't guarantee $limit -- extending!");
//

then to line 475

//	    $this->_timeLimit = $now + max($limit, 30);
//	    set_time_limit($this->_timeLimit - $now);
//

then to line 483

//	    $ret = GalleryCoreApi::refreshLocks($this->_timeLimit);
//	}
//   }

4. save it. (line-numbers can differ +/-1)

Then you will get another error:

Fatal error: Call to undefined function: guaranteetimelimit() in ... modules/core/classes/helpers/GalleryEntityHelper_simple.class on line 48

5. Backup your GalleryEntityHelper_simple.class in dir modules/core/classes/helpers/
6. Edit GalleryEntityHelper_simple.class

Jump to line 48 -> $gallery->guaranteeTimeLimit(5);

Delete or comment it out:

// $gallery->guaranteeTimeLimit(5);

7. Save it -> load both files up and the set_time_limit error is gone

Hope it helps :)

Greets Ron :)

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Fri, 2004-10-01 12:44

@fabioassis

found some more pieces you have to change :

Fatal error: Call to undefined function: guaranteetimelimit() in ../modules/core/classes/GalleryPlatform/UnixPlatform.class on line 47

Edit UnixPlatform.class in dir modules/core/classes/GalleryPlatform/

line : 47 -> $gallery->guaranteeTimeLimit(5);

look above: -> // $gallery->guaranteeTimeLimit(5);

Fatal error: Call to undefined function: guaranteetimelimit() in ../modules/core/classes/GalleryStorage/DatabaseStorage.class on line 267

Edit -> modules/core/classes/GalleryStorage/DatabaseStorage.class

line : 267 + 278 -> //	$gallery->guaranteeTimeLimit(5);

Then:

Fatal error: Call to undefined function: guaranteetimelimit() in ../modules/core/classes/helpers/GalleryLockHelper_medium.class on line 250

Fatal error: Call to undefined function: guaranteetimelimit() in ../modules/core/classes/helpers/GalleryLockHelper_medium.class on line 273

Also edit -> modules/core/classes/helpers/GalleryLockHelper_medium.class

line : 250 + 273 -> // $gallery->guaranteeTimeLimit(5);

Hope it works :) Ron

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2004-10-01 14:50

not sure what you're trying to do, but it would certainly be easier to comment out the content of guaranteeTimeLimit() instead of commenting out the whole method.. then you don't have to find all the places where the method is called....

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7993
Posted: Fri, 2004-10-01 18:43

If you disable that code, you're probably going to wind up with strange and wonderful data integrity errors somewhere down the line, if you ever do long running operations in G2 (like migrations). After 30 seconds, PHP will yank the rug out from under G2 leaving it in whatever weird state it happened to be in at that moment.

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Fri, 2004-10-01 20:41

@mindless -> not much so far, just trying G2 on a "free" Webspace with safe_mode=on and other "disabled" settings - after going through these steps 'above' it works so far. Looking deeper in it ...
@bharat -> right, but there's no other chance to test G2 with these 'predefined' Webspace-settings. No exec_calls and other stuff.
Of course not recommended for 'any' productive environment, but for testing G2 ...

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Fri, 2004-10-01 23:45

@mindless
What did you mean with 'comment out the content' ?? - just for the 'clueless' :wink: - it is my first contact with G2, and just started to look into it - and
:o , of course.

@bharat
Have got the G2 to run, basically, with these restrictions, made by the hoster (not to blame him, because its completely free, no popups and banners, no storage limitation, PHP + mySQL, FTP, one can run Portals: Mambo, PHPKIT, Boards: phpBB2, phpBB2 Plus, YaBB SE Power Board, Galleries: 4images, Coppermine without probs, and that with absolutely no costs - so IMHO it is ok :D

disable_functions:
shell_exec,highlight_file,diskfreespace, exec, passthru, system, popen, fsockopen, pfsockopen, show_source, php_uname, ini_alter, ini_restore, ini_set, getrusage, get_current_user, set_time_limit, getmyuid,  dl, leak, listen, chown, chgrp, tmpfile, link, mb_send_mail, proc_open,proc_nice,proc_terminate,proc_close,proc_get_status

But after looking a bit deeper into G2 i assume one will make no headway having such 'restrictions', because G2 is so sophisticated.

Right ?

With all the functions of G2 and the the basic intention of G2 there is also the need for a 'better' webspace - at least without such rigid restrictions ?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2004-10-02 00:44

I meant, change // function guaranteeTimeLimit($limit) { to function guaranteeTimeLimit($limit) { }
Ie, make it a function that does nothing instead of removing the function completely, thus breaking code trying to call the function.

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Sat, 2004-10-02 00:56

:oops: thx -> you helped the 'blind' :oops:

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7993
Posted: Sat, 2004-10-02 04:39
testguy wrote:
disable_functions:
shell_exec,highlight_file,diskfreespace, exec, passthru, system, popen, fsockopen, pfsockopen, show_source, php_uname, ini_alter, ini_restore, ini_set, getrusage, get_current_user, set_time_limit, getmyuid,  dl, leak, listen, chown, chgrp, tmpfile, link, mb_send_mail, proc_open,proc_nice,proc_terminate,proc_close,proc_get_status

But after looking a bit deeper into G2 i assume one will make no headway having such 'restrictions', because G2 is so sophisticated.

Right ?

With all the functions of G2 and the the basic intention of G2 there is also the need for a 'better' webspace - at least without such rigid restrictions ?

I think that G2 can probably run in that environment. After you disable the set_time_limit code, think that most of the other stuff is ok. You won't be able to use the ImageMagick or NetPBM graphics toolkits, but you can use GD so you're good there. You won't be able to use the PhotoAccess printing module, or the "Add items from the Web" upload option because both of those require fsockopen. Otherwise, I think it'll work.

G2's goal is to run reliably, on as many servers as possible. Without set_time_limit, it's hard to really run reliably, but if you use it judiciously you might be ok. We could potentially jump through some crazy hoops to get around the time limit problem (but we won't be working on doing that any time soon). Because we have a modular setup, some modules won't function properly in all environments -- but that's ok since you're not forced to use them and we're working hard on coming up with more alternatives.

 
testguy

Joined: 2004-05-27
Posts: 18
Posted: Sat, 2004-10-02 10:52

@bharat
:) thank you and mindless thousand times !! For your patience, helpfulness with all those questions, probs and users ;) , and, your passion and brain to develop and code such an app as G2 !

G2 is definitively RUNNING - with ALL those restrictions ! Exactly as you
told, bharat :) - but one can live without some 'features' of G2, so far :)

Just have a short look - nothing much to expect yet ;), but the 'live proof' it is running - and this on a FREE webspace :D

http://pictures.ohost.de

Soon coming also http://picture.funpic.de
The second absolutely free webspace :D

Being now quite a long time with G1 -> actual, i was very keen to look into G2, because its development goes ahead rapidly.
And, look at the sig :lol:, i'm testing a lot of other apps and galleries too.

First, i am doing this always on webspace, one can regard as 'most spread' in reference to the 'number' of people using it.
There's no question about it, the 'masses' do still have 'cheap' and/or 'free' webspace, because the 'basic' performances are enough for private and hobby use.
Especially Galleries are springing up like mushrooms everywhere, sometimes i think - "Wow, the 100000's invention of the wheel" 8)
And, mostly coded by very young ppl, just for fun and/or for the use on their 'restricted' webspace, and for putting up their Fun- / Party Pics.

I do not want to judge over all those 1000's of Gallery apps, because everyone should do what he wants to :)
But there's so much to 'keep' in mind with 'using' an app on a webspace - SECURITY - is my first point !
And, because of this, my very own opinion is very clear and easy :) ...

Gallery is one of those app's, i would recommend !
Definitely no one has to be afraid of being alone, feeling insecure etc., because of the wonderful 'community' behind the project G (Project Gallery ;) )

So, of course, IMHO, i am very interested in G2 running in such environments, too. YES, maybe WITHOUT ALL features the Pro app G2 HAS to offer, but this is still MORE than enough :D - or more than other's have !

So, thx again, bharat + mindless (<- 8) ...helping the blind... ) and of course all the other coders, contributors and helpers of the G - PROJECT !

 
richjive

Joined: 2005-10-18
Posts: 1
Posted: Tue, 2005-10-18 05:11

hello, I know this topic has since died down, but I am also a user of gallery or at
least was. When I switched providers I didnt know the one I went to had safemode enabled.

Anyways, was just wondering if anyone did any more tinkering and was able to get G2
to be even more compatible with safemode enabled. yes I know, huge thorn in the butt,
get an ISP that doesnt enable it, and all them other things, but was just wondering.. if maybe,
someon has this done already. Thanks

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-10-18 12:50

Not any more tinkering than you've found already.

http://codex.gallery2.org/index.php/Gallery2:faq#Does_G2_work_with_Safe_Mode_PHP.3F

http://gallery.menalto.com/node/3017

And this comment above:
http://gallery.menalto.com/node/21574#comment-75954

If you have more questions please start a new thread, though if they are about safe_mode you won't get a lot more info :)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
djg2005

Joined: 2006-07-13
Posts: 1
Posted: Thu, 2006-07-13 15:02

I'm having a headache with this too. My host is a paid host (AwardSpace) and they have disabled get_time_limit().

I tried commenting out the content of the function as suggested above (and placing it with empty parenthesis)
but to no avail. I am still getting:

Core module is only partially installed.
Error installing Gallery Core

There are no errors or warnings on that page except the step is failing. Obviously in the System step it is saying
Warning next to set_time_limit() allowed.

The log file is here ~ http://www.porkyisback.com/g2data//install_03a4e.log

Hope I could get some help here,
thanks. All the best.

 
liquid-motion

Joined: 2009-03-14
Posts: 3
Posted: Sun, 2009-03-15 13:08
djg2005 wrote:
Hope I could get some help here,
thanks. All the best.

Try the patched version of Gallery 2.3, which is working with safe mode enabled and can be found at: http://www.liquid-motion.nl/dl/download.php?t=f&i=1.