[apache and perl] using firefox

Greetings !!

I’m trying to go back at the apache web server but I had a strange behaviour concerning a perl script I did long time ago.

At this time, I remember have had the same behaviour: the web browser opens a dialog box with the “.pl” file and asks for “save” or “open with” and that’s all.

looking at the error_log I found there were errors in the script and strangely even if I put the whole block in comments this script acts the same (??)

but the main issue is that the .pl files are opened as every files in the web with this dialog box asking for “save” or “open with”.

I put

AddHandler cgi-bin .pl

in the configuration file concerning the web site I’m actually testing… last time I had the issue the browser displayed the perl file’s content… but this time…

I’ll go back in front monday and will add more informations concerning my troubles ^^

soundlord wrote:

> At this time, I remember have had the same behaviour: the web browser
> opens a dialog box with the “.pl” file and asks for “save” or “open
> with” and that’s all.

That is because the script was not executed.

> but the main issue is that the .pl files are opened as every files in
> the web with this dialog box asking for “save” or “open with”.
>
> I put
> Code:
> --------------------
> AddHandler cgi-bin .pl
> --------------------

Shouldn’t that be:

Addhandler cgi-script .pl


Per Jessen, Zürich (23.6°C)
http://en.opensuse.org/User:Pjessen

Oups !!
I was thinking cgi-script and typed cgi-bin.
I spent too much time with the scriptalias /cgi-bin/ etc… that I was confused…
I’ll go back on monday, today I’m not at the location to export the code samples and so on…

If you put scripts in the cgi-bin directory, or any directory indicated by a ScriptAlias directive, then you don’t need to specify AddHandler. AddHandler is only when you have .pl files in what are normally content directories. One school of thought is that content files should be separated from script files, but PHP has blurred the distinction.

And this is even before we get to mod_perl which is distinct from CGI.

All my apologizes !!

To make sure your script written in perl will be executed (not displayed nore causing the browser to ask you for open or save) you have to check the file mod_mime-defaults.conf and verify that this entry is listed:

AddType perl .pl	

otherwise none of your scripts would be executed…

I tried with chmod +x and so on… this doesn’t matter, the apache server is the only one to “decide” if a script would be executed or not…

Thank you for your patience, hope this thread will be helpfull for those in the same confusing situation than me…

Jah guidance everytime !

Hi, I have a similar problem. But my script works 7 out of 10 times. The remaining 3 times, instead of executing the script, the browser pop up a dialogue box to save the “.pl” file. The gui page has many links which is written in mod perl and the problem occurs only for one script. The mime-type and the content-type is declared as required. I have done a lot of analysis, but could not able to resolve the problem.

The earlier version works fine. The new version includes centrified code for using the windows id to login instead of UNIX id through browser. That’s where the problem occurs.

Newly included code is pasted below:

