Make it reload syscall.ph so both places get the functions
This commit is contained in:
parent
b78dcaaaab
commit
72e6e79407
3 changed files with 27 additions and 7 deletions
|
@ -5,7 +5,11 @@ use warnings;
|
|||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
|
||||
require 'syscall.ph';
|
||||
BEGIN {
|
||||
# Force reloading of all .ph files
|
||||
delete $INC{$_} for (grep {/\.ph$/} keys %INC);
|
||||
require 'syscall.ph';
|
||||
}
|
||||
|
||||
my @mount_consts = qw/MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_REMOUNT MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_BIND MS_MOVE MS_REC MS_SILENT MS_POSIXACL MS_UNBINDABLE MS_PRIVATE MS_SLAVE MS_SHARED MS_RELATIME MS_KERNMOUNT MS_I_VERSION MS_STRICTATIME MS_LAZYTIME MS_ACTIVE MS_NOUSER/;
|
||||
|
||||
|
@ -21,7 +25,7 @@ sub mount {
|
|||
|
||||
my $options_str = join ',', map {"$_=".$options_hr->{$_}} keys %$options_hr;
|
||||
|
||||
my $ret = syscall(SYS_mount(), $source, $target, $filesystem, $flags, $options_str);
|
||||
my $ret = syscall(SYS_mount(), $source, $target, $filesystem//undef, $flags, $options_str);
|
||||
|
||||
if ($ret != 0) {
|
||||
die "mount failed: $ret $!";
|
||||
|
|
|
@ -7,6 +7,11 @@ use Sys::Linux::Mount qw/:all/;
|
|||
use Sys::Linux::Unshare qw/:all/;
|
||||
use POSIX qw/_exit/;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
|
||||
our @EXPORT_OK=qw/namespace/;
|
||||
|
||||
sub namespace {
|
||||
my ($options) = @_;
|
||||
|
||||
|
@ -25,6 +30,7 @@ sub namespace {
|
|||
} elsif (ref $options->{private_tmp}) {
|
||||
die "Bad ref type passed as private_tmp";
|
||||
} else {
|
||||
mount("/tmp", "/tmp", "tmpfs", 0, undef);
|
||||
mount("/tmp", "/tmp", "tmpfs", MS_PRIVATE, undef);
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +54,9 @@ sub namespace {
|
|||
my $mid_pid = fork();
|
||||
|
||||
unless($mid_pid == -1) {
|
||||
if($mid_pid) {
|
||||
if ($mid_pid) {
|
||||
# Original Process
|
||||
waitpid($mid_pid); # WE MUST BLOCK
|
||||
waitpid($mid_pid, 0); # WE MUST BLOCK
|
||||
return; # don't run anything else in here
|
||||
} else {
|
||||
# Middle child process
|
||||
|
@ -60,7 +66,7 @@ sub namespace {
|
|||
|
||||
unless($child_pid == -1) {
|
||||
if ($child_pid) {
|
||||
waitpid($child_pid);
|
||||
waitpid($child_pid, 0);
|
||||
} else {
|
||||
$options->{pid}->();
|
||||
}
|
||||
|
@ -80,3 +86,5 @@ sub namespace {
|
|||
$post_setup->();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package Sys::Linux::Unshare;
|
||||
|
||||
use strict;
|
||||
#use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
|
||||
require 'syscall.ph';
|
||||
BEGIN {
|
||||
# Force reloading of all .ph files
|
||||
delete $INC{$_} for (grep {/\.ph$/} keys %INC);
|
||||
require 'syscall.ph';
|
||||
}
|
||||
|
||||
my @unshare_consts = qw/CSIGNAL CLONE_VM CLONE_FS CLONE_FILES CLONE_SIGHAND CLONE_PTRACE CLONE_VFORK CLONE_PARENT CLONE_THREAD CLONE_NEWNS CLONE_SYSVSEM CLONE_SETTLS CLONE_PARENT_SETTID CLONE_CHILD_CLEARTID CLONE_DETACHED CLONE_UNTRACED CLONE_CHILD_SETTID CLONE_NEWCGROUP CLONE_NEWUTS CLONE_NEWIPC CLONE_NEWUSER CLONE_NEWPID CLONE_NEWNET CLONE_IO/;
|
||||
|
||||
|
@ -19,6 +24,9 @@ our %EXPORT_TAGS = (
|
|||
sub unshare {
|
||||
my ($flags) = @_;
|
||||
|
||||
|
||||
local $! = 0;
|
||||
### FIXME XXX HACK FUCK YOU = 272 unshare syscall number on x86_64
|
||||
my $ret = syscall(SYS_unshare(), $flags);
|
||||
|
||||
if ($ret != 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue