5 filetest - Perl pragma to control the filetest permission operators
9 $can_perhaps_read = -r "file"; # use the mode bits
11 use filetest 'access'; # intuit harder
12 $can_really_read = -r "file";
14 $can_perhaps_read = -r "file"; # use the mode bits again
18 This pragma tells the compiler to change the behaviour of the filetest
19 permissions operators, the -r -w -x -R -W -X (see L<perlfunc>).
21 The default behaviour to use the mode bits as returned by the stat()
22 family of calls. This, however, may not be the right thing to do if
23 for example various ACL (access control lists) schemes are in use.
24 For such environments, C<use filetest> may help the permission
25 operators to return results more consistent with other tools.
27 Each "use filetest" or "no filetest" affects statements to the end of
30 There may be a slight performance decrease in the filetests
31 when C<use filetest> is in effect, because in some systems
32 the extended functionality needs to be emulated.
34 B<NOTE>: using the file tests is a lost case from the start: there is
35 a window open for race conditions (who is to say that the permissions
36 will not change between the test and the real operation?). Therefore
37 if you are serious about security, just try the real operation and
38 test for its success. Think atomicity.
40 =head2 subpragma access
42 Currently only one subpragma, C<access> is implemented. It enables
43 (or disables) the use of access() or similar system calls. This
44 extended filetest functionality is used only when the argument of the
45 operators is a filename, not when it is a filehandle.
50 if ( $_[1] eq 'access' ) {
53 die "filetest: the only implemented subpragma is 'access'.\n";
58 if ( $_[1] eq 'access' ) {
61 die "filetest: the only implemented subpragma is 'access'.\n";