Skip Menu |

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

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

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

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



Subject: do not search "root" homedir on Cygwin
On Cygwin there is generally no "root" user, just like on Windows.
Subject: perl-File-HomeDir.src.patch
--- origsrc/File-HomeDir-1.00/t/02_main.t 2012-10-19 23:35:24.000000000 +0200 +++ src/File-HomeDir-1.00/t/02_main.t 2015-05-23 22:00:32.272973000 +0200 @@ -272,6 +272,6 @@ SKIP: { # On platforms other than windows, find root's homedir SKIP: { - if ( $^O eq 'MSWin32' or $^O eq 'darwin') { + if ( $^O eq 'MSWin32' or $^O eq 'cygwin' or $^O eq 'darwin') { skip("Skipping root test on $^O", 1 ); }
On 2015-05-24 04:07:04, https://me.yahoo.com/howdidwegetherereally#f714d wrote: Show quoted text
> On Cygwin there is generally no "root" user, just like on Windows.
Why not simply check first if there is a userid named 'root', and if not, skip the test? These platforms *may* have a root user, but may not. If it exists, the tests are fine.
On Sun May 24 15:20:16 2015, ETHER wrote: Show quoted text
> Why not simply check first if there is a userid named 'root', and if > not, skip the test?
For Windows and by extension Cygwin at least, being "root" is tied to the membership in certain groups and/or the existence of certain security tokens in the SID. Show quoted text
> These platforms *may* have a root user, but may not. If it exists, the > tests are fine.
Yes, many Cygwin systems have root user configured (it's only recently been changed to not be generated by default). However, it almost never had an actual homedir associated with it, so that test would often fail anyway.
Immediately below that skip there is a skip if there is no getpwuid(0). Does that not cover the cygwin case? I don't have my cygwin box to test at the moment.
On Fri Aug 07 12:57:01 2015, PLICEASE wrote: Show quoted text
> Immediately below that skip there is a skip if there is no > getpwuid(0). Does that not cover the cygwin case? I don't have my > cygwin box to test at the moment.
This covers the case of a recent Cygwin installation that doesn't have a root user configured in /etc/passwd or a system that has no /etc/passwd at all (in that you don't get a result from getpwuid in this case). For an older installation, that entry would typically exist after installation and the home directory in the entry would often not exist unless the user also configured certain services (cygserver for instance) which would make use of the same location and create it if necessary. As I read it, the test tries to get the home directory of some user other than the one runnning the test and in the absence of anything better it uses UID=0. That can generally only be expected to work on UN*X systems.
On Wed Aug 12 15:47:09 2015, https://me.yahoo.com/howdidwegetherereally#f714d wrote: Show quoted text
> /etc/passwd at all (in that you don't get a result from getpwuid in > this case). For an older installation, that entry would typically
My question, perhaps poorly worded, was: if you do not get a result from getpwuid(0), wouldn't $root be undef, and wouldn't this unless skip the test? unless ( $root ) { skip("Skipping, can't determine root", 1 ); }
On Wed Aug 12 17:12:47 2015, PLICEASE wrote: Show quoted text
> On Wed Aug 12 15:47:09 2015, > https://me.yahoo.com/howdidwegetherereally#f714d wrote:
> > /etc/passwd at all (in that you don't get a result from getpwuid in > > this case). For an older installation, that entry would typically
> > My question, perhaps poorly worded, was: if you do not get a result > from getpwuid(0), wouldn't $root be undef, and wouldn't this unless > skip the test? > > unless ( $root ) { > skip("Skipping, can't determine root", 1 ); > }
Yes, it would skip the test. But there might be an entry for "root" that doesn't have a valid home directory and then you get a test error based on a wrong assumption made about "root" and its UID.
Summary: There might be a weird root user without a valid directory. This hypothetical situation is valid for every (but not all) unix-like operating system. Since modern desktop oriented unix'sh operating systems might (valid or not) restrict root in weird ways (I've seen the skip for Darwin, even if all Mac OS X machines I've seen have a root home). The test shall prove whether home directories of other users can be determined. With above bad facts in mind, how about a loop over pwent and skip for every user where !pw_dir or !-d pw_dir?
On Thu Aug 13 02:17:11 2015, REHSACK wrote: Show quoted text
> The test shall prove whether home directories of other users can be > determined. With above bad facts in mind, how about a loop over pwent > and skip for every user where !pw_dir or !-d pw_dir?
This would enumerate the AD or NIS if the machine is a domain member. I'm not sure this is something desirable. Using the "root" user was meant to provide a username that exists and has a home directory. That assumption turns out to be wrong and I can't think of any other user name that could be guaranteed to meet these two conditions. I can always provide another username than the one that runs the test that is good for the tests, but it would typically be specific to the system I'm testing on. How about making this configurable and providing some sane defaults based on the system type?
On Wed Aug 19 15:38:18 2015, https://me.yahoo.com/howdidwegetherereally#f714d wrote: Show quoted text
> On Thu Aug 13 02:17:11 2015, REHSACK wrote:
> > The test shall prove whether home directories of other users can be > > determined. With above bad facts in mind, how about a loop over pwent > > and skip for every user where !pw_dir or !-d pw_dir?
> > This would enumerate the AD or NIS if the machine is a domain member. > I'm not sure this is something desirable.
Unlikely ;) Show quoted text
> Using the "root" user was > meant to provide a username that exists and has a home directory. > That assumption turns out to be wrong and I can't think of any other > user name that could be guaranteed to meet these two conditions.
Scanning some /etc/passwd's I agree - beside root I don't see much valueable widely which would be available ... Show quoted text
> I can always provide another username than the one that runs the test > that is good for the tests, but it would typically be specific to the > system I'm testing on. How about making this configurable and > providing some sane defaults based on the system type?
I think this is a sane approach, and to disable that for someone's weird cygwin/darwin, set the username knob to an empty value or so.
I digged a bit throug the code: I would expect, on Cygwin, the $IMPLEMENTATION_BY defaults to File::HomeDir::FreeDesktop or File::HomeDir::Unix. For the resolve of my_home, in both conditions, the first check goes whether $ENV{HOME} or $ENV{LOGDIR} is reasonable. Set one of the environment variables to a sane value should you get out of trouble.
Now it's out in 1.003_001