--- helpers/basic_auth/DB/squid_db_auth.in 2010-03-29 12:02:56.000000000 +0200 +++ helpers/basic_auth/DB/squid_db_auth.in.dlucio 2010-04-25 09:57:42.000000000 +0200 @@ -1,8 +1,9 @@ #!@PERL@ -use strict; +#use strict; use DBI; use Getopt::Long; use Pod::Usage; +use Digest::MD5 qw(md5 md5_hex md5_base64); $|=1; =pod @@ -22,6 +23,8 @@ my $db_cond = "enabled = 1"; my $plaintext = 0; my $persist = 0; +my $isjoomla = 0; +my $debug = 0; =pod @@ -62,6 +65,7 @@ =item B<--cond> Condition, defaults to enabled=1. Specify 1 or "" for no condition +If you use --joomla flag, this condition will be changed to block=0 =item B<--plaintext> @@ -71,6 +75,10 @@ Keep a persistent database connection open between queries. +=item B<--joomla> + +Tell helper that user database is joomla db. So salt hasing is understood. + =back =cut @@ -85,13 +93,17 @@ 'cond=s' => \$db_cond, 'plaintext' => \$plaintext, 'persist' => \$persist, + 'joomla' => \$isjoomla, + 'debug' => \$debug, ); -my ($_dbh, $_sth); +$db_cond = "block = 0" if $isjoomla; + sub close_db() { return if !defined($_dbh); + $_sth->finish(); $_dbh->disconnect(); undef $_dbh; undef $_sth; @@ -113,10 +125,17 @@ { my ($password, $key) = @_; - return 1 if crypt($password, $key) eq $key; + if ($isjoomla){ + my $salt; + my $key2; + ($key2,$salt) = split (/:/, $key); + return 1 if md5_hex($password.$salt).':'.$salt eq $key; + } + else{ + return 1 if crypt($password, $key) eq $key; - return 1 if $plaintext && $password eq $key; - + return 1 if $plaintext && $password eq $key; + } return 0; } @@ -155,8 +174,9 @@ =head1 COPYRIGHT Copyright (C) 2007 Henrik Nordstrom +Copyright (C) 2010 Luis Daniel Lucio Quiroz (Joomla support) + This program is free software. You may redistribute copies of it under the terms of the GNU General Public License version 2, or (at youropinion) any later version. - =cut