App-LXC-Container

 view release on metacpan or  search on metacpan

lib/App/LXC/Container/Run.pm  view on Meta::CPAN

			 network => 0,
			 network_type => 'N',
			 rc => _ROOT_DIR_ . '/' . $container . '.conf',
			 root => 'root/of/container/not/found',
			 running => 0,
			 uids => [],
			 user => $user,
			 x11 => '-');
    my $self = bless \%configuration, $class;
    -e _ROOT_DIR_  or  fatal 'link_to_root_missing';
    -l _ROOT_DIR_  or  fatal '_1_is_not_a_symbolic_link' , _ROOT_DIR_;

    open my $in, '<', $self->{rc}  or  fatal 'can_t_open__1__2', $self->{rc}, $!;
    my $found = 0;
    while (<$in>)
    {
	if (m/^\s*#\s*MASTER\s*:\s*([GLN])(\d+)?\s*,\s*([-X])\s*,\s*([-A])\s*$/)
	{
	    if ($1 ne 'N')
	    {
		defined $2  or  fatal 'bad_master__1', $1 . ',' . $3 . ',' . $4;

lib/App/LXC/Container/Setup.pm  view on Meta::CPAN

			 users => [],
			 x11 => 0);
    my $self = bless \%configuration, $class;
    unless (-e _ROOT_DIR_)
    {	$self->_init_config_dir();   }
    unless (-l _ROOT_DIR_)
    {
	# uncoverable branch false
	if (-e _ROOT_DIR_)
	{
	    fatal '_1_is_not_a_symbolic_link' , _ROOT_DIR_;
	}
	else
	{
	    # This could only happen if symbolic link got deleted after
	    # creation in _init_config_dir:
	    # uncoverable statement
	    fatal 'internal_error__1' ,
		_ROOT_DIR_ . ' does not exist in Setup::new';
	}
    }

lib/App/LXC/Container/Texts/de.pm  view on Meta::CPAN

     IG
     => 'Verzeichnis ignorieren',
     NM
     => 'Unterverzeichnisse separiert lassen (nicht verschmelzen)',
     OV
     => 'Dataisystem überlagern (Original verstecken)',
     RW
     => 'lesender und schreibender Zugriff',
     _1_differs_from_standard__2
     => "%s unterscheidet sich vom Standard:\n%s",
     _1_does_not_exist
     => '%s existiert nicht!',
     _1_has_incompatible_state__2
     => '%s hat inkompatible Konfiguration zu %s',
     _1_is_not_a_symbolic_link
     => '%s ist kein symbolischer Link',
     _1_may_be_inaccessible
     => '%s ist eventuell unerreichbar für die root Kennung des LXC Containers',
     __
     => 'nur lesender Zugriff',
     aborting_after_error__1
     => "Abbruch nach folgendem Fehler:\n%s",
     audio
     => 'Audio',
     audio_network_only

lib/App/LXC/Container/Texts/en.pm  view on Meta::CPAN

     IG
     => 'ignore directory',
     NM
     => "don't merge sub-directories into directory",
     OV
     => 'overlay file-system (hide original)',
     RW
     => 'read/write access',
     _1_differs_from_standard__2
     => "%s differs from the standard configuration:\n%s",
     _1_does_not_exist
     => "%s doesn't exist!",
     _1_has_incompatible_state__2
     => '%s already has incompatible state to configuration of %s',
     _1_is_not_a_symbolic_link
     => '%s is not a symbolic link',
     _1_may_be_inaccessible
     => "%s may be inaccessible for LXC container's root account",
     __
     => 'read-only access',
     aborting_after_error__1
     => "aborting after the following error(s):\n%s",
     audio
     => 'audio',
     audio_network_only

lib/App/LXC/Container/Update.pm  view on Meta::CPAN

			 packages => [],
			 root_fs => '/var/lib/lxc',
			 specials => [],
			 user_ids => [],
			 users => {},
			 users_from => [],
			 x11 => 0,
			 x11_from => '???');
    my $self = bless \%configuration, $class;
    -e _ROOT_DIR_  or  fatal 'link_to_root_missing';
    -l _ROOT_DIR_  or  fatal '_1_is_not_a_symbolic_link' , _ROOT_DIR_;

    my $path = _ROOT_DIR_ . '/.networks.lst';
    open my $in, '<', $path  or  fatal 'can_t_open__1__2', $path, $!;
    while (<$in>)
    {
	next if m/^\s*(?:#.*)?$/;
	if (m/^(\d+):([-A-Z_a-z.0-9]+)$/)
	{   $self->{networks}{$2} = $1;   }
	else
	{   error 'ignoring_unknown_item_in__1__2', $path, $.;   }

lib/App/LXC/Container/Update.pm  view on Meta::CPAN

    debug(4, __PACKAGE__, '::_make_lxc_path($self, "', $path, '")');
    local $_ = $path . '/';
    s|(?<=.)/+$||;		# remove trailing / (just to be on the safe side)
    my @paths = ($_);
    unshift @paths, $_  while s|/+(?:[^/]+)$||  and  $_;

    my $root = $self->{root_fs} . '/' . $self->{name};
    -d $root  or  mkdir $root  or  fatal('can_t_create__1__2', $root, $!);
    foreach (@paths)
    {
	-e $_  or  fatal('_1_does_not_exist', $path);
	my $target = $root . $_;
	next if -e $target;
	my $stat = stat($_);
	my ($mode, $uid, $gid) = ($stat->mode, $stat->uid, $stat->gid);
	if (-d)
	{
	    $mode |= 0200;	# prevent blocking ourselves later on
	    if (-l)
	    {
		# links can be arbitrarily deep, so we use make_path on the

lib/App/LXC/Container/Update.pm  view on Meta::CPAN

    # part 4c - implicit mounts (from packages) - gather and merge paths of
    # packages (while respecting the filters!):

    foreach my $package (@packages)
    {
	# gather paths of next package:
	foreach (paths_of($package))
	{
	    unless (-e)
	    {
		error('_1_does_not_exist', $_);
		next;
	    }
	    my $state = undef;
	    if (-l)
	    {
		$state = $mounts->mount_point($_);
		$mounts->mount_point($_, IMPLICIT_LINK)  if  $state == UNDEFINED;
		next;
	    }
	    next if -d;

minil.toml  view on Meta::CPAN

name = "App-LXC-Container"
# badges = ["travis-ci.com"]
module_maker = "ModuleBuild"
static_install = "auto"

# no automatic upload to PAUSE/CPAN (yet):
[release]
do_not_upload_to_cpan = true

# we have a mock-up .Xauthority:
[FileGatherer]
include_dotfiles = true

#########################################################################
# This is a Linux-only module!
requires_external_bin=[
    'cp',
    'id',

t/01-texts.t  view on Meta::CPAN

is($_, "text '%s' fehlt", 'found correct German text message');

warning_like
{   $_ = txt('zz_unit_test');   }
{   carped =>
	qr/^text 'zz_unit_test' fehlt, falle auf en zurück$re_msg_tail/   },
    'missing message creates warning';
is($_, 'unit test string', 'found correct fall-back text message');

warnings_like
{   $_ = txt('zz_not_existing');   }
    [ { carped =>
	qr/^text 'zz_not_existing' fehlt, falle auf en zurück$re_msg_tail/ },
      { carped =>
	qr/^text 'zz_not_existing' fehlt$re_msg_tail/ } ],
    'missing message creates warning + error';

warning_is
{   App::LXC::Container::Texts::language('en');   }
    undef,
    'changing back to English works';
$_ = txt('message__1_missing');
is($_, "message '%s' missing", 'found correct English test message');

warning_like
{   $_ = txt('zz_not_existing');   }
{   carped => qr/^message 'zz_not_existing' missing$re_msg_tail/   },
    "missing message in 'en' creates error";

warning_like
{   $_ = txt('zz_unit_test_empty');   }
{   carped => qr/^message 'zz_unit_test_empty' missing$re_msg_tail/   },
    "empty message in 'en' creates error";

warning_like
{   info('message__1_missing', 'something');   }
    qr/^message 'something' missing$re_msg_tail_texts/,

t/03-setup.t  view on Meta::CPAN

eval {   App::LXC::Container::Setup::_modify_entry(1,2,3, 1,2);   };
like($@,
     qr/^INTERNAL ERROR [^:]+: uneven list in _modify_entry$re_msg_tail/,
     'short parameter list for _modify_entry fails');
eval {   App::LXC::Container::Setup::_modify_entry(1,2,3, 1,2,3,4,5);   };
like($@,
     qr/^INTERNAL ERROR [^:]+: uneven list in _modify_entry$re_msg_tail/,
     'uneven parameter list for _modify_entry fails');

my $dummy_obj = {name => 'not-accessible'};
sub test_not_accessible($)
{
    my ($file) = @_;
    my $short_path = '/lxc/conf/' . $file;
    _remove_file($short_path);
    _setup_file($short_path);
    _chmod(0, $short_path);
    my $re = "can't open '" . LXC_LINK . '/conf/' . $file . "'" . ': .*'
	. $re_msg_tail_eval;
    (my $func = $file) =~ s/^.*\.//;
    $func = 'App::LXC::Container::Setup::_parse_' . $func . '($dummy_obj);';
    eval "$func";
    like($@, qr/^$re$/,
	 'reading non-accessible configuration file ' . $file . ' fails');
}
test_not_accessible('ne-NOT-not-accessible.filter');
test_not_accessible('ne-CNF-not-accessible.master');
test_not_accessible('ne-MNT-not-accessible.mounts');
test_not_accessible('ne-PKG-not-accessible.packages');

$dummy_obj = {name => 'bad'};
sub test_bad_config($@)
{
    my $file = shift;
    my $short_path = '/lxc/conf/' . $file;
    _remove_file($short_path);
    _setup_file($short_path, @_);
    my $re = "ignoring unknown configuration item in '" . LXC_LINK .
	'/conf/' . $file . "'" . ', line 1' . $re_msg_tail_eval;



( run in 1.145 second using v1.01-cache-2.11-cpan-0a987023a57 )