You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Rodrigo Monteiro <mr...@gmail.com> on 2006/01/24 17:11:11 UTC
[users@httpd] htpasswd in cgi (shell script)
Hello everyone.
I've looked for this question but can't find it in the mailing list
archive. So, if there is an answer in a old thread, point to me...
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?
regards,
--
Rodrigo Monteiro
"Free as in Freedom, not free as in free beer"
Linux User # 403730
JID: mrodrigom@jabber.org
mrodrigox@gmail.com
---------------------------------------------------------------------
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
Re: [users@httpd] htpasswd in cgi (shell script)
Posted by Marty Landman <ml...@face2interface.com>.
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