X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/3cb6de8118f279c0dca172ac40ef21e89cf524b7..6d9c9890b6305b20fe39f3b418a5330f9fb32465:/lib/filetest.pm diff --git a/lib/filetest.pm b/lib/filetest.pm index d08f9b4..0c62741 100644 --- a/lib/filetest.pm +++ b/lib/filetest.pm @@ -1,5 +1,7 @@ package filetest; +our $VERSION = '1.01'; + =head1 NAME filetest - Perl pragma to control the filetest permission operators @@ -16,10 +18,10 @@ filetest - Perl pragma to control the filetest permission operators =head1 DESCRIPTION This pragma tells the compiler to change the behaviour of the filetest -permissions operators, the C<-r> C<-w> C<-x> C<-R> C<-W> C<-X> +permission operators, C<-r> C<-w> C<-x> C<-R> C<-W> C<-X> (see L). -The default behaviour to use the mode bits as returned by the stat() +The default behaviour is to use the mode bits as returned by the stat() family of calls. This, however, may not be the right thing to do if for example various ACL (access control lists) schemes are in use. For such environments, C may help the permission @@ -36,7 +38,8 @@ B: using the file tests for security purposes is a lost cause from the start: there is a window open for race conditions (who is to say that the permissions will not change between the test and the real operation?). Therefore if you are serious about security, just try -the real operation and test for its success. Think atomicity. +the real operation and test for its success - think in terms of atomic +operations. =head2 subpragma access @@ -47,9 +50,11 @@ operators is a filename, not when it is a filehandle. =cut +$filetest::hint_bits = 0x00400000; # HINT_FILETEST_ACCESS + sub import { if ( $_[1] eq 'access' ) { - $^H |= 0x00400000; + $^H |= $filetest::hint_bits; } else { die "filetest: the only implemented subpragma is 'access'.\n"; } @@ -57,7 +62,7 @@ sub import { sub unimport { if ( $_[1] eq 'access' ) { - $^H &= ~0x00400000; + $^H &= ~$filetest::hint_bits; } else { die "filetest: the only implemented subpragma is 'access'.\n"; }