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

block command-use access(non-malicious)

Started by tdog21, 05 February 2014 - 07:17 PM
tdog21 #1
Posted 05 February 2014 - 08:17 PM
so for creating a lock system with multiple users having different tier access i put in this piece of code:

h = fs.open("programs", "w")
h.writeLine("print(\"Sorry you do not have access to that command\")")
h.writeLine("os.sleep( 20 )")
h.writeLine("shell.run(\"clear\")")
h.close()
what i'm basically wondering is, is it possible to bypass this as my entire locking system revolves around having different levels of access (being able to edit, being able to enter other directorys, etc.) thanks in advance if you can help me
Lyqyd #2
Posted 05 February 2014 - 08:45 PM
Moved to Ask a Pro.

That doesn't actually block anything at all, which you probably already know.
tdog21 #3
Posted 05 February 2014 - 08:53 PM
Moved to Ask a Pro.

That doesn't actually block anything at all, which you probably already know.
actually (i dont know if it's the version i'm using or something) but if you do this, and then run programs (like you would to see the list) this runs instead of the list of programs works the same with edit, and becuase of this the base CC commands are "blocked" on the computer this is run on i should be able to remove them on a reboot, but otherwise i dont think you can bypass this, just wanted to see if someone could find a way out of it. again might be the version of CC i'm using but i believe this should work on the most recent version as well.
Edited on 05 February 2014 - 07:55 PM
Lyqyd #4
Posted 05 February 2014 - 09:03 PM
All that does is show a list of the programs, you can still run any of them. I've never even run the "programs" program, as far as I can recall. If you made a file at "/edit" that did the same thing, all people would have to do is run "/rom/programs/edit" instead.
awsmazinggenius #5
Posted 05 February 2014 - 09:37 PM
So you can override fs.write, I believe, to prevent use of the edit program. But then that would apply to all programs that save data.
tdog21 #6
Posted 06 February 2014 - 04:55 PM
ok thanks so it doesn't work if you know how to do more in CC than use the basic commands. this helps me alot and it means i need to try and find another way to block access to programs, or else just make a regular lock system
awsmazinggenius #7
Posted 06 February 2014 - 10:43 PM
You can override the base functions like shell.run, os.run, fs.read/fs.write, etc.
D3matt #8
Posted 06 February 2014 - 11:40 PM
The easiest and most effective way is probably a custom shell that launches at startup that controls what commands you can run. Make sure to block ctrl+t and it should be pretty secure.
awsmazinggenius #9
Posted 06 February 2014 - 11:49 PM
What if you run a program that can edit files/whatever?
D3matt #10
Posted 07 February 2014 - 12:01 AM
What if you run a program that can edit files/whatever?
It's up to you to design your custom shell to prevent potentially malicious programs from running.
awsmazinggenius #11
Posted 07 February 2014 - 12:12 AM
Or edit the base functions to control what dirs/whatever the user can write in..