Re: [users@httpd] htpasswd in cgi (shell script)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux