mount /sys and /proc as read-only in root mode

This commit is contained in:
Johannes 'josch' Schauer 2020-01-24 10:14:10 +01:00
parent a8fa48fbc7
commit c4a47947ab
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -929,8 +929,9 @@ sub run_chroot {
or warn "umount /sys failed: $?";
};
0 == system(
'mount', '-t', 'sysfs', '-o',
'nosuid,nodev,noexec', 'sys', "$options->{root}/sys"
'mount', '-t', 'sysfs',
'-o', 'ro,nosuid,nodev,noexec', 'sys',
"$options->{root}/sys"
) or error "mount /sys failed: $?";
} elsif ($options->{mode} eq 'unshare') {
# naturally we have to clean up after ourselves in sudo mode where
@ -978,7 +979,8 @@ sub run_chroot {
0 == system('umount', "$options->{root}/proc")
or error "umount /proc failed: $?";
};
0 == system('mount', '-t', 'proc', 'proc', "$options->{root}/proc")
0 == system('mount', '-t', 'proc', '-o', 'ro', 'proc',
"$options->{root}/proc")
or error "mount /proc failed: $?";
} elsif ($options->{mode} eq 'unshare') {
# naturally we have to clean up after ourselves in sudo mode where