1filetest(3pm) Perl Programmers Reference Guide filetest(3pm)
2
3
4
6 filetest - Perl pragma to control the filetest permission operators
7
9 $can_perhaps_read = -r "file"; # use the mode bits
10 {
11 use filetest 'access'; # intuit harder
12 $can_really_read = -r "file";
13 }
14 $can_perhaps_read = -r "file"; # use the mode bits again
15
17 This pragma tells the compiler to change the behaviour of the filetest
18 permission operators, "-r" "-w" "-x" "-R" "-W" "-X" (see perlfunc).
19
20 The default behaviour is to use the mode bits as returned by the stat()
21 family of calls. This, however, may not be the right thing to do if
22 for example various ACL (access control lists) schemes are in use. For
23 such environments, "use filetest" may help the permission operators to
24 return results more consistent with other tools.
25
26 Each "use filetest" or "no filetest" affects statements to the end of
27 the enclosing block.
28
29 There may be a slight performance decrease in the filetests when "use
30 filetest" is in effect, because in some systems the extended functionâ
31 ality needs to be emulated.
32
33 NOTE: using the file tests for security purposes is a lost cause from
34 the start: there is a window open for race conditions (who is to say
35 that the permissions will not change between the test and the real
36 operation?). Therefore if you are serious about security, just try the
37 real operation and test for its success - think in terms of atomic
38 operations.
39
40 subpragma access
41
42 Currently only one subpragma, "access" is implemented. It enables (or
43 disables) the use of access() or similar system calls. This extended
44 filetest functionality is used only when the argument of the operators
45 is a filename, not when it is a filehandle.
46
47
48
49perl v5.8.8 2001-09-21 filetest(3pm)