Navigation Menu

Skip to content
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

Closed
p5pRT opened this issue Aug 3, 2015 · 18 comments
Closed

[PATCH] t/op/stat.t: skipping -r test is unneeded #14836

p5pRT opened this issue Aug 3, 2015 · 18 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 3, 2015

Migrated from rt.perl.org#125740 (status was 'open')

Searchable as RT125740$

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2015

From vano@mail.mipt.ru

Created by vano@mail.mipt.ru

Subj. The -r test works just fine in Cygwin 2.1.0.

I couldn't find a note in Cygwin git repo on
whether this had been changed as some point
and don't have an ancient Cygwin version to test
this directly.

Perl Info

Flags:
    category=core
    severity=low
    Type=Patch
    PatchStatus=HasPatch

Site configuration information for perl 5.23.2:

Configured by User at Sat Aug  1 13:47:55 AST 2015.

Summary of my perl5 (revision 5 version 23 subversion 2) configuration:
  Local Commit: a90ad6d3cfecd7f26e2a8932159963ea31307bca
  Ancestor: 85d323d4d59cc15f5c76bca4c1df90317f88d0e8
  Platform:
    osname=cygwin, osvers=2.1.0(0.28753), archname=cygwin-thread-multi-64int
    uname='cygwin_nt-5.1 iru-notebook 2.1.0(0.28753) 2015-07-14 21:26 i686 cygwin '
    config_args='-Dprefix=/opt/perl5 -Dusedevel -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2',
    optimize='-O3',
    cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion='', gccversion='4.9.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12, longdblkind=3
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lpthread -ldl -lcrypt
    perllibs=-lpthread -ldl -lcrypt
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=cygperl5_23_2.dll
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' --shared  -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -L/usr/local/lib -fstack-protector-strong'

Locally applied patches:
    a90ad6d3cfecd7f26e2a8932159963ea31307bca


@INC for perl 5.23.2:
    lib
    /opt/perl5/lib/site_perl/5.23.2/cygwin-thread-multi-64int
    /opt/perl5/lib/site_perl/5.23.2
    /opt/perl5/lib/5.23.2/cygwin-thread-multi-64int
    /opt/perl5/lib/5.23.2
    .


Environment for perl 5.23.2:
    CYGWIN=nodosfilewarning
    HOME=/home/User
    LANG=ru_RU.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/c/bin/rk:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/system32/WBEM:/usr/local/bin:/usr/bin:/:/c/bin:/c/Program Files/Java/jdk1.7.0_12/bin:/c/Program Files/QT Lite/QTSystem:/c/Program Files/TortoiseHg:/c/ant/bin:/c/apache-maven-3.0.4/bin:/c/Program Files/TortoiseSVN/bin:/c/Py/Scripts:/c/Py:/c/Program Files/TortoiseGit/bin:/c/Program Files/Git/cmd:/c/program files/Java/jdk1.6.0_22/bin:/c/program files/vim/vim71:/c/py:/c/Py/Scripts:/c/Program Files/PuTTY:/c/Program Files/Nmap
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2015

From vano@mail.mipt.ru

0001-cygwin-2.1.0-can-test-r-just-fine-incl.-under-admin.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2015

From @tonycoz

On Mon Aug 03 02​:26​:59 2015, vano@​mail.mipt.ru wrote​:

Subj. The -r test works just fine in Cygwin 2.1.0.

I couldn't find a note in Cygwin git repo on
whether this had been changed as some point
and don't have an ancient Cygwin version to test
this directly.

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

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2015

From vano@mail.mipt.ru

Tuesday, August 4, 2015, 3​:52​:06 Tony​:

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 former. I dunno why the latter slipped through - must be an
oversight.

--
Regards,
Ivan Pozdeev

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2015

From vano@mail.mipt.ru

Regarding the ticket's matter​:
I found it.

Cygwin commit https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=2c1ffdbf5e6f2767ab63e67834530539d36c6c0b
from 16 Oct 2006, winsup/cygwin/security.cc,
actually _enabled_ security override.

In actuality, they report read access regardless of ACL
if the user has SeBackupPrivilege enabled.

It is disabled by default, even for admins.
(The secpol.msc "Back up files and directories" setting
only allows a program to enable it on request.)

BUT​: Cygwin processes always enable this privilege
(thus, so does Perl built for Cygwin).

Despite this, Perl still reports -r correctly, even with this privilege set.
Shall I investigate the reason further ot this is proof enough?

--
Best regards,
Ivan mailto​:vano@​mail.mipt.ru

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

From @tonycoz

On Mon Aug 03 23​:53​:48 2015, vano@​mail.mipt.ru wrote​:

Regarding the ticket's matter​:
I found it.

Cygwin commit https://cygwin.com/git/gitweb.cgi?p=newlib-
cygwin.git;a=commit;h=2c1ffdbf5e6f2767ab63e67834530539d36c6c0b
from 16 Oct 2006, winsup/cygwin/security.cc,
actually _enabled_ security override.

In actuality, they report read access regardless of ACL
if the user has SeBackupPrivilege enabled.

It is disabled by default, even for admins.
(The secpol.msc "Back up files and directories" setting
only allows a program to enable it on request.)

BUT​: Cygwin processes always enable this privilege
(thus, so does Perl built for Cygwin).

Despite this, Perl still reports -r correctly, even with this
privilege set.
Shall I investigate the reason further ot this is proof enough?

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

@p5pRT p5pRT closed this as completed Aug 11, 2015
@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

From Stromeko@nexgo.de

Tony Cook via RT writes​:

BUT​: Cygwin processes always enable this privilege
(thus, so does Perl built for Cygwin).

