Skip Menu |

This queue is for tickets about the Apache-Htpasswd CPAN distribution.

Report information
The Basics
Id: 15535
Status: open
Priority: 0/
Queue: Apache-Htpasswd

People
Owner: Nobody in particular
Requestors: nothingmuch [...] woobling.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Apache::Htpasswd does while(<FH>) without localizing $_
Hi ho... I just got this error: Modification of a read-only value attempted at /Library/Perl/5.8.6/Apache/Htpasswd.pm line 226. because I used Apache::Htpasswd (indirectly) inside a loop like: for (qw/some list of constant values/) { ... } The fix would be to add local $_; just before while(<FH>). Thanks!
Hello there, If you give me a full example, I'll see if I should make the fix. Cheers, Kevin [NUFFIN - Fri Nov 4 16:46:37 2005]: Show quoted text
> Hi ho... > > I just got this error: > > Modification of a read-only value attempted at > /Library/Perl/5.8.6/Apache/Htpasswd.pm line 226. > > because I used Apache::Htpasswd (indirectly) inside a loop like: > > for (qw/some list of constant values/) { > ... > } > > The fix would be to add > > local $_; > > just before while(<FH>). > > Thanks!
From: nothingmuch [...] woobling.org
[KMELTZ - Fri Nov 4 16:58:07 2005]: Show quoted text
> If you give me a full example, I'll see if I should make the fix.
Hmm, i thought the report was detailed enough. What's not obvious?
use strict; use warnings; use Test::More tests => 1; use Test::Exception; use Apache::Htpasswd; use File::Temp qw/tempfile/; my ( undef, $tmp ) = tempfile; my $p = Apache::Htpasswd->new( $tmp ); $p->htpasswd( user => 's3cr3t' ); lives_ok { for (qw/foo/) { # $_ is currently aliased to the read only value 'foo' $p->htCheckPassword( user => 's3cr3t' ); } } '$_ does not get overwritten by while(<FH>)';
From: nothingmuch [...] woobling.org
[NUFFIN - Sat Nov 5 06:45:33 2005]: Show quoted text
> Hmm, i thought the report was detailed enough. What's not obvious?
In retrospect this may have sounded rude =( I attached a test to that message, but the email notification system didn't list attachments.
From: nothingmuch [...] woobling.org
[KMELTZ - Fri Nov 4 16:58:07 2005]: Show quoted text
> Hello there, > > If you give me a full example, I'll see if I should make the fix.
Is there anything more that you need to get around to this? It's been 4 and a half days since I've posted a test.
[guest - Wed Nov 9 06:42:40 2005]: Show quoted text
> [KMELTZ - Fri Nov 4 16:58:07 2005]: >
> > Hello there, > > > > If you give me a full example, I'll see if I should make the fix.
> > Is there anything more that you need to get around to this? It's been > 4 and a half days since I've > posted a test.
Yes, you need patience. Between my job, and just having gotten back from travelling.. this isn't my top priority.
From: nothingmuch [...] woobling.org
To all other observers of this bug - I can only reccomend you use Authen::Htpasswd instead of this module.
From: Darren Kulp (kulp...thekulp [...] [...] [...] com)
[NUFFIN - Fri Nov 25 21:04:46 2005]: Show quoted text
> To all other observers of this bug - I can only reccomend you use > Authen::Htpasswd instead of > this module.
Unfortunately, Authen::Htpasswd does not appear to return a list of users, which I need. Here's where I got my problem: my %users = map { $_ => $h->fetchPass($_) } $h->fetchUsers; Indeed, adding "local $_;" (on line 248 for this particular method) resolved my problem (which was that my hash keys were full .htaccess lines). Attached is a patch against 1.7 that I think should eliminate these problems. Thanks.
--- /home/xxxxx/perl/share/perl/5.8/Apache/Htpasswd.pm 2005-11-21 15:15:13.000000000 -0800 +++ Htpasswd.pm 2006-01-08 13:25:00.000000000 -0800 @@ -198,6 +198,7 @@ $self->_open(); seek( FH, 0, SEEK_SET ); + local $_; while (<FH>) { if (/^$Id\:/) { @@ -245,6 +246,7 @@ $self->_open(); + local $_; while (<FH>) { chop; my @tmp = split ( /:/, $_, 3 ); @@ -273,6 +275,7 @@ $self->_open(); seek( FH, 0, SEEK_SET ); + local $_; while (<FH>) { my @tmp = split ( /:/, $_, 3 ); @@ -325,6 +328,7 @@ $self->_open(); + local $_; while (<FH>) { chop; my @tmp = split ( /:/, $_, 3 ); @@ -349,6 +353,7 @@ $self->_open(); + local $_; while (<FH>) { chop; my @tmp = split ( /:/, $_, 3 ); @@ -375,6 +380,7 @@ $self->_open(); seek( FH, 0, SEEK_SET ); + local $_; while (<FH>) { my @tmp = split ( /:/, $_, 3 );
I'd love to look at the diff, but RT is just giving me back crap when I try to download it. Feel free to email it to me. Cheers, Kevin Show quoted text
> > Unfortunately, Authen::Htpasswd does not appear to return a list of > users, which I need. > Here's where I got my problem: > > my %users = map { $_ => $h->fetchPass($_) } $h->fetchUsers; > > Indeed, adding "local $_;" (on line 248 for this particular method) > resolved my problem > (which was that my hash keys were full .htaccess lines). > > Attached is a patch against 1.7 that I think should eliminate these > problems. Thanks.
On Sun Jan 08 16:31:55 2006, guest wrote: Show quoted text
> Unfortunately, Authen::Htpasswd does not appear to return a list of > users, which I need.
This is supported in 0.14, just pushed to CPAN. my $pwfile = Authen::Htpasswd->new('pass.txt'); my @users = $pwfile->all_users;