.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "File::Policy 3pm" .TH File::Policy 3pm "2016-11-25" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" File::Policy \- Site policy for file I/O functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use File::Policy; \& use File::Policy qw/check_safe/; # to import a specific subroutine \& use File::Policy qw/:all/; # to import all subroutines \& \& #Checking I/O policy \& check_safe($filename, \*(Aqr\*(Aq); \& check_safe($filename, \*(Aqw\*(Aq); \& \& #Preferred directory locations \& $logdir = get_log_dir(); \& $tmpdir = get_temp_dir(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This defines the policy for file I/O with modules such as File::Slurp::WithinPolicy. The purpose is to allow systems administrators to define locations and restrictions for applications' file I/O and give app developers a policy to follow. Note that the module doesn't \s-1ENFORCE\s0 the policy \- application developers can choose to ignore it (and systems administrators can choose not to install their applications if they do!). .PP You may control which policy gets applied by creating a File::Policy::Config module with an \s-1IMPLEMENTATION\s0 constant. You may write your own policy as a module within the File::Policy:: namespace. .PP By default (if no File::Policy::Config is present), the File::Policy::Default policy gets applied which doesn't impose any restrictions and provides reasonable default locations for temporary and log files. .PP The motivation behind this module was a standard, flexible approach to allow a site wide file policy to be defined. This will be most useful in large environments where a few sysadmins are responsible for code written by many other people. Simply ensuring that submitted code calls \fIcheck_safe()\fR ensures file access is sane, reducing the amount of effort required to do a security audit. .PP If your code is not security audit'd, or you are the only developer at your site, this might be overkill. However you may consider it good practise regardless and protection against paths in your code getting corrupted accidentally or maliciously in the future. .PP There are two major benefits of using this module. One, sites that do implement a policy can more easily integrate your code in a standard way. If you have a file policy at your site, you can apply different policies (via File::Policy::Config) in different environments (production, integration test, development) and the appropriate policy is automatically applied without having to change your code or configs. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .IP "check_safe" 4 .IX Item "check_safe" .Vb 1 \& check_safe( FILENAME , MODE ); .Ve .Sp Checks \s-1FILENAME\s0 is safe \- dies if not. \s-1MODE\s0 is r (read) or w (write). .IP "get_temp_dir" 4 .IX Item "get_temp_dir" .Vb 1 \& $temporary_directory = get_temp_dir(); .Ve .Sp Returns the path to temporary directory. Note that any return value will have been cleared of a trailing slash. .IP "get_log_dir" 4 .IX Item "get_log_dir" .Vb 1 \& $log_directory = get_log_dir(); .Ve .Sp Returns the path to log directory. Note that any return value will have been cleared of a trailing slash. .SH "DEFINING YOUR OWN POLICY" .IX Header "DEFINING YOUR OWN POLICY" To implement your own custom policy .PP .Vb 1 \& cp File/Policy/Default.pm File/Policy/YourPolicy.pm .Ve .PP and modify YourPolicy accordingly. Then, create File/Policy/Config.pm containing: .PP .Vb 1 \& use constant IMPLEMENTATION => \*(AqYourPolicy\*(Aq; .Ve .PP Now having used File::Policy, calling check_safe in your scripts will enforce your policy (as well as give you access to log and temp paths in locations you recommend). .SH "SEE ALSO" .IX Header "SEE ALSO" File::Policy::Default, Safe .SH "VERSION" .IX Header "VERSION" \&\f(CW$Revision:\fR 1.5 $ on \f(CW$Date:\fR 2005/05/18 15:58:21 $ by \f(CW$Author:\fR johna $ .SH "AUTHOR" .IX Header "AUTHOR" John Alden .SH "COPYRIGHT" .IX Header "COPYRIGHT" (c) \s-1BBC 2005.\s0 This program is free software; you can redistribute it and/or modify it under the \s-1GNU GPL.\s0 .PP See the file \s-1COPYING\s0 in this distribution, or http://www.gnu.org/licenses/gpl.txt