diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-09-25 07:13:13 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-09-25 07:13:13 +0000 |
commit | 5ff3f7a4e03a6b103d9e628865398e498e9a7968 (patch) | |
tree | 5884f57bd4a3baf1ad76e8ab3f81f12aa71a31da /lib/filetest.pm | |
parent | 46124e9ee58ad41479e5b089638f6c263bbddcb7 (diff) | |
download | perl-5ff3f7a4e03a6b103d9e628865398e498e9a7968.tar.gz |
big Configure update from Jarkko: sync metaconfig units; d_statblks fix
for Linux; hpux CMA-threads hints; ELF support for FreeBSD; beginnings
of full-fledged 64-bit support (including support for: fseeko/ftello,
Quad_t aka long long, hpux and irix 64-bits hints, new 64-bit constants
in Fcntl)
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Fri, 11 Sep 1998 23:56:11 +0300 (EET DST)
Message-Id: <199809112056.XAA04720@alpha.hut.fi>
Subject: [PATCH] 5.005_51: Configure "Massive Attack"
--
From: Jarkko Hietaniemi <jhi@cc.hut.fi>
Date: 12 Sep 1998 09:44:25 +0300
Message-ID: <oeeaf45bzjq.fsf@alpha.hut.fi>
Subject: Re: [PATCH] 5.005_51: Configure "Massive Attack"
p4raw-id: //depot/perl@1889
Diffstat (limited to 'lib/filetest.pm')
-rw-r--r-- | lib/filetest.pm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/filetest.pm b/lib/filetest.pm new file mode 100644 index 0000000000..cc14e82817 --- /dev/null +++ b/lib/filetest.pm @@ -0,0 +1,65 @@ +package filetest; + +=head1 NAME + +filetest - Perl pragma to control the filetest permission operators + +=head1 SYNOPSIS + + $can_perhaps_read = -r "file"; # use the mode bits + { + use filetest 'access'; # intuit harder + $can_really_read = -r "file"; + } + $can_perhaps_read = -r "file"; # use the mode bits again + +=head1 DESCRIPTION + +This pragma tells the compiler to change the behaviour of the filetest +permissions operators, the -r -w -x -R -W -X (see L<perlfunc>). + +The default behaviour 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<use filetest> may help the permission +operators to return results more consistent with other tools. + +Each "use filetest" or "no filetest" affects statements to the end of +the enclosing block. + +There may be a slight performance decrease in the filetests +when C<use filetest> is in effect, because in some systems +the extended functionality needs to be emulated. + +B<NOTE>: using the file tests is a lost case 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. + +=head2 subpragma access + +Currently only one subpragma, C<access> is implemented. It enables +(or disables) the use of access() or similar system calls. This +extended filetest functionality is used only when the argument of the +operators is a filename, not when it is a filehandle. + +=cut + +sub import { + if ( $_[1] eq 'access' ) { + $^H |= 0x00400000; + } else { + die "filetest: the only implemented subpragma is 'access'.\n"; + } +} + +sub unimport { + if ( $_[1] eq 'access' ) { + $^H &= ~0x00400000; + } else { + die "filetest: the only implemented subpragma is 'access'.\n"; + } +} + +1; |