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

[Question/Lua] Read-Only Privileges

Started by Stevenmcl, 20 November 2012 - 01:43 AM
Stevenmcl #1
Posted 20 November 2012 - 02:43 AM
Hi,

I've been messing around with Lua a lot today and kinda just started learning it. Reading tutorials on how to code with it, and such and made my first own little OS lock system where you need a password to get into it. I've coded it with anti-terminate as well as a backdoor password encase something goes wrong, yadda yadda yaddda.

My question is, is there a way where I could set the lua file as read-only if I were to give it to someone over floppy? Or possibly by having it request a password if someone tries to edit it or something? I'm not sure how I could have it edit proof, but it'd be interesting to figure out.

This is a bit of an obscure question and certainly a random one, but I was wondering if anyone knew how to do something like this. I was thinking maybe creating another program that'll set read/write privileges on files, but I'm not sure of ComputerCraft has a sort of system like that, that I could play with.

Anyway, thanks for the help and if you can't think of anything either, you even reading this is greatly appreciated.
Kingdaro #2
Posted 20 November 2012 - 03:35 AM
Someone a while ago asked about something like this. It's really as simple as overwriting fs.open() using a startup file in the disk.

In disk/startup

-- if your program name is "foo"

local blockedProgram = 'disk/foo'
local _open = fs.open

function fs.open(file, mode)
  if file ~= blockedProgram then
    return _open(file, mode)
  end
end

You could also use this same method to prevent copying or deleting.
Lyqyd #3
Posted 20 November 2012 - 03:44 AM
This won't prevent them from just putting the disk into a running computer and editing it, of course.
Kingdaro #4
Posted 20 November 2012 - 03:50 AM
This won't prevent them from just putting the disk into a running computer and editing it, of course.
That's true. There's also hiding it with the . in front of it, and the user won't really know it's there unless they actually search for that specific file name, since it doesn't show up with ls.

You have a point, though, there's really no way to achieve full security. :/
Stevenmcl #5
Posted 20 November 2012 - 10:19 AM
Ah, fair enough.

Thanks for the help guys, I guess if something can be interpreted in a raw form it can also be edited straight from there so I don't know if I'd be able to incorporate anything directly within the program as a local setup to prevent it from being run unless they figure out how to get the OS to run .exe versions of the lua script via compiler. That'd be cool, but you know.

Anyway, thanks again.

Edit: I've just thought of something. Using a one trip install, I could supply a program coded that'll pull a file from pastebin that'll download some other scripts, install them, lock them, then delete itself having the scripts installed in place with the code supplied above.

So in series:
1. It'll load a script I supply.
2. The script will download another script and run that.
3. The script downloaded will automate the download and install of the scripts that'll set the password screen up.
4. After it automates the install it'll lock the files and delete itself.

Though the disk addition might be a problem as stated. I wonder if there would be a way for it to automatically hide itself even from disk menus. It's definitely not 100% secure but it's atleast worth a try if I'm able to do something like that.