App-LXC-Container
view release on metacpan or search on metacpan
lib/App/LXC/Container/Data/Debian.pm view on Meta::CPAN
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
use constant SEARCH => 'dpkg-query --search ';
sub package_of($$)
{
my ($self, $file) = @_;
$self->SUPER::package_of($file);
local $_;
# TODO: looks like pipe with redirection in shell never fails:
# uncoverable branch true
open my $dpkg, '-|', SEARCH . $file . ' 2>/dev/null'
or fatal('internal_error__1',
'error calling ' . SEARCH . $file . ': '. $!);
# escape special characters in file name:
$file =~ s/([]+*?{}[])/\\$1/;
my $package = undef;
while (<$dpkg>)
{
if (m/^([^ ]+): $file$/)
lib/App/LXC/Container/Texts.pm view on Meta::CPAN
fatal('unsupported_language__1', $new_language);
fatal('bad_container_name');
=head3 parameters:
$message_id ID of the text or format string in language module
@message_data optional additional text data for format string
=head3 description:
This function looks up the format (or simple) string passed in
C<$message_id> in the text hash of the currently used language, formats it
together with the C<@message_data> with sprintf and passes it on to
C<L<croak|Carp>>.
=head3 returns:
never
=cut
lib/App/LXC/Container/Texts.pm view on Meta::CPAN
warning('message__1_missing_en', $message_id);
=head3 parameters:
$message_id ID of the text or format string in language module
@message_data optional additional text data for format string
=head3 description:
This function looks up the format (or simple) string passed in
C<$message_id> in the text hash of the currently used language, formats it
together with the C<@message_data> with sprintf and passes it on to
C<L<carp|Carp>> (in case of errors or warnings) or C<L<warn|perlfunc/warn>>
(in case of informational messages).
Note that currently the first two functions only differ semantically. (This
may or may not change in the future.)
=cut
lib/App/LXC/Container/Texts.pm view on Meta::CPAN
=head3 example:
$_ = sprintf(txt($message_id), @_);
=head3 parameters:
$message_id ID of the text or format string in language module
=head3 description:
This function looks up the format (or simple) string passed in its parameter
C<$message_id> in the text hash of the currently used language and returns
it.
=head3 returns:
looked up string
=cut
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
t/02-init.t view on Meta::CPAN
#########################################################################
# failing and aborted tests of _init_config_dir:
chmod 0555, FAIL_PATH or die "can't chmod 0555 ", FAIL_PATH;
$_ = fail_in_sub_perl(HOME_PATH, FAIL_PATH, '2 2 2 2', 1);
like($_,
qr{^aborting after the following error\(s\):\nPermission denied at }m,
'bad configuration directory should fail');
$_ = fail_in_sub_perl(HOME_PATH, FAIL_PATH, '2 1 2 2', 0);
like($_,
qr{$re_dialog_main$re_dialog_buttons}ms,
'aborting initialisation 1 looks correct');
ok(! -d HOME_PATH . '/conf', 'conf does not yet exist');
$_ = fail_in_sub_perl(HOME_PATH, FAIL_PATH, '2 2 2 1', 0);
like($_,
qr{$re_dialog_main$re_dialog_buttons}ms,
'aborting initialisation 2 looks correct');
ok(! -d HOME_PATH . '/conf', 'conf still does not yet exist');
$_ = fail_in_sub_perl(FAIL_PATH, HOME_PATH, '2 2 2 2', 0);
like($_,
qr{^can't link '.*/t/tmp/fail/.lxc-configuration' to '.*/t/tmp/home': Permission denied at }m,
'unwritable home directory should fail');
ok(-d HOME_PATH . '/conf', 'conf got created regardless of error');
eval { App::LXC::Container::Setup::new('wrong-call', 'dummy'); };
like($@,
qr{^bad call to App::LXC::Container::Setup->new.*$re_msg_tail},
t/06-update.t view on Meta::CPAN
##))
);
my $conf = '';
if (-f CONF_ROOT . '/update-test-1.conf')
{
open my $in, '<', CONF_ROOT . '/update-test-1.conf'
or die "can't open ", CONF_ROOT, '/update-test-1.conf: ', $!;
$conf = join('', <$in>);
close $in;
}
like($conf, qr{^$re}s, 'LXC configuration file looks correct');
foreach (qw(bin lib lib32 lib64 libx32 sbin))
{
SKIP:{
-l '/' . $_ or skip "/$_ not symbolic link on $os", 1;
ok(-l CONF_ROOT . '/update-test-1/' . $_, 'got link: /' . $_);
}
}
my $tmp_sub = substr(TMP_PATH, 1);
foreach (qw(root tmp var var/log),
t/06-update.t view on Meta::CPAN
#))
);
if (-f $conf_file)
{
open my $in, '<', $conf_file
or die "can't open ", $conf_file . ': ', $!;
$conf = join('', <$in>);
close $in;
}
like($conf, qr{^$re}s,
'LXC configuration file looks correct - ' . $network);
my $conf_dir = CONF_ROOT . '/' . $network . '/';
foreach (qw(bin lib lib32 lib64 libx32 sbin))
{
SKIP:{
-l '/' . $_ or skip "/$_ not symbolic link on $os", 1;
ok(-l $conf_dir . $_, 'got link /' . $_ . ' in ' . $network);
}
}
foreach (qw(root tmp var var/log),
eval '$_->_prepare_user();';
like($@,
qr{can't remove .+tmp/lxc/run-test-1/etc/group': Permission denied$re_eval},
'failing write-access to target /etc has correct output');
_chmod(0755, '/lxc/run-test-1/etc');
$_->{mounts}{'/etc'} = 1;
output_like
{ $_->_prepare_user(); }
qr{^$}, qr{^$},
'_prepare_user for mapped /etc looks correct';
delete $_->{mounts}{'/etc'};
$_->{mounts}{'/etc/group'} = 1;
$_->{mounts}{'/etc/gshadow'} = 1;
$_->{mounts}{'/etc/passwd'} = 1;
my $re_account_files = 'group gshadow passwd shadow';
output_like
{ $_->_prepare_user(); }
qr{^$},
qr{^broken user mapping - check mounting of $re_account_files$re_msg_tail},
'_prepare_user for only 3 mapped account files looks correct';
$_->{mounts}{'/etc/shadow'} = 1;
output_like
{ $_->_prepare_user(); }
qr{^$}, qr{^$},
'_prepare_user for all 4 mapped account files looks correct';
#########################################################################
# check writing of startup script for 1st configuration:
_remove_file('/lxc/run-test-1/lxc-run.sh');
_setup_file('/lxc/run-test-1/lxc-run.sh');
_chmod(0444, '/lxc/run-test-1/lxc-run.sh');
eval '$_->_write_init_sh();';
like($@,
qr{can't open .+tmp/lxc/run-test-1/lxc-run.sh': Permission denied$re_eval},
( run in 0.344 second using v1.01-cache-2.11-cpan-64827b87656 )