sub verify_login
{
print STDERR "in sub verify_login
" ;
#my $userid = @[0];
#my $passwd = @
[1];
my $user_id = $[0] ;
my $password = $
[1];
print STDERR "JBC: Checking userid $user_id $nt_id
";
my $errCode = 1;
my $nt_id = /bin/adquery user -M ${user_id} ;
print STDERR "JBC: Checking userid $user_id $nt_id
";
chomp ($nt_id);
$user_id = /bin/adquery user -n ${user_id} ;
chomp ($user_id);
print STDERR "JBC: Checking userid $user_id $nt_id
";

    print STDERR " Inside of verify_login function - Testing : Function : verify login : userid - $user_id nt_id $nt_id

";
print &::HTMLHeader(“Verifying $user_id PXED Username $nt_id”);
print &::PrintBanner;
my $ldap = Net::LDAP->new($::appinfo{PXEDSVR});
my $mesg = $ldap->bind($::appinfo{PXEDSVCACCT},password=>$::appinfo{PXEDPASSWD});
print STDERR $mesg->error(), " binded
";
$mesg->code && die $mesg->error;
$ENV{REMOTE_USER} = $user_id;
print "<br>CDARS (<i>‘Unix’</i>) Username: $user_id REMOTE_USER: $ENV{REMOTE_USER})
";
print "<br>PXED (<i>‘Windows’</i>) Username: $nt_id
";
print “<br>Verifying PXED (<i>‘Windows’</i>) Password…
“;
#now search for a username
$mesg = $ldap->search(base=>“dc=pxed,dc=pfizer,dc=com”, filter=>”(cn=${nt_id})”, sizelimit=>1);
# now bind the username
print STDERR “<p>” . $mesg->error . "
</pre>
";
#$mesg->code && die $mesg->error;
if ( $mesg->count != 1 ) {
print STDERR " ldap search found 1 search entry inside message count
";
print "<p><font color=‘red’>Couldn’t find userid $nt_id in PXED.</font>
";
print "<br>Hit the Back button and try again.
";
$errCode = 0;
}
else {
foreach my $entry ($mesg->entries) {
print STDERR " Starting for loop ldap search

";
$entry->dump;
my $dn = $entry->dn();
my $displayName = $entry->get_value(‘displayName’);
my $loginDisabled = $entry->get_value(‘loginDisabled’);
my $deactivationDate = $entry->get_value(‘pfizerDeActivationDate’);
my $mail = $entry->get_value(‘mail’);
my $position = $entry->get_value(‘pfizerPositionDescription’);
print "<p>LDAP dn:$dn
<br>Display Name: $displayName
<br>is Login Disabled: $loginDisabled
DeActivation Date $deactiva
tionDate
<br>email: $mail
<br>Position: $position
";
if ( $loginDisabled eq “TRUE” ) {
print STDERR " Inside if login disabled true

";
print "<p><font color=‘red’>Account DISABLED</font>
";
$pxeduser{$ENV{REMOTE_USER}} = “”; # wipe it out!
print "Please hit the BACK button and try again
";
$errCode = 0;
} else {
print STDERR " Inside else login disabled false

“;
# verify the password
# my $mesg = $ldap->bind(”$dn",password=>"$passwd");
my $mesg = $ldap->bind("$dn",password=>"$password");
print “<p>”, $mesg->error(), "<b> when authenticating user $displayName</b><p>
";
if ( $mesg->code ) {
print STDERR " Inside if message code true

";
# not ok, have 'em try again!
print STDERR $mesg->error(), " -- $displayName
";
$pxeduser{$ENV{REMOTE_USER}} = “”; # wipe it out!
print "Please hit the BACK button and try again
";
$errCode = 0;
}
else {
print STDERR " Inside else message code true

";
print “user account verfied
<p>”;
# now add to global hash
# ok the password is good, save to the LDAP database
$ENV{REMOTE_USER} = $user_id ;
#JBC Was here
#$pxeduser{$ENV{REMOTE_USER}} = $user_id;
#$cdarsuser{$user_id} = $ENV{REMOTE_USER};
#print $pxed_fh "$ENV{REMOTE_USER}:$user_id
";
#print $cd_fh "$user_id:$ENV{REMOTE_USER}
";
$pxeduser{$user_id} = $nt_id;
$cdarsuser{$user_id} = $user_id;
$pxeduser{$nt_id} = $nt_id;
$cdarsuser{$nt_id} = $user_id;
print $pxed_fh "$nt_id:$user_id
";
print $cd_fh "$user_id:$nt_id
";
print $pxed_fh "$user_id:$user_id
";
print $cd_fh "$nt_id:$nt_id
";
#JBC done
#JBC done

print "User added to CDARS’s PXED User database.

";

print "Thank you.

";

print "<p><input type=button value=‘Continue’ onClick=“window.location=’$::input{url}’”>

";
print STDERR "Inside Message Code.
";
} #$mesg->code
print STDERR " end of the block loginDisabled .
";
} # loginDisabled
print STDERR "looping for loop .
";
} # for loop
} # main if
print STDERR "end of the verify login
";
return $errCode ;
}
sub login {
print STDERR "in sub login
" ;
my $r = shift;
my $r_uri = $r->uri;
my %param = $r->method eq ‘POST’ ? $r->content : $r->args;
my $user_id = $param{‘user_id’};
my $nt_id;
print STDERR "login: user_id:$user_id|
";
if( $user_id ) {
$user_id = /bin/adquery user -n "$user_id"|head -1 ;
chomp ($user_id);
print STDERR "login1: user_id:$user_id nt_id:$nt_id REMOTE_USER:$ENV{REMOTE_USER}
";
$nt_id = /bin/adquery user -M "$user_id"|head -1 ;
chomp ($nt_id);
print STDERR "login2: user_id:$user_id nt_id:$nt_id REMOTE_USER:$ENV{REMOTE_USER}
";
}
my $password = $param{‘password’};
my $msg = “”;
my $url = $param{url} || getURL($r, %param);
if ($user_id && $password) {
# my $pwd = /bin/egrep "^$user_id\:" $::APPDIR/etc/cdars-ypcat | /bin/cut -d":" -f2;
#chomp($pwd);
#if ($pwd && (crypt($password, $pwd) eq $pwd)) {
if (verify_login($nt_id, $password)) { ------ new function is called here
existing code
}
}

The above code is included in login.pm page and the pop up error occurs for top.pl page (there is no change in top.pl page)

Could you please help me here to find out the problem.

Regards
Ravi

ravindranr81 wrote:
> Hi, I have a similar problem.

When you find yourself writing those words, it is almost always a signal
that you should be starting a new thread instead!

In this case you are also resurrecting a 3-year old thread, so you
definitely should start a new thread.

When you do so, please post your code using Code tags; it’s unreadable
like it is. Also please give a full, self-contained explanation of the
situation and the problem.