[orbis-kernel] implement sys_is_in_sandbox, sys_sandbox_path, sys_randomized_path

This commit is contained in:
DH 2023-11-11 21:00:41 +03:00
parent 4a80f918fe
commit 1f001101a4
2 changed files with 24 additions and 7 deletions

View file

@ -698,10 +698,11 @@ SysResult sys_dynlib_prepare_dlclose(Thread *thread /* TODO */);
SysResult sys_dynlib_get_proc_param(Thread *thread, ptr<ptr<void>> procParam,
ptr<uint64_t> procParamSize);
SysResult sys_dynlib_process_needed_and_relocate(Thread *thread);
SysResult sys_sandbox_path(Thread *thread /* TODO */);
SysResult sys_sandbox_path(Thread *thread, ptr<const char> path);
SysResult sys_mdbg_service(Thread *thread, uint32_t op, ptr<void> arg0,
ptr<void> arg1);
SysResult sys_randomized_path(Thread *thread /* TODO */);
SysResult sys_randomized_path(Thread *thread, sint type, ptr<char> path,
ptr<sint> length);
SysResult sys_rdup(Thread *thread, sint a, sint b);
SysResult sys_dl_get_metadata(Thread *thread /* TODO */);
SysResult sys_workaround8849(Thread *thread /* TODO */);

View file

@ -680,7 +680,8 @@ orbis::SysResult orbis::sys_obs_eport_close(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_is_in_sandbox(Thread *thread /* TODO */) {
std::printf("sys_is_in_sandbox() -> 0\n");
ORBIS_LOG_ERROR(__FUNCTION__, thread->tproc->isInSandbox);
thread->retval[0] = thread->tproc->isInSandbox ? 1 : 0;
return {};
}
orbis::SysResult orbis::sys_dmem_container(Thread *thread, uint id) {
@ -843,8 +844,10 @@ orbis::SysResult orbis::sys_dynlib_process_needed_and_relocate(Thread *thread) {
ORBIS_LOG_WARNING(__FUNCTION__);
return {};
}
orbis::SysResult orbis::sys_sandbox_path(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
orbis::SysResult orbis::sys_sandbox_path(Thread *thread, ptr<const char> path) {
ORBIS_LOG_ERROR(__FUNCTION__, path);
thread->tproc->isInSandbox = true;
return {};
}
struct mdbg_property {
@ -895,8 +898,21 @@ orbis::SysResult orbis::sys_mdbg_service(Thread *thread, uint32_t op,
return {};
}
orbis::SysResult orbis::sys_randomized_path(Thread *thread /* TODO */) {
std::printf("TODO: sys_randomized_path()\n");
orbis::SysResult orbis::sys_randomized_path(Thread *thread, sint type,
ptr<char> path, ptr<sint> length) {
ORBIS_LOG_TODO(__FUNCTION__, type, (ptr<void>)path, length ? *length : 0);
if (type == 0) {
if (thread->tproc->isInSandbox) {
std::strcpy(path, "system");
*length = sizeof("system") - 1;
return {};
}
*path = '\0';
*length = 0;
} else {
thread->where();
}
return {};
}
orbis::SysResult orbis::sys_rdup(Thread *thread, sint pid, sint fd) {