Skip Menu |

This queue is for tickets about the AppConfig CPAN distribution.

Report information
The Basics
Id: 67161
Status: open
Priority: 0/
Queue: AppConfig

People
Owner: Nobody in particular
Requestors: perlxmlcompile [...] defiant.mesastate.edu
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.66
Fixed in: (no value)



Subject: EXPAND_UID problem?
The AppConfig module has been a really nice package to use, and I've been using it for a while now. Recently, I tried to use a new (to me) feature: EXPAND_UID for parsing AppConfig configuration files. However, this feature doesn't seem to work correctly. I've attached a sample script that I think demonstrates this problem. I've tried this with AppConfig versions 1.56, 1.63, and 1.66, and all exhibit the same behavior. When I trace the code to the line in POSIX.pm that errors out, it's complaining because two arguments are being passed to getpwnam(): the first is an object ($self), and the second is the username to expand. $ ./expanduid.pl Passed the first one OK () Usage: POSIX::getpwnam(name) at /usr/share/perl5/AppConfig/File.pm line 397 I've reproduced this problem with perl 5.8.8, 5.8.9, and 5.10.1 (Solaris, Mac OS X, and Linux respectively). Thanks. - Daniel
Subject: a.config
Download a.config
application/octet-stream 43b

Message body not shown because it is not plain text.

Subject: expanduid.pl
#!/usr/bin/perl use AppConfig; my $config = AppConfig->new( 'poll_file|f=s', { EXPAND => AppConfig::EXPAND_UID } ); # Some parameters on the command-line may be needed to bootstrap the process $config->getopt(); printf "Passed the first one OK (%s)\n", $config->get('poll_file'); $config->file('a.config'); # This call fails printf "Passed the second one OK (%s)\n", $config->get('poll_file'); exit 0;
From: perlxmlcompile [...] defiant.mesastate.edu
Figured out the problem (it's in AppConfig::Sys): The POSIX getpw* modules were being loaded into the AppConfig::Sys namespace, and that was the source of the problem. By doing this, the AUTOLOAD in AppConfig::Sys was never being invoked -- the call was being passed directly to the POSIX subroutines, but they were being treated directly as object methods (which adds the $self parameter to the front of the subroutine invocation). The fix is to not import any of the POSIX modules into the namespace, and always explicitly reference them as POSIX::getpw* Three lines need to be changed to resolve this bug. A diff file is attached to resolve this bug. This is for AppConfig version 1.65. Thanks. - Daniel
Subject: diff-AppConfig::SYS.pm
--- /Library/Perl/5.10.0/AppConfig/Sys.pm 2007-05-30 05:24:26.000000000 -0600 +++ /opt/local/lib/perl5/vendor_perl/5.8.9/AppConfig/Sys.pm 2011-04-19 10:45:33.000000000 -0600 @@ -17,7 +17,7 @@ package AppConfig::Sys; use strict; use warnings; -use POSIX qw( getpwnam getpwuid ); +use POSIX; our $VERSION = '1.65'; our ($AUTOLOAD, $OS, %CAN, %METHOD); @@ -38,10 +38,10 @@ else { $METHOD{ getpwuid } = sub { - getpwuid( defined $_[0] ? shift : $< ); + POSIX::getpwuid( defined $_[0] ? shift : $< ); }; $METHOD{ getpwnam } = sub { - getpwnam( defined $_[0] ? shift : '' ); + POSIX::getpwnam( defined $_[0] ? shift : '' ); }; }
On Tue Apr 19 13:00:42 2011, daniel314 wrote: Show quoted text
> Figured out the problem (it's in AppConfig::Sys): > > The POSIX getpw* modules were being loaded into the AppConfig::Sys > namespace, and that was the source of the problem. By doing this, the > AUTOLOAD in AppConfig::Sys was never being invoked -- the call was being > passed directly to the POSIX subroutines, but they were being treated > directly as object methods (which adds the $self parameter to the front > of the subroutine invocation). > > The fix is to not import any of the POSIX modules into the namespace, > and always explicitly reference them as POSIX::getpw* > > Three lines need to be changed to resolve this bug. A diff file is > attached to resolve this bug. This is for AppConfig version 1.65. > > Thanks. > > - Daniel
I could not reproduce this using version 1.70. It also looks like, upon inspection, that the following `use` line should import the required POSIX:: methods as expected. use POSIX qw( getpwnam getpwuid );