I have a perl CGI script provided by Lancelot Securities in order to
synchronize a username/password file. Whenever a new user signs up (this is
to my understanding of how the script works by reading it, I have very
little knowledge in perl, and by reading the files) lancelot runs the script
by simply sending a command to it, the script then access¹ lancelot¹s
database and synchs. Anyways I can not get the script to run at all, hell I
can¹t get any script to run it seems. Here¹s what happens when I try to run
a script...

[h24-79-179-67:/library/webserver/cgi-executables] root# perl htadd.pl
[h24-79-179-67:/library/webserver/cgi-executables] root#

It doesn¹t play back ANYTHING! And when I try to run it from my webserver as
CGI it gives a misconfiguration error. I have included the script below.
Please please please help!
I am running the latest version of MAC OS X. The path at the beginning of
the script is right for where my perl is located. There was another script
that created the htadd.cfg file and the only way I was able to get that to
run was to copy the script, type just ³perl² at the command line and then
past the script into it and run it.
---------------------------------------------
#!/usr/bin/perl

##+++++ htadd.pl
##
##    Adds new users id and password to sites htpassword file.
##    Adds nes users id, password, and expiration date to sites expiration
file.
##    Uses the file htadd.cfg to obtain the appropriate path info for
##    the htpassword file, expiration file, and the site's server mail
program.
##
##-----
##
##    Version 2.51
##    
##    Copyright 1998, Validate Inc., All Rights Reserved
##    David Wright
##
##    Do not make any changes to this script except for those permitted by
Validate Inc.
##
##-----
##
##    Creation Date:    1/5/98
##    Last Modified:    8/03/98
##
##-----

print "Content-type: text/html\n";

&parse_form(*FORM);

$lancecode = $FORM{'lancecode'};
$userid = $FORM{'userid'};
$password = $FORM{'password'};
$configfile = $FORM{'configfile'};
$expdate = $FORM{'expdate'};

$exclusive_lock = 2;
$unlock = 8;
$recipient = "tech\@validate.com";
$encrypted_password = &encrypt_passwd($userid, $password);
$newexpireline = join(":",$userid, $encrypted_password, $expdate);
$newhtpassline = join(":", $userid, $encrypted_password);

my $mail_option = 0;
my $expireerror = 0;
my $htpasserror = 0;
my $configerror = 0;

if (open (CONFIG, "$configfile"))
{
    flock (CONFIG, $exclusive_lock);
    $htpasswdfile = <CONFIG>;
    chop($htpasswdfile);
    $expirefile = <CONFIG>;
    chop($expirefile);
    $mailprog = <CONFIG>;
    chop($mailprog);
    flock (CONFIG, $unlock);
    close(CONFIG);
}
else
{
    $configerror = 1;
    $mail_option = 1;
}
if (open (EXPIREFILE, ">>$expirefile"))
{
    flock (EXPIREFILE, $exclusive_lock);
    print EXPIREFILE ("$newexpireline\n");
    flock (EXPIREFILE, $unlock);
    close (EXPIREFILE);
}
else
{
    $expireerror = 1;
    $mail_option = 1;
}

if (open (HTPASSFILE, ">>$htpasswdfile"))
{
    flock (HTPASSFILE, $exclusive_lock);
    print HTPASSFILE ("$newhtpassline\n");
    flock (HTPASSFILE, $unlock);
    close (HTPASSFILE);
}
else
{
    $htpasserror = 1;
    $mail_option = 1;
}

if ($mail_option eq '1')
{
    if (open (MAIL, "|$mailprog $recipient"))
    {
           print MAIL "Reply-to: Lancelot\n";
           print MAIL "From: htadd.pl\n";
           print MAIL "Subject: Error finding file!";
           print MAIL
"------------------------------------------------------\n";
        print MAIL "\n";
        print MAIL "An Error occured during execution of the htadd.pl
program!\n";
        print MAIL "Site with lancecode - $lancecode\n";
        print MAIL "\n";
        if ($configerror)
        {
            print MAIL "Configuration file error!\n";
        }
        if ($expireerror)
        {
            print MAIL "Expiration file error!\n";
        }
        if ($htpasserror)
        {
            print MAIL "Password file error!\n";
        }
        close (MAIL);
    }
    if ($htpasserror || $configerror || $expireerror)
    {
        print "Status: 404\n\n";
    }
}
if (!$htpasserror && !$configerror && !$expireerror)
{
    print "Status: 200\n\n";
}
exit;

##+++++
##
##    Sub:    encrypt_passwd
##
##-----

sub encrypt_passwd
{
    local ($user, $pass) = @_;
    local ($now, $pert1, $pert2, $week, $nsalt);
    local (@saltset) = ('a'..'z','A'..'Z','0'..'9','.','/');
    $now = time;
    ($pert1, $pert2) = unpack("C2", $user);
    $week + $now / (60*60*24*7) + $pert1 + $pert2;
    $nsalt = $saltset[$week % 64] . $saltset[$now % 64];
    return crypt($pass, $nsalt);
}

##+++++
##
## Sub: parse_form
##
##-----

sub parse_form
{
    local (*FORM_DATA) = @_;
    local ($request_method, $post_info, @key_value_pairs, $key_value, $key,
$value);
    read (STDIN, $post_info, $ENV{'CONTENT_LENGTH'});
    @key_value_pairs = split(/&/, $post_info);
    foreach $key_value (@key_value_pairs)
    {
        ($key, $value) = split(/=/, $key_value);
        $value =~ tr/+/ /;
        $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;

        if (defined($FORM_DATA{$key}))
        {
            $FORM_DATA{$key} = join("\0", $FORM_DATA{$key}, $value);
        }
        else
        {
            $FORM_DATA{$key} = $value;
        }
    }
}


---------------------------------------------

Thank you very much for your help!

Cameron Malchow


-- 
Cameron Malchow
[EMAIL PROTECTED]
http://mybliss.gq.nu

³There is no excuse² - Anon


Reply via email to