httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marty Landman <mland...@face2interface.com>
Subject Re: [users@httpd] htpasswd in cgi (shell script)
Date Wed, 25 Jan 2006 14:35:03 GMT
At 11:11 AM 1/24/2006, Rodrigo Monteiro wrote:

>I'm using the httpd authentication (.htaccess and .htpasswd) for an
>cgi-bin/test dir. What I'm trying to do is another cgi (in shell
>script) that changes this file (cgi-bin/test/.htpasswd). I'm using the
>-m parameter in htpasswd to create the users.
># cat .htpasswd
>admin:$apr1$DXEZZ/..$EuDQbwbv3Wmf1QKe.leZd0
>#
>The user is admin and the password is admin.
>How can I encrypt the string "admin" to compare with the string in the
>.htpasswd?

Rodrigo I would approach this by using Perl's backtick operator to execute 
the htpasswd system command from within the program.

my $tmpPW = '/tmp/pswd';
my $res = `htpasswd -cb $tmpPW admin admin`;

if($res eq 'Adding password for user admin')
then
{
#  read $tmpPW and your .htpasswd file
#  compare and act accordingly
#  delete (Perl unlink function) $tmpPW
}
else { die "htpasswd command failed: $!\n" }

Just an overview of how I'd code it.

FWIW it looks to me like you're trying to write a password application 
using htaccess as your base. Personally I'd not got that way, ymmv.

Marty


Marty Landman, Face 2 Interface Inc. 845-679-9387
Webmaster's Bulletin Board: http://bbs.face2interface.com/
Web Installed Formmail: http://face2interface.com/formINSTal  


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message