This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MudkipTheEpic's profile picture

[1.5][Error] "File not found" when using sandboxing program

Started by MudkipTheEpic, 09 March 2013 - 01:10 PM
MudkipTheEpic #1
Posted 09 March 2013 - 02:10 PM
Hi! Whenever I sandbox with my custom program, using [filename] [dir] with a slash at the end, whenever I say a program in there, it just says "File not found". "No such program" still appears with saying a non-existing program and all, it's just you cannot run programs.

Code: 6kYxAqi5

Usage: sandbox dir/
MudkipTheEpic #2
Posted 09 March 2013 - 02:42 PM
Do you think the problem is shell.run?
3LiD #3
Posted 09 March 2013 - 03:00 PM
If you are using CraftOS 1.3 or lower then having args in shell.run() is like this: shell.run("someprogram somearg") but in higher versions of computercraft it is: shell.run("someprogram", "somearg")

I dont know if this helps
MudkipTheEpic #4
Posted 09 March 2013 - 03:46 PM
CraftOS 1.5
3LiD #5
Posted 09 March 2013 - 03:47 PM
Ok.. I can't help you here. Im sorry.
MudkipTheEpic #6
Posted 09 March 2013 - 03:49 PM
Ok.. I can't help you here. Im sorry.
'

Oh, it's ok. Someone else can help if they want!

(I always feel helpless looking at people's ask a pro questions when they have more posts/programs then me. XP)
faubiguy #7
Posted 09 March 2013 - 05:22 PM
I think the problem is that the sandbox dir is getting added multiple times. For example os.run calls loadfile, which itself calls fs.open, and since all 3 of those are sandboxed, it gets added 3 times.

I'd suggest sandboxing only the functions that directly access files without calling any other lua functions to do it (which is just the functions in the fs API)

(Also, this is unrelated, but I thought I'd point out that for functions with a variable number of arguments, instead of assigning them to a table, then unpacking it, you can directly pass the … to another function.)
MudkipTheEpic #8
Posted 09 March 2013 - 05:57 PM
It works! Thanks!
3LiD #9
Posted 09 March 2013 - 09:34 PM
I found this in your code:


--print(sandboxed)
--Check if loaded...
if fs.setReadOnly then error("Already loaded!!!",2) end
privTable["aliases"]=shell.aliases()

1st there is NO fs.setReadOnly and if there was it should be fs.setReadOnly() < Brackets
theoriginalbit #10
Posted 09 March 2013 - 09:48 PM
1st there is NO fs.setReadOnly and if there was it should be fs.setReadOnly() < Brackets
Line 107
function fs.setReadOnly(file, bool)
The purpose of
if fs.setReadOnly then error("Already loaded!!!",2) end
Is to see if his API has already been loaded.

Also no, you don't need brackets. He is checking if the function exists, if you don't use brackets its the actual function pointer, not the function itself, try this on a CC1.4 computer and see what happens
print(term.isColor)
now try this on CC1.3 and note the difference
print(term.isColor)
3LiD #11
Posted 09 March 2013 - 10:32 PM
Ok… Im sorry… As in now says in my signature:

Dont expect me to read through your hundreds of lines of code.

Well it isnt hundreds but I still dont like to read a ton of code.
remiX #12
Posted 09 March 2013 - 10:36 PM
Ok… Im sorry… As in now says in my signature:

Dont expect me to read through your hundreds of lines of code.

Well it isnt hundreds but I still dont like to read a ton of code.

You don't have to read the code. Use the search function, :huh:/>
theoriginalbit #13
Posted 09 March 2013 - 10:38 PM
Ok… Im sorry… As in now says in my signature:

Dont expect me to read through your hundreds of lines of code.

Well it isnt hundreds but I still dont like to read a ton of code.
While I agree with that prospect, as I too don't like reading through 100's of lines of code, before making suggestions that you did I do like to scan (or use the 'find' feature) to see if the function exists in their script before saying that its the cause of their problem.

EDIT: Also if you aren't willing to read the code then maybe you shouldn't be helping, sometimes it can take quite a lot of reading to see the problem.
Edited on 09 March 2013 - 09:39 PM
3LiD #14
Posted 09 March 2013 - 11:00 PM
I am willing to help. Im just not willing to read through heaps of code. I know the little tips and trick to find the code quick.
theoriginalbit #15
Posted 09 March 2013 - 11:04 PM
I know the little tips and trick to find the code quick.
Clearly didn't… but moral of the story, make sure what you're saying is a problem, actually is a problem?
MudkipTheEpic #16
Posted 10 March 2013 - 04:59 AM
Is there a way to secure setfenv to not modify my functions? Because when I set it to error about insufficient permissions all the time when used, it breaks the whole thing.