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

can_write_dir.t and Packlist.t fail within AFS filesystem #39

Open
djzhh opened this issue Mar 14, 2024 · 0 comments
Open

can_write_dir.t and Packlist.t fail within AFS filesystem #39

djzhh opened this issue Mar 14, 2024 · 0 comments

Comments

@djzhh
Copy link

djzhh commented Mar 14, 2024

can_write_dir.t and Packlist.t fail when Perl is compiled within AFS filesystem (perl-5.38.2 and perl-5.36.3) but works fine within the local filesystem:

  1. can_write_dir.t:
cpan/ExtUtils-Install/t/can_write_dir ............................ 
#   Failed test at t/can_write_dir.t line 50.
#     Structures begin differing at:
#          $got->[0] = '1'
#     $expected->[0] = '0'
#   Failed test at t/can_write_dir.t line 51.
#     Structures begin differing at:
#          $got->[0] = '1'
#     $expected->[0] = '0'
# Looks like you failed 2 tests of 12.
FAILED at test 7

Test snippet:

     45     ok chmod 0555, $exists, 'make read only';
     46
     47     skip "Current user or OS cannot create directories that they cannot read", 6
     48           if -w $exists; # these tests require a directory we cant read
     49
     50     is_deeply [can_write_dir($exists)], [0, $exists];
     51     is_deeply [can_write_dir($subdir)], [0, $exists, $subdir];
  1. Packlist.t
cpan/ExtUtils-Install/t/Packlist ................................. 
#   Failed test 'write() should croak on open failure'
#   at t/Packlist.t line 92.
#                   ''
#     doesn't match '(?^:Can't open file)'
# Looks like you failed 1 test of 35.
FAILED at test 18

Test snippet:

     86         chmod 0444, 'eplist';
     87
     88         SKIP: {
     89             skip("cannot write readonly files", 1) if -w 'eplist';
     90
     91             eval { ExtUtils::Packlist::write({}, 'eplist') };
     92             like( $@, qr/Can't open file/, 'write() should croak on open failure' );
     93         }

The test must fail as there is no such thing as file-based ACLs in AFS; see https://docs.openafs.org/UserGuide/HDRWQ46.html
Instead ACLs are set on directories. As AFS is not that common, so below you'll find an example. Anyhow, ./Configure detects AFS and displays a notice "AFS may be running... I'll be extra cautious then..."

% systemctl status afs.mount
● afs.mount - /afs
     Loaded: loaded (/proc/self/mountinfo)
     Active: active (mounted) since Fri 2024-01-19 13:28:15 CET; 1 month 16 days ago
      Until: Fri 2024-01-19 13:28:15 CET; 1 month 16 days ago
      Where: /afs
       What: AFS

% mkdir demo
% cd demo

% fs listacl -path .
Access list for . is
Normal rights:
  username rlidwka
  system:administrators rlidwka
  system:anyuser l

% echo Hello World > a_file

% ls -ld a_file
-rw-r--r--. 1 username grp 12 Mar  6 02:34 a_file

% cat a_file
Hello World

% chmod 0000 a_file

% ls -ld a_file
----------. 1 username grp 12 Mar  6 02:34 a_file

% getfacl a_file
# file: a_file
# owner: username
# group: grp
user::---
group::---
other::---

% cat a_file
Hello World

% echo "Have a nice day" >> a_file

% cat a_file
Hello World
Have a nice day

I am not familiar with Perl tests, but anyhow propose these patches:

  1. can_write_dir
diff -p old/cpan/ExtUtils-Install/t/can_write_dir.t new/cpan/ExtUtils-Install/t/can_write_dir.t
*** old/cpan/ExtUtils-Install/t/can_write_dir.t	2023-11-28 12:57:27.000000000 +0100
--- new/cpan/ExtUtils-Install/t/can_write_dir.t	2024-03-12 23:27:30.000000000 +0100
***************
*** 5,10 ****
--- 5,11 ----
  use strict;
  use ExtUtils::Install;
  use File::Spec;
+ use Config;
  { package FS;  our @ISA = qw(File::Spec); }

  # Alias it for easier access
*************** is_deeply [can_write_dir($abs_dne)],
*** 35,43 ****
--- 36,47 ----
            ];

  SKIP: {
+     my $Curdir = File::Spec→curdir;
      my $exists = FS->catdir(qw(exists));
      my $subdir = FS->catdir(qw(exists subdir));

+     skip "AFS", 8
+ 	if $Config{afs} eq "true" && ($Curdir eq '.' || $Curdir =~ /^\Q$Config{afsroot}/);

      ok mkdir $exists;
      END { rmdir $exists }
*************** SKIP: {
  1. Packlist
diff -p cpan/ExtUtils-Install/t/Packlist.t new/cpan/ExtUtils-Install/t/Packlist.t
*** old/cpan/ExtUtils-Install/t/Packlist.t	2023-11-28 12:57:27.000000000 +0100
--- new/cpan/ExtUtils-Install/t/Packlist.t	2024-03-13 00:14:32.000000000 +0100
*************** ok( $file_is_ready, 'write() can write a
*** 80,93 ****
  local *IN;

  SKIP: {
  	skip('cannot write files, some tests difficult', 3) unless $file_is_ready;

  	# set this file to read-only
  	chmod 0444, 'eplist';

! 	SKIP: {
  	    skip("cannot write readonly files", 1) if -w 'eplist';
!
  	    eval { ExtUtils::Packlist::write({}, 'eplist') };
  	    like( $@, qr/Can't open file/, 'write() should croak on open failure' );
  	}
--- 80,94 ----
  local *IN;

  SKIP: {
+     require Config;
  	skip('cannot write files, some tests difficult', 3) unless $file_is_ready;

  	# set this file to read-only
  	chmod 0444, 'eplist';

!   SKIP: {
  	    skip("cannot write readonly files", 1) if -w 'eplist';
! 	    skip "AFS"		if $Config::Config{afs};
  	    eval { ExtUtils::Packlist::write({}, 'eplist') };
  	    like( $@, qr/Can't open file/, 'write() should croak on open failure' );
  	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant