make sure that unshare mode cannot be run as superuser

pull/1/head
parent ec9ceb2115
commit cd39a44934
Signed by: josch
GPG Key ID: F2CBA5C78FBD83E1

@ -88,6 +88,9 @@ sub get_tar_compress_options($) {
}
sub test_unshare() {
if ($EFFECTIVE_USER_ID == 0) {
return 0;
}
# arguments to syscalls have to be stored in their own variable or
# otherwise we will get "Modification of a read-only value attempted"
my $unshare_flags = CLONE_NEWUSER;
@ -1351,6 +1354,9 @@ sub main() {
}
} elsif ($options->{mode} eq 'unshare') {
if (!test_unshare()) {
if ($EFFECTIVE_USER_ID == 0) {
print STDERR "I: cannot use unshare mode when executing as root\n";
}
my $procfile = '/proc/sys/kernel/unprivileged_userns_clone';
open(my $fh, '<', $procfile) or die "failed to open $procfile: $!";
chomp(my $content = do { local $/; <$fh> });

Loading…
Cancel
Save