- ComputerCraft | Programmable Computers for Minecraft
- → Ajt86's Content
Ajt86's Content
There have been 17 items by Ajt86 (Search limited from 10-February 22)
#243467 Fox Anti-Virus 1.01
Posted by
Ajt86
on 17 January 2016 - 01:01 PM
in
Programs
Anti-viruses are also a lot less useful since 1.76 simply because you can protect yourself against them now if you have a secure system.
#243466 [Solved] Unload all APIs
Posted by
Ajt86
on 17 January 2016 - 12:32 PM
in
Ask a Pro
The only API I had to reload was the IO API.
I have no idea how I got the others to work.
Here's the method I used (worked)
local sandbox = {--[[ Generate environment here ]]} -- Your sandbox environment
sandbox._G = sandbox
sandbox.func = function(...) -- Do this for each function
_ENV = sandbox
return func(...)
end
Thanks for your help.
#243456 [Solved] Unload all APIs
Posted by
Ajt86
on 17 January 2016 - 06:58 AM
in
Ask a Pro
Bomb Bloke, on 17 January 2016 - 12:34 AM, said:
local tAPIsLoading = {}
function os.loadAPI( _sPath )
local sName = fs.getName( _sPath )
if tAPIsLoading[sName] == true then
printError( "API "..sName.." is already being loaded" )
return false
end
tAPIsLoading[sName] = true
local tEnv = {}
setmetatable( tEnv, { __index = _G } )
local fnAPI, err = loadfile( _sPath, tEnv )
if fnAPI then
local ok, err = pcall( fnAPI )
if not ok then
printError( err )
tAPIsLoading[sName] = nil
return false
end
else
printError( err )
tAPIsLoading[sName] = nil
return false
end
local tAPI = {}
for k,v in pairs( tEnv ) do
if k ~= "_ENV" then
tAPI[k] = v
end
end
_G[sName] = tAPI
tAPIsLoading[sName] = nil
return true
endAs you can see, the API is loaded as a function, and then the environment of that function is replaced with a custom one. The whole point of this is so that any globals the API defines can then be extracted and dumped into the API table which finally ends up in _G (that being the "loaded API").
That is to say, APIs can't touch _ENV. This is why they can't call "shell" or "multishell" functions: Those are loaded into the global environment area all our scripts use, _ENV, as opposed to the table APIs generally go into, _G.
(Edit: Point is, everything an API does is supposed to apply on a system-wide basis. If two different scripts asking one API to do something results in a conflict, then that's the fault of the API, and it's not your problem to fix. There's a reason why you can't define windows using the term API as a parent, for example.)
There's a problem with that. I want to unload all the APIs bios.lua initialized and I want to reload those in the sandboxed filesystem.
I've already sandboxed os.loadAPI to load APIs into the sandboxed environment.
#243352 What do you mean "61: ')' expected"? That line already has one!
Posted by
Ajt86
on 16 January 2016 - 11:59 PM
in
Ask a Pro
ZippoMoon, on 16 January 2016 - 11:54 PM, said:
Dragon53535, on 16 January 2016 - 11:50 PM, said:
print("Vault Door Lock: - [1] "..VDL)
--# Should be
print("Vault Door Lock: - [1]"..tostring(VDL))
--#You need to tostring the boolean
I suppose taking the meaning of the above post is good, but you really should of gone with the entirety of what i put You need to add tostring if it's not a string otherwise you'll get an error about concatenating string and insert type here
#243346 [Solved] Unload all APIs
Posted by
Ajt86
on 16 January 2016 - 11:50 PM
in
Ask a Pro
Bomb Bloke, on 16 January 2016 - 11:44 PM, said:
Are you aware of the differences between _ENV and _G?
I'm enclosing each function in a function whose _ENV is equal to the sandbox. Kind of like this:
sandbox[function] = function(...) _ENV = sandbox return _G[function](...) end
However, APIs that define variables outside the function definition can no longer access those variables. And they do use the sandbox environment, functions inherit their environment from the function above them in the stack.
#243343 Get item ID inside blood magic altar.
Posted by
Ajt86
on 16 January 2016 - 11:47 PM
in
Ask a Pro
local atable = {
["key"] = "Value"
}
print(atable.key) -- Prints "Value"
print(atable["key"]) -- Prints "Value"
The latter is more useful when Lua could misinterpret the dot notation (spaces or special characters in key). It is also more useful when you're dynamically indexing the table.
#243336 [Solved] Unload all APIs
Posted by
Ajt86
on 16 January 2016 - 11:36 PM
in
Ask a Pro
Unfortunately, APIs often declare variables outside the function, which get excluded by my idea of using _ENV (and setfenv wouldn't help either).
My plan to work around this is to unload all APIs and reload them in the sandbox table.
Unfortunately, if I try to reload all of them (except term, window and those the computer can't access), the computer just shuts down.
How would I reload all the available APIs without the computer shutting down?
#243134 Fox Anti-Virus 1.01
Posted by
Ajt86
on 14 January 2016 - 09:10 PM
in
Programs
To avoid this, you'll want to shutdown (Ctrl + S), insert the disk, and start the computer.
Otherwise, some viruses might infect the disk.
#243133 [Solved] Os.run with _G table
#243023 ComputerCraft 1.77 (Minecraft 1.8.9) Beta Information
Posted by
Ajt86
on 13 January 2016 - 08:04 PM
in
Beta Testing
#242932 Ability to overwrite ROM (except bios.lua) on first startup (new computer)
Posted by
Ajt86
on 12 January 2016 - 02:50 PM
in
Suggestions
#242881 Ability to overwrite ROM (except bios.lua) on first startup (new computer)
Posted by
Ajt86
on 11 January 2016 - 07:07 PM
in
Suggestions
#242872 Ability to overwrite ROM (except bios.lua) on first startup (new computer)
Posted by
Ajt86
on 11 January 2016 - 06:07 PM
in
Suggestions
Would it be possible to allow the person who placed the computer to modify the rom directory or allow its modification only when a new computer is placed (computer must be backed up and replaced to fix)?
This system could become 100% secure simply by requiring that the person labels their computer and the OS checks the computer's ID every startup to verify that a potential hacker hasn't (somehow) copied all files off and replaced the computer with a new one. On top of that, the hacker wouldn't even be able to obtain the files without breaking into the OS, assuming the OS is custom and supports user-level security (or file encryption).
Here's how exactly it could work...
- User places a new computer (new ID generated)
- Computer asks the user if they want to modify the rom (recommends to select "no")
- If yes, computer opens up into a basic shell where the user is asked to select a disk drive containing the new rom
- Computer then resumes running by going through the OS's security checks (OS handles sandboxing, etc).
- User now has a secure computer.
- ComputerCraft | Programmable Computers for Minecraft
- → Ajt86's Content


