ok( !-d 'TEST' );
ok( -r 'TEST' );
-# make sure TEST is r-x
-eval { chmod 0555, 'TEST' or die "chmod 0555, 'TEST' failed: $!" };
-chomp ($bad_chmod = $@);
+# Make a read only file
+my $ro_file = tempfile();
+
+{
+ open my $fh, '>', $ro_file or die "open $fh: $!";
+ close $fh or die "close $fh: $!";
+}
+
+chmod 0555, $ro_file or die "chmod 0555, '$ro_file' failed: $!";
$oldeuid = $>; # root can read and write anything
eval '$> = 1'; # so switch uid (may not be implemented)
if (!$Config{d_seteuid}) {
skip('no seteuid');
}
- elsif ($Config{config_args} =~/Dmksymlinks/) {
- skip('we cannot chmod symlinks');
- }
- elsif ($bad_chmod) {
- skip( $bad_chmod );
- }
else {
- ok( !-w 'TEST' );
+ ok( !-w $ro_file );
}
}
package OverFtest;
use overload
+ fallback => 1,
-X => sub {
- $over = [overload::StrVal($_[0]), $_[1]];
+ $over = [qq($_[0]), $_[1]];
"-$_[1]";
};
}
}
my $ft = bless [], "OverFtest";
-my $ftstr = overload::StrVal($ft);
+my $ftstr = qq($ft);
my $str = bless [], "OverString";
my $both = bless [], "OverBoth";
my $neither = bless [], "OverNeither";
-my $nstr = overload::StrVal($neither);
+my $nstr = qq($neither);
open my $gv, "<", "TEST";
bless $gv, "OverString";
$io = *{$io}{IO};
bless $io, "OverString";
+my $fcntl_not_available;
+eval { require Fcntl } or $fcntl_not_available = 1;
+
for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") {
$over = [];
ok( my $rv = eval "-$op \$ft", "overloaded -$op succeeds" )
is( $over->[1], $op, "correct op for overloaded -$op" );
is( $rv, "-$op", "correct return value for overloaded -$op");
+ my ($exp, $is) = (1, "is");
+ if (
+ !$fcntl_not_available and (
+ $op eq "u" and not eval { Fcntl::S_ISUID() } or
+ $op eq "g" and not eval { Fcntl::S_ISGID() } or
+ $op eq "k" and not eval { Fcntl::S_ISVTX() }
+ )
+ ) {
+ ($exp, $is) = (0, "not");
+ }
+
$over = 0;
$rv = eval "-$op \$str";
ok( !$@, "-$op succeeds with string overloading" )
or diag( $@ );
is( $rv, eval "-$op 'TEST'", "correct -$op on string overload" );
- is( $over, 1, "string overload called for -$op" );
+ is( $over, $exp, "string overload $is called for -$op" );
- my ($exp, $is) = $op eq "l" ? (1, "is") : (0, "not");
+ ($exp, $is) = $op eq "l" ? (1, "is") : (0, "not");
$over = 0;
eval "-$op \$gv";