Last modified 3 years ago
BSD::Jail::Object
BSD::Jail::Object is a perl module for managing jailed environments under FreeBSD, in an object oriented fashion.
Downloads
You can download the latest version from CPAN.
Installation
Install via the regular perl module methods:
perl Makefile.pl make make install
Documentation
Full help and API can be found via perldoc BSD::Jail::Object.
Here are some examples for quick reference!
A perl implementation of jls:
use BSD::Jail::Object 'jids'; print " JID IP Address Hostname Path\n"; printf "%6d %−15.15s %−29.29s %.74s\n", $_−>jid, $_−>ip, $_−>hostname, $_−>path foreach jids( instantiate => 1 );
And here’s jexec (actually, a jexec that lets you optionally select by something other than just a jid):
my $j = BSD::Jail::Object−>new( $ARGV[0] ) or die $@; $j−>attach && chdir(’/’) && exec $ARGV[1] or exit;
Create a new jail:
$options = { path => '/tmp', ip => '127.0.0.1', hostname => 'example.com' }; $j = BSD::Jail::Object−>new( $options ) or die $@;
Attach to an existing jail:
$j = BSD::Jail::Object−>new( 'example.com' ); $j−>attach;
Do something in all jails:
foreach $j ( jids(instantiate => 1) ) { if ( fork ) { $j−>attach; # # do something exciting # exit; } }
Development
You can also check out the source via Mercurial from the following uri:
% hg clone http://code.martini.nu/perl-modules/
