• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4296: Configure crashes due to unset variable (Webserver_uid)

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine Configure Normal No Action Required TWiki:Main.RichardDonkin n/a  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


Configure crashes in CGISetup.pm - not sure why we are using these variables or what is supposed to set them (can't we just use the Perl get*uid() type functions?) but removing them stops the crash.
From apache error log:
[Sun Jun 24 09:54:59 2007] configure: Use of uninitialized value in concatenation (.) or string at /home/twikidev/lib/TWiki/Configure/Checkers/CGISetup.pm line 196.

I was running TWiki4.1 from SVN before (Mar 07) then recently (last week or two) did an svn up to 14213 etc, which is when the configure problems started.

This patch prevents this crash, but we need a replacement that does what was intended.

Index: lib/TWiki/Configure/Checkers/CGISetup.pm
--- lib/TWiki/Configure/Checkers/CGISetup.pm    (revision 14256)
+++ lib/TWiki/Configure/Checkers/CGISetup.pm    (working copy)
@@ -194,8 +194,11 @@
     $block .= $this->setting('mod_perl', $n);

     $block .= $this->setting(
-        'CGI user', 'userid = '.$::WebServer_uid.' groups = '.
-          $::WebServer_gid.''.
+       # RD Hack to demonstrate bug
+        # 'CGI user', 'userid = '.$::WebServer_uid.' groups = '.
+        'CGI user', 'userid = '.' groups = '.
+          # $::WebServer_gid.''.
+          ''.
                 'Your CGI scripts are executing as this user.'));

My environment is:

  • Ubuntu 5.10 Breezy
  • Perl 5.8.7
  • Apache 2.0.54 (Ubuntu)

No clever setup, just the vanilla Ubuntu Apache2 and Perl, and I'm running in CGI mode not mod_perl.

The old testenv code looked like this and would work fine on almost any Perl - found this on the web, but the most recent testenv code might have some fixes re BSD etc:

446           # Get web server's user and group info
447	my $usr = "";
448	my $grp = "";
449	if( $OS eq 'UNIX' or  ($OS eq 'WINDOWS' and $perltype eq 'Cygwin' ) ) {         
450	    $usr = lc( getpwuid($>) );          # Unix/Cygwin Perl - effective UID
451	    foreach( split( " ", $( ) ) {
452	        my $onegrp = getgrgid( $_ );
453	        $grp .= " " . lc($onegrp);
454	    }
455	} else {                                # ActiveState or other Win32 Perl
456	    $usr = lc( getlogin );
457	    # Try to use Cygwin's 'id' command - may be on the path, since Cygwin
458	    # is probably installed to supply ls, egrep, etc - if it isn't, give up.
459	    # Run command without stderr output, to avoid CGI giving error.
460	    # Get names of primary and other groups.
461	    $grp = lc(qx(sh -c '( id -un ; id -gn) 2>/dev/null' 2>nul ));
462	    if ($?) { 
463	        $grp = "[Can't identify groups - no Cygwin 'id' or 'sh' command on path]";
464	    }
465	}

Setting this to Urgent as having configure crash on a common Linux setup is not great.

-- TWiki:Main/RichardDonkin - 24 Jun 2007

I don't understand; the error message (supportsRegistration) has nothing to do with configure, it is in code that is only run after a TWiki object is created, which never happens in configure. Are you really getting that error from configure? I really can't imagine how the patch stops that error; how did you make the connection from the Users code to configure?

On the assumption that the error message is not the one you meant to report, what is the error message you see? $WebServer_uid and =$WebServer_gid are calculated in code in configure, as early as possible to avoid corruption and make them avaiable for reporting. They are calculated using (almost) the same methodology as was used in testenv viz.

# Get web server's user and group info
use vars qw($WebServer_uid $WebServer_gid);
$WebServer_uid = $WebServer_gid = '';

eval {
    $WebServer_uid = getlogin() || getpwuid($>) || '';

eval {
    $WebServer_gid = join(',', map { lc(getgrgid( $_ )) } split( ' ', $( ));
if( $@ ) {
    # Try to use Cygwin's 'id' command - may be on the path, since Cygwin
    # is probably installed to supply ls, egrep, etc - if it isn't, give
    # up.
    # Run command without stderr output, to avoid CGI giving error.
    # Get names of primary and other groups.
    $WebServer_gid = lc(qx(sh -c '( id -un ; id -gn) 2>/dev/null' 2>nul ));
The calculation is done without reference to OS and perltype because they haven't been calculated at the time the UID and GID are first required. My best guess is that the Ubuntu platform isn't returning a standard value for getlogin or getgrgid. Can you insert debugging in configure to narrow it down, please?


Sorry, was reporting a few different error messages and pasted in the wrong one, now fixed. The patch shows that it is these two variables specifically causing the problems, since applying it fixes the crash.

I've now put some debug in bin/configure just after that code which shows it's working fine there - a die produces:

  • Userid is www-data, Groupid is www-data,www-data at configure line 132.

And now this is working fine... Very odd, it was quite repeatable earlier today and yesterday.

-- TWiki:Main.RichardDonkin - 24 Jun 2007

BTW it would be best to not use getlogin at all, as I recall that on a FreeBSD email list it was discussed that this provides the wrong UID. I only used it in testenv for the ActivePerl case, not for the Unix case (following this feedback).

-- TWiki:Main.RichardDonkin - 24 Jun 2007

This is set to be a release blocker, better make a decision on how to move forward on it.

-- TWiki:Main.SteffenPoulsen - 26 Aug 2007

This turned out not to be reproducible, so have set to No Action Required.

-- RichardDonkin - 27 Aug 2007

Summary Configure crashes due to unset variable (Webserver_uid)
ReportedBy TWiki:Main.RichardDonkin
Codebase ~twiki4
SVN Range 14256
AppliesTo Engine
Component Configure
Priority Normal
CurrentState No Action Required
WaitingFor TWiki:Main.RichardDonkin

TargetRelease n/a

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r6 - 2007-08-27 - RichardDonkin
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback