module engine import os fn test_sandbox_access_masks_and_nonroot_activation() ! { assert sandbox_filesystem_mask(1) == 0x1fff assert sandbox_filesystem_mask(2) == 0x3fff assert sandbox_filesystem_mask(3) == 0x7fff assert sandbox_filesystem_mask(99) == 0x7fff assert sandbox_denied_syscalls.len == 83 dir := os.join_path(os.vtmp_dir(), 'native-sandbox-options-${os.getpid()}') os.mkdir_all(dir)! defer { os.rmdir_all(dir) or { eprintln(err) } } mut handle := initialize('/', dir)! defer { handle.release() or { eprintln(err) } } assert !handle.uses_download_sandbox()! if C.getuid() != 0 { handle.set_string_option(.sandbox_user, 'root')! assert !handle.uses_download_sandbox()! if _ := handle.sandbox_setup_child('root', none, true) { assert false } assert handle.errno() == .ok if _ := handle.register_syncdb('', 0) { assert false } mut public_code := -1 handle.sandbox_setup_child('root', none, true) or { public_code = err.code() } assert public_code == int(Errno.wrong_args) mut worker_code := -1 handle.sandbox_setup_identity(0, 0, none, true) or { worker_code = err.code() } assert worker_code == int(Errno.badperms) assert handle.errno() == .wrong_args } }