Skip Menu |

This queue is for tickets about the File-HomeDir CPAN distribution.

Report information
The Basics
Id: 40338
Status: resolved
Priority: 0/
Queue: File-HomeDir

People
Owner: Nobody in particular
Requestors: wyant [...] cpan.org
Cc:
AdminCc:

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



Subject: Darwin plug-in can return wrong directory.
I believe I have found a couple cases where the Darwin plug-in for File::HomeDir returns the wrong directory. The first case is that users_home() appears to return the current directory if the user does not exist. The second case is that users_data() (and presumably the other users_* methods that go through _to_user()) appears to ignore the username and return the same directory as my_data (or, presumably, the corresponding my_* method). The first case seems to be because Darwin.pm's users_home() appears to assume that Cwd::abs_path returns undef if given undef as an argument; but my copy (version 3.2701) appears to return the current directory instead. The documentation on abs_path and friends says "if no argument is given they'll use the current working directory." Nothing is said about an undef, but that and '' (but _not_ '0') appear to be the same as passing no argument. The second case seems to be because the regular expression in _to_user() is missing a backslash before the Q. The attached universal difference file records my attempt to address the issues. In the second case, I have also inserted a return if the call to users_home() returned undef. The attached file also takes the liberty of changing the $VERSION, mostly to record that I in fact did something. I would have also provided a test file if I could figure out how to write one without knowing in advance what (if any) other users are available on the system.
Subject: Darwin.pat
Download Darwin.pat
application/octet-stream 780b

Message body not shown because it is not plain text.

Proposed test attached. I'll let this sit in the queue for a week or so, then have a crack at the SVN repository, unless I hear otherwise. Yes, I know that's what the docs say to do, but I like to at least give a heads-up before I mess in someone else's code.
use strict; use warnings; use Test::More; use File::HomeDir; $File::HomeDir::IMPLEMENTED_BY eq 'File::HomeDir::Darwin' or plan skip_all => "File::HomeDir::Darwin not used under $^O"; plan tests => 2; SKIP: { my $user; foreach (0 .. 9) { my $temp = sprintf 'fubar%04d', rand(10000); getpwnam $temp and next; $user = $temp; last; } $user or skip("Unable to find non-existent user", 1); $@ = undef; my $home = eval {File::HomeDir->users_home($user)}; $@ and skip("Unable to execute File::HomeDir->users_home('$user')"); ok (!defined $home, "Home of non-existent user should be undef"); } SKIP: { my $user; foreach my $uid (501 .. 540) { $uid == $< and next; $user = getpwuid $uid or next; last; } $user or skip("Unable to find another user", 1); my $me = getpwuid $<; defined (my $my_home = eval {File::HomeDir->my_home()}) or skip ("File::HomeDir->my_home() undefined", 1); defined (my $users_home = eval {File::HomeDir->users_home($user)}) or skip ("File::HomeDir->users_home('$user') undefined", 1); $my_home eq $users_home and skip ("Users '$me' and '$user' have same home", 1); defined (my $my_data = eval {File::HomeDir->my_data()}) or skip ("File::HomeDir->my_data() undefined", 1); defined (my $users_data = eval {File::HomeDir->users_data($user)}) or skip ("File::HomeDir->users_data('$user') undefined", 1); ok ($my_data ne $users_data, "Users '$me' and '$user' should have different data"); }
Subject: Re: [rt.cpan.org #40338] Darwin plug-in can return wrong directory.
Date: Wed, 29 Oct 2008 03:16:34 +1100
To: bug-File-HomeDir [...] rt.cpan.org
From: "Adam Kennedy" <adamkennedybackup [...] gmail.com>
Unfortunately, I still lack the ability to effectively apply patches (Win32, don't ask). I've added an account for you to my repository, you should have an email from the repository management software with your access details. Please apply the changes (including patch) to the repository, and we'll throw out a dev release. Adam K 2008/10/28 Tom Wyant via RT <bug-File-HomeDir@rt.cpan.org>: Show quoted text
> Queue: File-HomeDir > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=40338 > > > Proposed test attached. I'll let this sit in the queue for a week or so, > then have a crack at the SVN repository, unless I hear otherwise. Yes, I > know that's what the docs say to do, but I like to at least give a > heads-up before I mess in someone else's code. >
On Tue Oct 28 12:16:58 2008, adamkennedybackup@gmail.com wrote: Show quoted text
> Unfortunately, I still lack the ability to effectively apply patches > (Win32, don't ask). > > I've added an account for you to my repository, you should have an > email from the repository management software with your access > details. > > Please apply the changes (including patch) to the repository, and > we'll throw out a dev release.
Thanks. I have changed my password, added t/11_darwin.t as revision 4515, and patched lib/File/HomeDir/Darwin.pm as revision 4516. Darwin.pm is identical to the patch submitted earlier (including the development version number). 11_darwin.t is similar to the submitted test, but adds the shebang line and replaces 'use warnings' with the BEGIN block that appears in 01_compile.t and 02_main.t. I see that I forgot to make 11_darwin.t executable. Shall I do that also? Please let me know what else is needed, and thank you for trusting me to muck around in your code. Tom Wyant
File-HomeDir-0.83_01 passes under Mac OS 10.5.5 under Perls 5.8.8 and 5.10.0. I would submit tests, but it's at least partly my patch. Did you also get a Darwin patch from Darrin McBride? I'd hate to see him blamed if my code screws something up.
Subject: Re: [rt.cpan.org #40338] Darwin plug-in can return wrong directory.
Date: Mon, 3 Nov 2008 09:17:04 +1100
To: bug-File-HomeDir [...] rt.cpan.org
From: "Adam Kennedy" <adamkennedybackup [...] gmail.com>
I've been talking to Darrin, but his patch is a bit more comprehensive than just a bug fix, so we're going to go back and forth a bit and let the idea stew a bit. Your case is much more straight forward, so if it survives a week with no errors and a sufficient number of testers I'll move it to a prod release. And we'll do Darrin's for the next prod release after that. Adam K 2008/11/3 Tom Wyant via RT <bug-File-HomeDir@rt.cpan.org>: Show quoted text
> Queue: File-HomeDir > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=40338 > > > File-HomeDir-0.83_01 passes under Mac OS 10.5.5 under Perls 5.8.8 and > 5.10.0. I would submit tests, but it's at least partly my patch. > > Did you also get a Darwin patch from Darrin McBride? I'd hate to see him > blamed if my code screws something up. >
For what it's worth, I consider the original problem fixed as of 0.86. Maybe earlier. Usually I check when new releases come out, but this time I didn't. My apologies, and thanks for the fix. Tom Wyant
Original reporter confirms this is resolved.