1# $OpenBSD: Unveil.pm,v 1.1 2019/07/09 20:41:54 afresh1 Exp $ # 2package OpenBSD::Unveil; 3 4use 5.028; 5use strict; 6use warnings; 7 8use Carp; 9 10use parent 'Exporter'; 11our %EXPORT_TAGS = ( 'all' => [qw( unveil )] ); 12our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); 13our @EXPORT = qw( unveil ); ## no critic 'export' 14 15our $VERSION = '0.02'; 16 17require XSLoader; 18XSLoader::load( 'OpenBSD::Unveil', $VERSION ); 19 20sub unveil 21{ ## no critic 'unpack' 22 croak("Usage: OpenBSD::Unveil::unveil([path, permissions])") 23 unless @_ == 0 || @_ == 2; ## no critic 'postfix' 24 return _unveil(@_); 25} 26 271; 28 29## no critic 'pod sections' 30__END__ 31 32=head1 NAME 33 34OpenBSD::Unveil - Perl interface to OpenBSD unveil(2) 35 36=head1 SYNOPSIS 37 38 use OpenBSD::Unveil; 39 40 my $file = "/usr/share/dict/words"; 41 unveil( $file, "r" ) || die "Unable to unveil: $!"; 42 unveil() || die "Unable to lock unveil: $!"; 43 open my $fh, '<', $file or die "Unable to open $file: $!"; 44 45 print grep { /unveil/i } readline($fh); 46 close $fh; 47 48 49=head1 DESCRIPTION 50 51This module provides a perl interface to OpenBSD's L<unveil(2)> L<syscall(2)>. 52 53=head1 EXPORT 54 55Exports L</unveil> by default. 56 57=head1 FUNCTIONS 58 59=head2 unveil 60 61Perl interface to L<unveil(2)>. 62 63 unveil($paths, $permissions) 64 unveil() # to lock 65 66Returns true on success, returns false and sets $! on failure. 67Throws an exception on incorrect number of parameters. 68 69=head1 SEE ALSO 70 71L<unveil(2)> 72 73L<http://man.openbsd.org/unveil.2> 74 75=head1 AUTHOR 76 77Andrew Fresh, E<lt>afresh1@OpenBSD.orgE<gt> 78 79=head1 LICENSE AND COPYRIGHT 80 81Copyright (C) 2019 by Andrew Fresh E<lt>afresh1@OpenBSD.orgE<gt> 82 83Permission to use, copy, modify, and distribute this software for any 84purpose with or without fee is hereby granted, provided that the above 85copyright notice and this permission notice appear in all copies. 86 87THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 88WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 89MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 90ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 91WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 92ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 93OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 94 95=cut 96