OpenBSD::Pledge(3p)

NAME
OpenBSD::Pledge - Perl interface to OpenBSD pledge(2)

SYNOPSIS
  use OpenBSD::Pledge;
  my $file = "/usr/share/dict/words";
  pledge(qw( rpath ), [$file]) || die "Unable to pledge: $!";

  open my $fh, '<', $file or die "Unable to open $file: $!\n";
  while ( readline($fh) ) {
    print if /pledge/i;
  }
  close $fh;

DESCRIPTION
This module provides a perl interface to OpenBSD's pledge(2) syscall(2).

Once you promise that your program will only use certain syscalls the kernel will kill the program if it attempts to call any other interfaces.

  EXPORT
Exports "pledge" by default.

":all" will also export "pledgenames"

METHODS

  pledge(@promises, [\@paths])
With pledge(2) you can promise what abilities your program will need. You can pledge multiple times with more restrictive promises, but abilities can never be regained.

This interface always promises "stdio" because perl(1) itself uses some of the provided system calls.

You can supply an optional array reference of paths to be used as a whitelist, all other paths will appear not to exist. You may only limit the paths once.

Returns true on success, returns false and sets $! on failure.

  pledgenames
Returns a list of the possible promises you can pass to "pledge".

BUGS AND LIMITATIONS
Perl is particularly fond of "stdio" so that promise is always added by "pledge".

SEE ALSO
pledge(2)

<http://man.openbsd.org/pledge.2>

AUTHOR
Andrew Fresh, <afresh1@OpenBSD.org>

LICENSE AND COPYRIGHT
Copyright (C) 2015 by Andrew Fresh <afresh1@OpenBSD.org>

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.