The foswiki svn repository is obsolete. Developers should register for a http://github.com/ account for commit access to foswiki project. Github is ready for updates.

Item9710: GATEWAY_INTERFACE deprecated in mod_perl2. Should not be used to determine CLI vs. CGI

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Normal Closed Engine scripts  
Copied from TWikibug:Item6561
/bin scripts check for environment variable GATEWAY_INTERFACE to determine if they are run via CLI or CGI/mod_perl. However, mod_perl 2 defines MOD_PERL environment variable instead. The check should be:

if ( defined $ENV{GATEWAY_INTERFACE} or defined $ENV{MOD_PERL} )

-- TWiki:Main/AvishaiIshShalom - 2010-08-21

Thank you AvishaiIsh for reporting and for providing a solution. I patched all twiki/bin files and twiki/lib/TWiki.pm accordingly. SVN trunk and 5.0 branch are updated.

-- TWiki:Main.PeterThoeny - 2010-08-22

See http://perl.apache.org/docs/2.0/user/porting/compat.html#C__ENV_GATEWAY_INTERFACE__ for more details

Note that as long as PerlOptions +SetupEnv is enabled, mod_perl2 will provide a backwards compatible ENV. However it would probably be safer if we didn't rely on it. Is testing the GATEWAY_INTERFACE the best/preferred way to determine if we are running as a CLI script?

-- GeorgeClark - 18 Sep 2010

This fix will not cause harm, but people should use ModPerlEngineContrib with mod_perl. GATEWAY_INTERFACE is part of CGI RFC. The fix makes more sense on the other project, that lacks native support for environments other than CGI, but it's OK since it doesn't cause harm.

-- GilmarSantosJr - 19 Sep 2010

Does our ModPerlEngineContrib set the GATEWAY_INTERFACE independent of the setting of +SetupEnv? If this change isn't needed, then it should be reverted. No need to add extra comparison overhead if it isn't needed.

I had recently added the test of GATEWAY_INTERFACE to UI.pm - passing through a default userid (and probably breaking authentication) when it's not set.

-- GeorgeClark - 19 Sep 2010

With ModPerlEngineContrib none of those scripts is actually used. Apache is configured to make ModPerlEngineContrib handle the whole bin directory and the scripts are never used. Although, this fix makes sense if people use CPAN:ModPerl::Registry instead of the native engine (and there are people out there using this...).

-- GilmarSantosJr - 19 Sep 2010

One of my changes was to Foswiki::UI - which is still used with ModPerl (See http://trac.foswiki.org/browser/trunk/core/lib/Foswiki/UI.pm?rev=9217#L303) Because CLI doesn't do authentication, it needs to pass through the user name supplied using the CLI -user blah operand. I used the GATEWAY_INTERFACE to detect that the UI was running in the CLI environment. That change is committed to 1.1 as well. The cli scripts were not running under the admin id, and statistics was broken.

Is there a better solution I should use in Foswiki::UI - which unlike the scripts, is after the Engine has gotten control and established the Foswiki environment?

-- GeorgeClark - 19 Sep 2010

I missed the change at Foswiki::UI. That one seems necessary wink

-- GilmarSantosJr - 19 Sep 2010

This probably should be checked in for 1.1.

-- GeorgeClark - 25 Sep 2010
 

ItemTemplate edit

Summary GATEWAY_INTERFACE deprecated in mod_perl2. Should not be used to determine CLI vs. CGI
ReportedBy GeorgeClark
Codebase 1.1.0 beta1, trunk
SVN Range
AppliesTo Engine
Component scripts
Priority Normal
CurrentState Closed
WaitingFor
Checkins Foswikirev:9217 Foswikirev:9342
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r11 - 04 Oct 2010, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License