/usr/share/perl5/File/Slurp/WithinPolicy.pm is in libfile-policy-perl 1.005-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | ###############################################################################
# Purpose : Hide site-dependent FS policies beneath a well-known interface
# Author : John Alden
# Created : March 2005
# CVS : $Id: WithinPolicy.pm,v 1.4 2005/06/15 10:40:21 simonf Exp $
###############################################################################
package File::Slurp::WithinPolicy;
use strict;
use Carp;
use Exporter;
use Fcntl ':flock';
use File::Slurp();
use File::Policy;
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS @ISA);
@ISA = qw(Exporter);
@EXPORT_OK = qw(read_file write_file append_file overwrite_file read_dir);
%EXPORT_TAGS = ('all' => \@EXPORT_OK);
$VERSION = sprintf"%d.%03d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/;
sub read_file {
File::Policy::check_safe( $_[0], 'r' );
goto &File::Slurp::read_file;
}
sub write_file {
File::Policy::check_safe( $_[0], 'w' );
goto &File::Slurp::write_file;
}
sub append_file {
File::Policy::check_safe( $_[0], 'w' );
goto &File::Slurp::append_file;
}
sub overwrite_file {
File::Policy::check_safe( $_[0], 'w' );
goto &File::Slurp::overwrite_file;
}
sub read_dir {
File::Policy::check_safe( $_[0], 'r' );
goto &File::Slurp::read_dir;
}
1;
=head1 NAME
File::Slurp::WithinPolicy - Applies filesystem policies to File::Slurp
=head1 SYNOPSIS
use File::Slurp::WithinPolicy qw(:all);
my $text = read_file( 'filename' );
my @lines = read_file( 'filename' );
write_file( 'filename', $text );
append_file( 'filename', $more_text );
overwrite_file( 'filename', $text );
my @files = read_dir( '/path/to/dir' );
=head1 DESCRIPTION
This provides the File::Slurp interface within a policy defined by File::Policy.
By default, File::Policy is a no-op and this behaves identically to File::Slurp.
System administrators may want to override the default File::Policy implementation to enforce a local filesystem policy
(see L<File::Policy>).
=head1 FUNCTIONS
=head2 read_dir
See L<File::Slurp/read_dir>
=head2 read_file
See L<File::Slurp/read_file>
=head2 write_file
See L<File::Slurp/write_file>
=head2 append_file
See L<File::Slurp/append_file>
=head2 overwrite_file
See L<File::Slurp/overwrite_file>
=head1 EXPORTS
By default, nothing is exported.
The C<:all> tag can be used to export everything.
Individual methods can also be exported.
=head1 SEE ALSO
L<File::Slurp>, L<File::Policy>
=head1 VERSION
$Revision: 1.4 $ on $Date: 2005/06/15 10:40:21 $ by $Author: simonf $
=head1 AUTHOR
John Alden <cpan _at_ bbc _dot_ co _dot_ uk>
=head1 COPYRIGHT
(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
=cut
|