Posted 26 March 2017 - 09:36 AM
TL;DR - how to make APIs identify the caller environment and act differently based on it.
Hello,
is there any way to identify the program started with os.run? I am trying to make it so that every program runs on a specific UID and has different levels of file/api access. The best way would be so that no craftOS API is broken. I already am able to replace the os.run API so I can modify it.
My current code is as follows:
So, I have a process table, now the problem is that how do I get a parent uid/pid in any API (including os.run)? I could store something like a function or a table so that if a variable in program's environment is altered, then it would make calls as a nobody user.
Hello,
is there any way to identify the program started with os.run? I am trying to make it so that every program runs on a specific UID and has different levels of file/api access. The best way would be so that no craftOS API is broken. I already am able to replace the os.run API so I can modify it.
My current code is as follows:
function os.run( _tEnv, _sPath, ... )
local tEnv = _tEnv
lastid = lastid+1
local pid = lastid
ptable[pid] = {_sPath, uid}
ret = _osrun(tEnv, _sPath, ...)
ptable[pid] = nil
return ret
end
Where _osrun is the native os.run and a ptable and lastid are local variables.So, I have a process table, now the problem is that how do I get a parent uid/pid in any API (including os.run)? I could store something like a function or a table so that if a variable in program's environment is altered, then it would make calls as a nobody user.
Edited on 26 March 2017 - 07:38 AM