You can drop privileges as well as membership in the Administrator group
with cygdrop. Specifically, if you want to do both​:

cygdrop -lm <command>

Despite this, Perl still reports -r correctly, even with this
privilege set.
Shall I investigate the reason further ot this is proof enough?

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.

You can't have UID zero on Windows and there is no root user either.
You can fake that in Cygwin via /etc/passwd if you really want to, but
it's not making the tests for "root" work correctly anyway. If you need
to test for something that's approximating root, then you need to check
for group 544. It's still not the same thing as being root, mind you.
There's even a library that fakes the euid to zero for programs from
UNIX. I haven't applied it to Cygwin Perl since I don't think that Perl
should lie about the uig/gid, though.

Thanks, applied as 9728ed0 with the adjusted author as discussed previously.

The tests that fail if you are admin are mainly the -w tests, IIRC.
Last but not least, the results very much depend on whather the file
system you run the tests on uses ACL and how they are set. Cygwin has
recently learned to deal with Windows ACL much more thoroughly, however
some setings just can't map to POSIX and the resulting mode bits can be
quite confusing.

In particular, if your access is granted only via inherited ACL (which
is common on network shares), the file ownership is recorded with your
UID and you are not allowed to change the ACL, then Cygwin has no way of
setting the POSIX mode bits correctly. In those cases the user bits are
all cleared and the group bits reflect the access via ACL, which in
POSIX means the user has explicitly been shut out from accessing the
file (the group bits and the ACL will never be checked), while Windows
processes the ACL in a slightly different way and allows the access.

So, as said before​: Since some of the tests require certain privileges
to be present, other tests require the same privileges to be absent and
checking for the user being "root" is at best an incomplete proxy for
the status of those privileges (even on UN*X if you have SELinux or some
other MAC extension enabled), the correct way of dealing with those
tests would be to drop privileges when they are not needed and skip
tests when you have insufficient privileges. That, however requires a
bit of infrastructure that isn't there yet.

Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2​:
http​://Synth.Stromeko.net/Downloads.html#WaldorfSDada

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

From vano@mail.mipt.ru

Thanks, applied as 9728ed0 with
the adjusted author as discussed previously.

Aaahhh... don't be so rash!

In the meantime, I finished the investigation.

And it showed​: Perl _is_ designed to always report access
for admin in Cygwin, but it doesn't check the group membership
correctly.

So, this test succeeds when it shouldn't!

I thought to devise a patch to add a specific test case for admins
(that would fail) before reporting all this to as not to come
with just complaints and no solution (which would only get me
jettisoned from the community since it's the most despicable thing to
do ever).

Apparently, my decision was misguided!

Anyway, there's no need to revert the commit, just don't lock the
ticket until the real solution is applied.

--
Regards,
Ivan Pozdeev

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

@tonycoz - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

From vano@mail.mipt.ru

Anyway, there's no need to revert the commit, just don't lock the
ticket until the real solution is applied.

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
thus allowing Cygwin to use the new-style security mappings
(https://www.cygwin.com/ml/cygwin/2014-02/msg00306.html).
Due to this, the severity of the failure has dropped abruptly.
Thus I'm not going to investigate this further, I'll just create
another issue with my findings on the matter since there _does_
appear to be a flaw in Perl's logic according to them.

For now, it's enough that this problem is visible in test results now.

@p5pRT
Copy link
Author

p5pRT commented Aug 11, 2015

From vano@mail.mipt.ru

0001-Added-r-w-tests-for-admin.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Aug 12, 2015

From vano@mail.mipt.ru

A followup to the last patch - devised a way to fix the FIXME in it.

Guess this wraps up this issue.

@p5pRT
Copy link
Author

p5pRT commented Aug 12, 2015

From vano@mail.mipt.ru

0002-Fix-permission-override-check-in-Cygwin.patch
From 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

@p5pRT
Copy link
Author

p5pRT commented Feb 26, 2017

From @jkeenan

On Wed, 12 Aug 2015 10​:54​:09 GMT, vano@​mail.mipt.ru wrote​:

A followup to the last patch - devised a way to fix the FIXME in it.

Guess this wraps up this issue.

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.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Mar 3, 2017

From vano@mail.mipt.ru

What I apparently suggested here, without realizing it at first, is a
separate -r/-w test for superuser.
Even without `use filetest 'access';', -r/-w override stat bits for
superuser (doio.c​:Perl_cando), and the suggested test checks that override.

The other ticket I referenced in
https://rt.perl.org/Public/Bug/Display.html?id=125740#txn-1360344 is
https://rt.perl.org/Public/Bug/Display.html?id=125788 , and the problem
there is that Perl doesn't always determine the "superuser" status
correctly in Cygwin. The suggested test was supposed to fail in those
cases to show that.

So, the patch is still needed if checking the override is needed.

@p5pRT
Copy link
Author

p5pRT commented Mar 3, 2017

From @jkeenan

On Fri, 03 Mar 2017 10​:36​:10 GMT, vano@​mail.mipt.ru wrote​:

What I apparently suggested here, without realizing it at first, is a
separate -r/-w test for superuser.
Even without `use filetest 'access';', -r/-w override stat bits for
superuser (doio.c​:Perl_cando), and the suggested test checks that override.

The other ticket I referenced in
https://rt.perl.org/Public/Bug/Display.html?id=125740#txn-1360344 is
https://rt.perl.org/Public/Bug/Display.html?id=125788 , and the problem
there is that Perl doesn't always determine the "superuser" status
correctly in Cygwin. The suggested test was supposed to fail in those
cases to show that.

So, the patch is still needed if checking the override is needed.

Please prepare a new patch drawn against Perl 5 blead. This will enable us to evaluate it better.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant