check whether newuidmap and newgidmap are available
This commit is contained in:
parent
95669ff193
commit
d232870b28
1 changed files with 26 additions and 0 deletions
26
mmdebstrap
26
mmdebstrap
|
@ -109,6 +109,16 @@ sub test_unshare() {
|
||||||
if (($? >> 8) != 0) {
|
if (($? >> 8) != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
# if newuidmap and newgidmap exist, the exit status will be 1 when
|
||||||
|
# executed without parameters
|
||||||
|
system "newuidmap 2>/dev/null";
|
||||||
|
if (($? >> 8) != 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
system "newgidmap 2>/dev/null";
|
||||||
|
if (($? >> 8) != 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1357,6 +1367,22 @@ sub main() {
|
||||||
if ($EFFECTIVE_USER_ID == 0) {
|
if ($EFFECTIVE_USER_ID == 0) {
|
||||||
print STDERR "I: cannot use unshare mode when executing as root\n";
|
print STDERR "I: cannot use unshare mode when executing as root\n";
|
||||||
}
|
}
|
||||||
|
system "newuidmap 2>/dev/null";
|
||||||
|
if (($? >> 8) != 1) {
|
||||||
|
if (($? >> 8) == 127) {
|
||||||
|
print STDERR "I: cannot find newuidmap\n";
|
||||||
|
} else {
|
||||||
|
print STDERR "I: newuidmap returned unknown exit status\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system "newgidmap 2>/dev/null";
|
||||||
|
if (($? >> 8) != 1) {
|
||||||
|
if (($? >> 8) == 127) {
|
||||||
|
print STDERR "I: cannot find newgidmap\n";
|
||||||
|
} else {
|
||||||
|
print STDERR "I: newgidmap returned unknown exit status\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
my $procfile = '/proc/sys/kernel/unprivileged_userns_clone';
|
my $procfile = '/proc/sys/kernel/unprivileged_userns_clone';
|
||||||
open(my $fh, '<', $procfile) or die "failed to open $procfile: $!";
|
open(my $fh, '<', $procfile) or die "failed to open $procfile: $!";
|
||||||
chomp(my $content = do { local $/; <$fh> });
|
chomp(my $content = do { local $/; <$fh> });
|
||||||
|
|
Loading…
Reference in a new issue