Perl-Toolchain-Gang / ExtUtils-MakeMaker

Perl module to make Makefiles and build modules (what backs Makefile.PL)
https://metacpan.org/release/ExtUtils-MakeMaker
65 stars 77 forks source link

Mkbootstrap.t fails within AFS filesystem #451

Open djzhh opened 8 months ago

djzhh commented 8 months ago

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

cpan/ExtUtils-MakeMaker/t/Mkbootstrap ............................ 
#   Failed test 'should die given bad filename'
#   at t/Mkbootstrap.t line 84.
#                   ''
#     doesn't match '(?^:Unable to open dasboot\.bs)'
# Looks like you failed 1 test of 18.
FAILED at test 8

Snippet of test:

     78         chmod 0444, 'dasboot.bs';
     79
     80         SKIP: {
     81             skip("cannot write readonly files", 1) if -w 'dasboot.bs' || $^O eq 'cygwin';
     82
     83             eval{ Mkbootstrap('dasboot', 1) };
     84             like( $@, qr/Unable to open dasboot\.bs/, 'should die given bad filename' );
     85         }

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 this patch:

require Config;
     78         chmod 0444, 'dasboot.bs';
     79
     80         SKIP: {
     81             skip("cannot write readonly files", 1) if -w 'dasboot.bs' || $^O eq 'cygwin';
skip "AFS" if $Config::Config{afs} eq "true";
     82
     83             eval{ Mkbootstrap('dasboot', 1) };
     84             like( $@, qr/Unable to open dasboot\.bs/, 'should die given bad filename' );
     85         }
Leont commented 8 months ago

This should only be skipped if the current directory is under /afs, right? Something along the lines of

skip "Can't write readonly files" if $Config{afs} eq "true" and Cwd::getcwd =~ /^\Q$Config{afsroot}\E/;
djzhh commented 8 months ago

All AFS cells I know of are starting with /afs, so this looks an appropriate condition to me.