Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 18066
Status: rejected
Worked: 5 min
Priority: 0/
Queue: Test-File

People
Owner: bdfoy [...] cpan.org
Requestors: adamk [...] cpan.org
Cc:
AdminCc:

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



Subject: Handle or document the weird root cases
When writing File::Flat I had some testing issues because sometimes the module would be tested as root, and sometimes not. When confirming that a chmod 0000 file is not readable by the current user, the normal user could correctly not read the file, and the root user still could, despite permissions. As a result, I ended up having to skip can_not_read_file type tests when running as root. You may want to consider either adjusting tests to handle this issue (by skipping the expected-false test that root will unexpectedly pass, or at the very minimum by documenting that the problem exists. Note, I haven't actually tested you have this problem for sure, but I thought I should at least bring it up.
From: brian.d.foy [...] gmail.com
On Wed Mar 08 21:31:16 2006, guest wrote: Show quoted text
> When writing File::Flat I had some testing issues because sometimes the > module would be tested as root, and sometimes not.
Show quoted text
> When confirming that a chmod 0000 file is not readable by the current > user, the normal user could correctly not read the file, and the root > user still could, despite permissions.
If the file is readable by the current user (even if that's root), file_readable_ok() should still return true, shouldn't it? I had the same problem in creating the tests for Test::File, but the function still works as advertised. Note that the second paragraph under DESCRIPTION explains this. Perhaps we need a file_readable_by_user( $file, $user ) function when you want to test it for a particular user.
Subject: Re: [rt.cpan.org #18066] Handle or document the weird root cases
Date: Thu, 09 Mar 2006 14:07:40 +1100
To: bug-Test-File [...] rt.cpan.org
From: Adam Kennedy <adam [...] phase-n.com>
Nope. When a file is set to u-r (as it is with 0000) it means that the user should not be able to read it. In fact, nobody should be able to read write or execute a 0000 file other than root. However, as the owner of the file, the owner can still change the permissions of the file to allow themselves the permission, and then do what they want. (which is something you need to also bear in mind when deleting the temporary test 0000 file). For a 0000 file... file_readable_ok($file); # Root OK, User Not OK file_not_readable($file); # Root Not OK, User OK Or rather, you probably want to skip a bunch of things when running as root. In fact, if you split it into file_readable_user_ok and etc_root, then you can cause each test called not in your current user mode (root/not-root) to skip. Adam K Guest via RT wrote: Show quoted text
> On Wed Mar 08 21:31:16 2006, guest wrote: >
>>When writing File::Flat I had some testing issues because sometimes the >>module would be tested as root, and sometimes not.
> >
>>When confirming that a chmod 0000 file is not readable by the current >>user, the normal user could correctly not read the file, and the root >>user still could, despite permissions.
> > > If the file is readable by the current user (even if that's root), > file_readable_ok() should still return true, shouldn't it? I had the > same problem in creating the tests for Test::File, but the function > still works as advertised. Note that the second paragraph under > DESCRIPTION explains this. > > Perhaps we need a file_readable_by_user( $file, $user ) function when > you want to test it for a particular user.
On Wed Mar 08 22:07:58 2006, adam@phase-n.com wrote: Show quoted text
> Nope.
I'm not sure what that applies to. You asked to handle or document the root cases. If you think the docs that are already there for that, tell me where it's still confusing. A patch would work :) Show quoted text
> For a 0000 file... > > file_readable_ok($file); # Root OK, User Not OK > file_not_readable($file); # Root Not OK, User OK
Did you not see this behavior? On my tests with Mac OS X.4, that is what happens. Or, are you saying that this is what you saw and you think that is wrong? Show quoted text
> Or rather, you probably want to skip a bunch of things when running as
root. I don't want to do that in the module because I don't want to guess or limit what the user is doing. If you're running as root and you can read the file as root, then the file is readable and the answer to "Can I read the file" is "yes".
Subject: Re: [rt.cpan.org #18066] Handle or document the weird root cases
Date: Fri, 10 Mar 2006 09:20:02 +1100
To: bug-Test-File [...] rt.cpan.org
From: Adam Kennedy <adam [...] phase-n.com>
brian_d_foy via RT wrote: Show quoted text
> On Wed Mar 08 22:07:58 2006, adam@phase-n.com wrote:
>> Nope.
> > I'm not sure what that applies to. You asked to handle or document the > root cases. If you think the docs that are already there for that, tell > me where it's still confusing. A patch would work :) >
>> For a 0000 file... >> >> file_readable_ok($file); # Root OK, User Not OK >> file_not_readable($file); # Root Not OK, User OK
> > Did you not see this behavior? On my tests with Mac OS X.4, that is what > happens. Or, are you saying that this is what you saw and you think that > is wrong?
Correct. Show quoted text
>> Or rather, you probably want to skip a bunch of things when running as
> root. > > I don't want to do that in the module because I don't want to guess or > limit what the user is doing. If you're running as root and you can read > the file as root, then the file is readable and the answer to "Can I > read the file" is "yes".
While this is true, the problem is that the results can be non-deterministic. There's one highly probably case here. If you put in a file_not_readable or type-test anywhere, that test will fail for root. So in File::Flat all I did was skip the negative tests as root. The remain potential false positive tests I didn't put any work into preventing them and was will to deal with any if bug reports got generated somewhere. But the test failure when testing for negative read/write/execute permissions is a biggie. Adam K
On Thu Mar 09 17:22:35 2006, adam@phase-n.com wrote: Show quoted text
> brian_d_foy via RT wrote:
> > On Wed Mar 08 22:07:58 2006, adam@phase-n.com wrote:
Show quoted text
> >> For a 0000 file... > >> > >> file_readable_ok($file); # Root OK, User Not OK > >> file_not_readable($file); # Root Not OK, User OK
> > > > Did you not see this behavior? On my tests with Mac OS X.4, that is what > > happens. Or, are you saying that this is what you saw and you think that > > is wrong?
> > Correct.
Which one of those does your reply apply to? I think I understand what you are saying. You don't want to know that root can read the file no matter what when you call file_not_readable(). I don't see a bug here though. You want something that excludes root, so I suggest you come up with a function that does what you want. I'd be happy to add it. However, file_not_readable does exactly what I want it to do and I'm not going to change it.
Subject: Re: [rt.cpan.org #18066] Handle or document the weird root cases
Date: Fri, 10 Mar 2006 09:34:33 +1100
To: bug-Test-File [...] rt.cpan.org
From: Adam Kennedy <adam [...] phase-n.com>
brian_d_foy via RT wrote: Show quoted text
> On Thu Mar 09 17:22:35 2006, adam@phase-n.com wrote: >
>> brian_d_foy via RT wrote:
>>> On Wed Mar 08 22:07:58 2006, adam@phase-n.com wrote:
>
>>>> For a 0000 file... >>>> >>>> file_readable_ok($file); # Root OK, User Not OK >>>> file_not_readable($file); # Root Not OK, User OK
>>> Did you not see this behavior? On my tests with Mac OS X.4, that is what >>> happens. Or, are you saying that this is what you saw and you think that >>> is wrong?
>> Correct.
> > Which one of those does your reply apply to?
Sorry, correct (this is what I saw, and it's a bug). Show quoted text
> I think I understand what you are saying. You don't want to know that > root can read the file no matter what when you call file_not_readable(). > > I don't see a bug here though. You want something that excludes root, so > I suggest you come up with a function that does what you want. I'd be > happy to add it. However, file_not_readable does exactly what I want it > to do and I'm not going to change it.
Well, the problem comes during installation. Some people build as a normal user, and only make install as root. Some people run "sudo cpan" and do the entire install as root. So if you have a negative test that uses -r then some of the time the module will install, and some of the time it won't. That's what my problem turned out to be. I kept getting cpan testers failure because of it, and reports from users. Adam K
On Thu Mar 09 17:37:07 2006, adam@phase-n.com wrote: Show quoted text
> So if you have a negative test that uses -r then some of the time the > module will install, and some of the time it won't. > > That's what my problem turned out to be. I kept getting cpan testers > failure because of it, and reports from users.
Are CPAN Testers reporting failures with your tests, or with mine? I haven't received any failures or complaints. You need to handle the special cases yourself. You can build a function on top of the stuff that I alreayd have, or use skip() like I do in my tests for the same situation. I think we're going around in circles though. If your tests are failing, you probably should test those situations that way. It's not the fault of Test::File, though.
Subject: Re: [rt.cpan.org #18066] Handle or document the weird root cases
Date: Fri, 10 Mar 2006 09:49:23 +1100
To: bug-Test-File [...] rt.cpan.org
From: Adam Kennedy <adam [...] phase-n.com>
No, I'm just saying that that's what happened with File::Flat. I personally didn't have any problems, it was completely fine for me. But over time, bad testing reports would keep coming in, all for that same problem. So I'm suggesting that since the root/not problem applies to every single time any user of File::Test does a negative test, you should build in support for it directly. As some form of skip perhaps. I personally don't have any problems, but every user you have will have that problem. Adam K brian_d_foy via RT wrote: Show quoted text
> On Thu Mar 09 17:37:07 2006, adam@phase-n.com wrote: >
>> So if you have a negative test that uses -r then some of the time the >> module will install, and some of the time it won't. >> >> That's what my problem turned out to be. I kept getting cpan testers >> failure because of it, and reports from users.
> > Are CPAN Testers reporting failures with your tests, or with mine? I > haven't received any failures or complaints. > > You need to handle the special cases yourself. You can build a function > on top of the stuff that I alreayd have, or use skip() like I do in my > tests for the same situation. > > I think we're going around in circles though. If your tests are failing, > you probably should test those situations that way. It's not the fault > of Test::File, though.
On Thu Mar 09 17:51:56 2006, adam@phase-n.com wrote: Show quoted text
> No, I'm just saying that that's what happened with File::Flat. > > I personally didn't have any problems, it was completely fine for me.
Show quoted text
> I personally don't have any problems, but every user you have will have > that problem.
Every user? You're the only one who's said anything about it, and you say you don't have the problem. :) Let's leave this closed.