I have been having trouble connecting to my user database, according to the logs, 
there was never any password returned.

After browsing through the code, I found the following:
---start code---
undef $passwd if 0 == $sth->rows; # so we can distinguish later on between no password 
and empty password
---start code---

According to the DBI documentation here:
http://search.cpan.org/author/TIMB/DBI-1.30/DBI.pm#rows
---start quote---
So use of the rows method or $DBI::rows with SELECT statements is not recommended.
---end quote---

It seems my particular driver (PgPP) is returning a 0 to $sth->rows, which undefs 
$passwd, even if there was a password returned.

So I cooked up a patch to fix it.  (Attached)

It simply increments a counter while looping through the recordsets and checks that 
counter instead $sth->rows.

My Configuration:
Apache 1.3.26
Apache::AuthDBI 0.88
PostgreSQL 7.2.1
Perl 5.6.1
DBD::PgPP 0.04



--- AuthDBI.pm  Wed Nov 20 06:04:19 2002
+++ old/AuthDBI.pm      Wed Nov 20 05:30:25 2002
@@ -273,10 +273,9 @@
             $dbh->disconnect;
             return SERVER_ERROR;
         }
-       my $password_count = 0;
+
         # fetch result
         while ($_ = $sth->fetchrow_array) {
-           $password_count++;
             # strip trailing blanks for fixed-length data-type
             $_ =~ s/ +$// if $_;
             # consider the case with many users sharing the same userid
@@ -284,7 +283,7 @@
         }
 
         chop  $passwd if $passwd;
-        undef $passwd if 0 == $password_count; # so we can distinguish later on 
between no password and empty password
+        undef $passwd if 0 == $sth->rows; # so we can distinguish later on between no 
+password and empty password
 
         if ($sth->err) {
             $dbh->disconnect;



Reply via email to