Open djzhh opened 6 months ago
Interesting. This test has existed for a very very very long time so I'm surprised nobody has tripped over this issue before.
I need to add a preliminary test that checks that chmod
actually works. If it doesn't these tests get skipped.
Be aware that when using chmod
the output of ls
changes:
% 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
@djzhh Just looking at how I have the failing tests structure, I already do tests that check that the files I'm going to use are not-writable and not-readable respectively.
For example, for the non-writable use case I do this
chmod 0444, $name
or skip "Cannot create non-writable file", 3 ;
skip "Cannot create non-writable file", 3
if -w $name ;
ok ! -w $name, " input file not writable";
Once the code above runs successfully Perl thinks that the file $name
is not writable, but the subsequent code that will write to the file does not fail for the AFS use case. That means that the -w
operator isn't telling the truth.
Think my best option is to try to write data to the non-writable file and read data from the non-readable file.
Below is a proposed change for the two failing tests. If you have the time, could you give them a go with your AFS setup please?
{
title 'read/write a non-readable/writable file';
SKIP:
{
skip "Cannot create non-writable file", 3
if $^O eq 'cygwin';
my $lex = LexFile->new( my $name );
writeFile($name, "abc");
chmod 0444, $name
or skip "Cannot create non-writable file", 3 ;
skip "Cannot create non-writable file", 3
if -w $name ;
# double check non-writable for AFS
my $written = do {
no warnings;
my $fh;
open $fh, '>', $name &&
print $fh "hello world"
};
skip "Cannot create non-writable file", 3
if $written ;
ok ! -w $name, " input file not writable";
my $fil = gzopen($name, "wb") ;
ok !$fil, " gzopen returns undef" ;
ok $gzerrno, " gzerrno ok" or
diag " gzerrno $gzerrno\n";
chmod 0777, $name ;
}
SKIP:
{
my $lex = LexFile->new( my $name );
skip "Cannot create non-readable file", 3
if $^O eq 'cygwin';
writeFile($name, "abc");
chmod 0222, $name ;
skip "Cannot create non-readable file", 3
if -r $name ;
# double check non-readable for AFS
my $readable = do {
no warnings;
my $fh;
open $fh, '<', $name &&
read $fh, my $data, 1
};
skip "Cannot create non-writable file", 3
if $readable ;
ok ! -r $name, " input file not readable";
$gzerrno = 0;
my $fil = gzopen($name, "rb") ;
ok !$fil, " gzopen returns undef" ;
ok $gzerrno, " gzerrno ok";
chmod 0777, $name ;
}
}
The test does not complain any longer. Thanks a lot, esp. as compiling in AFS is not so common.
The test does not complain any longer.
Good job!
Thanks a lot, esp. as compiling in AFS is not so common.
I know of AFS, but I've never used it.
Test fails for perl-5.36.3 and perl-5.38.2 (no other versions tested) when compiling in an AFS-part of the filesystem. Compiling in e.g.
/var/tmp
works fine, though../Configure
detects that the sources reside in AFS:AFS may be running... I'll be extra cautious then...
The errors detected are:
They correspond directly to tests using
chmod
(line numbers at the beginning):The tests must fail as there is no such thing as file-based ACLs in AFS; see https://docs.openafs.org/UserGuide/HDRWQ46.html
I assume that these tests should be
skip
ped when compiled in an AFS-directory as a workaround.Just for completeness: