New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] t/op/stat.t: skipping -r test is unneeded #14836
Comments
From vano@mail.mipt.ruCreated by vano@mail.mipt.ruSubj. The -r test works just fine in Cygwin 2.1.0. I couldn't find a note in Cygwin git repo on Perl Info
|
From vano@mail.mipt.ru0001-cygwin-2.1.0-can-test-r-just-fine-incl.-under-admin.patchFrom 2245a2697d9662043aa9aa1fdfc9002e9438a089 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <ivan_pozdeev@mail.ru>
Date: Mon, 3 Aug 2015 12:01:13 +0300
Subject: [PATCH] cygwin 2.1.0 can test -r just fine, incl. under admin
---
t/op/stat.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/op/stat.t b/t/op/stat.t
index ad94b3f..a807b90 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -194,7 +194,7 @@ SKIP: {
skip "Can't test if an admin user in miniperl", 2,
if $Is_Cygwin && is_miniperl();
skip "Can't test -r or -w meaningfully if you're superuser", 2
- if ($Is_Cygwin ? Win32::IsAdminUser : $> == 0);
+ if ($> == 0);
SKIP: {
skip "Can't test -r meaningfully?", 1 if $Is_Dos;
--
1.9.5.msysgit.1
|
From @tonycozOn Mon Aug 03 02:26:59 2015, vano@mail.mipt.ru wrote:
When Merijn added you to AUTHORS he added you with email address <vano@mail.mipt.ru> which is the email address used in your "[PATCH] configure: -error when default output is not a.aot - errors when build path has spaces" email. This new patch uses <ivan_pozdeev@mail.ru>. Do you have a preference? Tony |
The RT System itself - Status changed from 'new' to 'open' |
From vano@mail.mipt.ruTuesday, August 4, 2015, 3:52:06 Tony:
The former. I dunno why the latter slipped through - must be an -- |
From vano@mail.mipt.ruRegarding the ticket's matter: Cygwin commit https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=2c1ffdbf5e6f2767ab63e67834530539d36c6c0b In actuality, they report read access regardless of ACL It is disabled by default, even for admins. BUT: Cygwin processes always enable this privilege Despite this, Perl still reports -r correctly, even with this privilege set. -- |
From @tonycozOn Mon Aug 03 23:53:48 2015, vano@mail.mipt.ru wrote:
I wasn't able to get cygwin to set $> to 0 (which would skip the test anyway) and the test passes when not skipped, so it's all good. Thanks, applied as 9728ed0 with the adjusted author as discussed previously. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
From Stromeko@nexgo.deTony Cook via RT writes:
You can drop privileges as well as membership in the Administrator group cygdrop -lm <command>
You can't have UID zero on Windows and there is no root user either.
The tests that fail if you are admin are mainly the -w tests, IIRC. In particular, if your access is granted only via inherited ACL (which So, as said before: Since some of the tests require certain privileges Regards, SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2: |
From vano@mail.mipt.ru
Aaahhh... don't be so rash! In the meantime, I finished the investigation. And it showed: Perl _is_ designed to always report access So, this test succeeds when it shouldn't! I thought to devise a patch to add a specific test case for admins Apparently, my decision was misguided! Anyway, there's no need to revert the commit, just don't lock the -- |
@tonycoz - Status changed from 'resolved' to 'open' |
From vano@mail.mipt.ru
Here it is. It fails on one of my machines and succeeds on another. The failure is fixed when I remove /etc/passwd & /etc/group For now, it's enough that this problem is visible in test results now. |
From vano@mail.mipt.ru0001-Added-r-w-tests-for-admin.patchFrom 12346e4ff702e4d3dd04841fa1bc365cdd41477f Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Tue, 11 Aug 2015 16:01:57 +0300
Subject: [PATCH] Added -r/-w tests for admin
---
t/op/stat.t | 131 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 73 insertions(+), 58 deletions(-)
diff --git a/t/op/stat.t b/t/op/stat.t
index a807b90..36830d7 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -3,7 +3,7 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
- require './test.pl'; # for which_perl() etc
+ require './test.pl'; # for which_perl() etc
}
use Config;
@@ -25,12 +25,12 @@ if ($^O eq 'MSWin32') {
${^WIN32_SLOPPY_STAT} = 0;
}
-plan tests => 115;
+plan tests => 117;
my $Perl = which_perl();
-$ENV{LC_ALL} = 'C'; # Forge English error messages.
-$ENV{LANGUAGE} = 'C'; # Ditto in GNU.
+$ENV{LC_ALL} = 'C'; # Forge English error messages.
+$ENV{LANGUAGE} = 'C'; # Ditto in GNU.
$Is_Amiga = $^O eq 'amigaos';
$Is_Cygwin = $^O eq 'cygwin';
@@ -75,7 +75,7 @@ my $Filesystem_Time_Offset = abs($mtime - time);
#nlink should if link support configured in Perl.
SKIP: {
skip "No link count - Hard link support not built in.", 1
- unless $Config{d_link};
+ unless $Config{d_link};
is($nlink, 1, 'nlink on regular file');
}
@@ -103,7 +103,7 @@ my $inaccurate_atime = 0;
if (defined &Win32::IsWinNT && Win32::IsWinNT()) {
if (Win32::FsType() ne 'NTFS') {
$has_link = 0;
- $inaccurate_atime = 1;
+ $inaccurate_atime = 1;
}
}
@@ -128,7 +128,7 @@ SKIP: {
}
SKIP: {
- skip_if_miniperl("File::Spec not built for minitest", 2);
+ skip_if_miniperl("File::Spec not built for minitest", 2);
my $cwd = File::Spec->rel2abs($Curdir);
skip "Solaris tmpfs has different mtime/ctime link semantics", 2
if $Is_Solaris and $cwd =~ m#^/tmp# and
@@ -185,26 +185,41 @@ ok(-s $tmpfile, ' and -s');
ok( chmod(0000, $tmpfile), 'chmod 0000' );
SKIP: {
- skip "-r, -w and -x have different meanings on VMS", 3 if $Is_VMS;
+ skip "-r, -w and -x have different meanings on VMS", 5 if $Is_VMS;
SKIP: {
- # Going to try to switch away from root. Might not work.
- my $olduid = $>;
- eval { $> = 1; };
- skip "Can't test if an admin user in miniperl", 2,
- if $Is_Cygwin && is_miniperl();
- skip "Can't test -r or -w meaningfully if you're superuser", 2
- if ($> == 0);
+ skip "Can't check whether an admin user in miniperl", 4,
+ if $Is_Cygwin && is_miniperl();
+
+ #FIXME:in Cygwin, check for BackupPrivilege instead
+ my $is_admin=(($Is_Cygwin && Win32::IsAdminUser()) || $> == 0);
SKIP: {
- skip "Can't test -r meaningfully?", 1 if $Is_Dos;
- ok(!-r $tmpfile, " -r");
+ skip "Not a superuser", 2
+ if (!$is_admin);
+ ok(-r $tmpfile, " -r");
+ ok(-w $tmpfile, " -w");
}
- ok(!-w $tmpfile, " -w");
-
- # switch uid back (may not be implemented)
- eval { $> = $olduid; };
+ SKIP: {
+ # Going to try to switch away from root. Might not work.
+ if ($is_admin) {
+ my $olduid = $>;
+ eval { $> = 1; };
+ skip "Can't switch away from superuser", 2
+ if ($> == $olduid);
+ }
+
+ SKIP: {
+ skip "Can't test -r meaningfully?", 1 if $Is_Dos;
+ ok(!-r $tmpfile, " -r");
+ }
+
+ ok(!-w $tmpfile, " -w");
+
+ # switch uid back (may not be implemented)
+ if ($is_admin) { eval { $> = $olduid; }; }
+ }
}
ok(! -x $tmpfile, ' -x');
@@ -303,11 +318,11 @@ SKIP: {
}
my $try = sub {
- my @c1 = eval qq[\$DEV =~ /^$_[0].*/mg];
- my @c2 = eval qq[grep { $_[1] "/dev/\$_" } \@DEV];
- my $c1 = scalar @c1;
- my $c2 = scalar @c2;
- is($c1, $c2, "ls and $_[1] agreeing on /dev ($c1 $c2)");
+ my @c1 = eval qq[\$DEV =~ /^$_[0].*/mg];
+ my @c2 = eval qq[grep { $_[1] "/dev/\$_" } \@DEV];
+ my $c1 = scalar @c1;
+ my $c2 = scalar @c2;
+ is($c1, $c2, "ls and $_[1] agreeing on /dev ($c1 $c2)");
};
{
@@ -499,16 +514,16 @@ SKIP: {
-T _;
eval { lstat _ };
like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
- 'lstat croaks after -T _' );
+ 'lstat croaks after -T _' );
eval { -l _ };
like( $@, qr/^The stat preceding -l _ wasn't an lstat/,
- '-l _ croaks after -T _' );
+ '-l _ croaks after -T _' );
unlink $linkname or print "# unlink $linkname failed: $!\n";
}
SKIP: {
skip "Too much clock skew between system and filesystem", 5
- if ($Filesystem_Time_Offset > 5);
+ if ($Filesystem_Time_Offset > 5);
print "# Zzz...\n";
sleep($Filesystem_Time_Offset+1);
my $f = 'tstamp.tmp';
@@ -540,17 +555,17 @@ SKIP: {
my $s2 = -s _;
is($s1, $s2, q(-T _ doesn't break the statbuffer));
SKIP: {
- my $root_uid = $Is_Cygwin ? 18 : 0;
- skip "No lstat", 1 unless $Config{d_lstat};
- skip "uid=0", 1 if $< == $root_uid or $> == $root_uid;
- skip "Can't check if admin user in miniperl", 1
- if $^O =~ /^(cygwin|MSWin32|msys)$/ && is_miniperl();
- skip "Readable by group/other means readable by me on $^O", 1 if $^O eq 'VMS'
+ my $root_uid = $Is_Cygwin ? 18 : 0;
+ skip "No lstat", 1 unless $Config{d_lstat};
+ skip "uid=0", 1 if $< == $root_uid or $> == $root_uid;
+ skip "Can't check if admin user in miniperl", 1
+ if $^O =~ /^(cygwin|MSWin32|msys)$/ && is_miniperl();
+ skip "Readable by group/other means readable by me on $^O", 1 if $^O eq 'VMS'
or ($^O =~ /^(cygwin|MSWin32|msys)$/ and Win32::IsAdminUser());
- lstat($tmpfile);
- -T _;
- ok(eval { lstat _ },
- q(-T _ doesn't break lstat for unreadable file));
+ lstat($tmpfile);
+ -T _;
+ ok(eval { lstat _ },
+ q(-T _ doesn't break lstat for unreadable file));
}
unlink $tmpfile;
}
@@ -564,9 +579,9 @@ SKIP: {
# And now for the ambiguous bareword case
{
- no warnings 'deprecated';
- ok(open(DIR, "TEST"), 'Can open "TEST" dir')
- || diag "Can't open 'TEST': $!";
+ no warnings 'deprecated';
+ ok(open(DIR, "TEST"), 'Can open "TEST" dir')
+ || diag "Can't open 'TEST': $!";
}
my $size = (stat(DIR))[7];
ok(defined $size, "stat() on bareword works");
@@ -592,23 +607,23 @@ SKIP: {
skip "No dirfd()", 9 unless $Config{d_dirfd} || $Config{d_dir_dd_fd};
ok(opendir(DIR, "."), 'Can open "." dir') || diag "Can't open '.': $!";
ok(stat(*DIR{IO}), "stat() on *DIR{IO} works");
- ok(-d _ , "The special file handle _ is set correctly");
+ ok(-d _ , "The special file handle _ is set correctly");
ok(-d -r *DIR{IO} , "chained -x's on *DIR{IO}");
- # And now for the ambiguous bareword case
- {
- no warnings 'deprecated';
- ok(open(DIR, "TEST"), 'Can open "TEST" dir')
- || diag "Can't open 'TEST': $!";
- }
- my $size = (stat(*DIR{IO}))[7];
- ok(defined $size, "stat() on *THINGY{IO} works");
- is($size, -s "TEST",
- "size returned by stat of *THINGY{IO} is for the file");
- ok(-f _, "ambiguous *THINGY{IO} uses file handle, not dir handle");
- ok(-f *DIR{IO});
- closedir DIR or die $!;
- close DIR or die $!;
+ # And now for the ambiguous bareword case
+ {
+ no warnings 'deprecated';
+ ok(open(DIR, "TEST"), 'Can open "TEST" dir')
+ || diag "Can't open 'TEST': $!";
+ }
+ my $size = (stat(*DIR{IO}))[7];
+ ok(defined $size, "stat() on *THINGY{IO} works");
+ is($size, -s "TEST",
+ "size returned by stat of *THINGY{IO} is for the file");
+ ok(-f _, "ambiguous *THINGY{IO} uses file handle, not dir handle");
+ ok(-f *DIR{IO});
+ closedir DIR or die $!;
+ close DIR or die $!;
}
}
@@ -628,7 +643,7 @@ SKIP: {
# give a syntax error, they shouldn't crash.
eval { stat -t };
ok(1, 'can "stat -t" without crashing');
- eval { lstat -t };
+ eval { lstat -t };
ok(1, 'can "lstat -t" without crashing');
}
--
1.9.5.msysgit.1
|
From vano@mail.mipt.ruA followup to the last patch - devised a way to fix the FIXME in it. Guess this wraps up this issue. |
From vano@mail.mipt.ru0002-Fix-permission-override-check-in-Cygwin.patchFrom 6fc2240e623bd7357f4b806a5ff7fe12960784d4 Mon Sep 17 00:00:00 2001
From: Ivan Pozdeev <vano@mail.mipt.ru>
Date: Wed, 12 Aug 2015 13:46:10 +0300
Subject: [PATCH 2/2] Fix permission override check in Cygwin
---
t/op/stat.t | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/t/op/stat.t b/t/op/stat.t
index 36830d7..3c2a9c3 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -103,7 +103,7 @@ my $inaccurate_atime = 0;
if (defined &Win32::IsWinNT && Win32::IsWinNT()) {
if (Win32::FsType() ne 'NTFS') {
$has_link = 0;
- $inaccurate_atime = 1;
+ $inaccurate_atime = 1;
}
}
@@ -191,8 +191,11 @@ SKIP: {
skip "Can't check whether an admin user in miniperl", 4,
if $Is_Cygwin && is_miniperl();
- #FIXME:in Cygwin, check for BackupPrivilege instead
- my $is_admin=(($Is_Cygwin && Win32::IsAdminUser()) || $> == 0);
+ #Cygwin overrides permissions if SeBackupPrivilege/
+ # SeRestorePrivilege is held. We don't check for both
+ # as holding only one is a remote possibility
+ my $is_admin=(($Is_Cygwin && !system(qq{test -r "$tmpfile"}))
+ || $> == 0);
SKIP: {
skip "Not a superuser", 2
--
1.9.5.msysgit.1
|
From @jkeenanOn Wed, 12 Aug 2015 10:54:09 GMT, vano@mail.mipt.ru wrote:
Discussion in this RT petered out a year-and-a-half ago. To move the discussion forwarded, I created a branch in my local repository in which I tried to apply the patches. However, the first of the two patches does not apply cleanly. Hence, I'm not pushing a branch to origin. Can we get an update as to whether a patch is still needed? Thank you very much. -- |
From vano@mail.mipt.ruWhat I apparently suggested here, without realizing it at first, is a The other ticket I referenced in So, the patch is still needed if checking the override is needed. |
From @jkeenanOn Fri, 03 Mar 2017 10:36:10 GMT, vano@mail.mipt.ru wrote:
Please prepare a new patch drawn against Perl 5 blead. This will enable us to evaluate it better. Thank you very much. -- |
Migrated from rt.perl.org#125740 (status was 'open')
Searchable as RT125740$
The text was updated successfully, but these errors were encountered: