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

SS - SecureStart.. Need help

Started by TheWhiteKhan, 20 April 2016 - 11:50 PM
TheWhiteKhan #1
Posted 21 April 2016 - 01:50 AM
Hey guys. I am currently working on a startup called "SecureStart".
I have been researching ways to be able to block disk drives/disks from overriding the current startup file, but sadly have found nothing.
I want to try and keep the code as small as possible. I have heard that it can only be done by editing the files in the computercraft.zip file, but that is something I don't want to do.
I have seen one particular post the shows the code in the zip file so I copied it and rewrote it..
The copied code is under secureStart().
After trying to run this it did not work so I am stuck unless someone knows a cunning way around it.

Here is the code:
Spoiler——————SecureStart 1.1—————–
os.pullEvent = os.pullEventRaw
function secureStart()
for n,sSide in pairs(redstone.getsides()) do
if disk.isPresent(sSide) and disk.hasData(sSide)
then
fs.delete(disk.getMountPath(sSide))
end
end
end
function clearSCR() – Clears screen
term.clear()
term.setCursorPos(1,1)
end
function textColour()
term.setTextColor(colors.yellow)
end
function Pass() – Sets password variable
password = "TheBlackPlaguE2017*"
end
function askPass() – Asks for password
textutils.slowWrite("Please enter the password: ")
end
function receivePass() – Reads for input
username = "TheWhiteKhan"
greet = "Welcome, "
welcome = greet..username
input = read("*")
if input == password then
clearSCR()
term.setTextColor(colors.green)
textutils.slowPrint("Login Successful")
sleep(0.5)
clearSCR()
term.setTextColor(colors.orange)
textutils.slowPrint(welcome)
sleep(0.5)
else
clearSCR()
term.setTextColor(colors.red)
textutils.slowPrint("Login Insuccessful")
sleep(0.5)
clearSCR()
textutils.slowPrint("Shutting down")
sleep(1)
os.shutdown()
end
end

——————PROGRAM BEGINS——————

secureStart()
clearSCR()
textColour()
Pass()
askPass()
receivePass()
clearSCR()
Bomb Bloke #2
Posted 21 April 2016 - 03:09 AM
Without reading it I can tell you that unless you're injecting this into the zip, or implementing it via a resource pack, it's simply not going to execute before the system loads the startup file from disk.

Computers look for external startup files by checking for disk drives in a certain order. Make sure you've got a disk drive of your own in the first place the system looks, and it'll ignore any others. Can't quite recall where that spot is, think it might be the top of the system, I'm sure you can work it out by testing.

As of CC 1.77, the settings API can be used to make a given system ignore external startup files completely.
Anavrins #3
Posted 21 April 2016 - 04:27 AM
It goes in the same order as rs.getSides(), which is {"bottom", "top", "back", "front", "right", "left"}.
That means bottom is the first side that it tries.
TheWhiteKhan #4
Posted 21 April 2016 - 06:50 AM
Cheers! I really appreciate the help. I have decided that I will use the 'set' command and change the settings that way.