Apache environment strangeness

Dan Coutu coutu at snowy-owl.com
Fri Apr 27 10:02:49 EDT 2007


Background: RHEL 4, Apache 2.0.52

An intranet site that uses basic authentication for login has some CGI
code that checks the value of REMOTE_USER in order to determine the
login name of the current visitor. Pretty simple eh?

The strange part is that in PHP I can fetch the REMOTE_USER value just
fine and using phpinfo() shows it properly defined.

>From within the very same browser I then visit a URL that is a perl cgi
program that simply dumps the environment out and it show that
REMOTE_USER *is not defined*! Huh? There are scripts in other languages
that also fail to find a definition for REMOTE_USER. I don't get it. The
web context is identical aside from the name of the program code being
executed and the specific language that the code is written in. But that
should have no affect whatsoever on the web environment.

FYI, here's the perl that dumps the environment:

#!/usr/bin/perl

print("Content-type: text/plain\n\n");
foreach $key (keys(%ENV)) {
     print("${key}: ${ENV{${key}}}\n");
}
exit;

Has anyone ever seen such a thing?

Dan



More information about the gnhlug-discuss mailing list