Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ... (existing code)
- local function checkPassphrase(username)
- local storedPassphrase = getPassphrase(username)
- if not storedPassphrase then
- return false -- Passphrase not set
- end
- term.setTextColor(colors.white)
- print("Enter passphrase:")
- local enteredPassphrase = read("*")
- return enteredPassphrase == storedPassphrase
- end
- local function checkPasskeyConfig(disk)
- local passkeyConfigFile = fs.combine(disk, "passkey.config")
- if fs.exists(passkeyConfigFile) then
- local file = fs.open(passkeyConfigFile, "r")
- local storedUsername = file.readLine()
- file.close()
- term.setTextColor(colors.white)
- print("Enter username:")
- local enteredUsername = read()
- if enteredUsername == storedUsername then
- return checkPassphrase(enteredUsername)
- else
- return false -- Incorrect username
- end
- else
- return false -- passkey.config not found
- end
- end
- local function main()
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.green)
- print("Protected by Doggy OS security")
- print("-----------------------------")
- term.setTextColor(colors.white)
- -- Check for passkey.config on /disk2/
- if checkPasskeyConfig("/disk2/") then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.lime)
- print("Access granted on /disk2/. Welcome!")
- os.sleep(2)
- -- Continue with the main OS code for /disk2/
- return
- end
- -- Check for passkey.config on /disk3/
- if checkPasskeyConfig("/disk3/") then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.lime)
- print("Access granted on /disk3/. Welcome!")
- os.sleep(2)
- -- Continue with the main OS code for /disk3/
- return
- end
- -- Continue with the existing code for username entry
- print("Enter username:")
- local enteredUsername = read()
- if checkDisabled(enteredUsername) then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.red)
- print("This user has been disabled due to security reasons.")
- os.sleep(3) -- Display the disabled message for 3 seconds
- print("Contact your administrator for help.")
- os.sleep(2) -- Display the contact administrator message for 2 seconds
- shell.run("/disk/os/lock.lua") -- Run the lock.lua program
- return
- end
- local users = fs.list(USERS_FOLDER)
- if not users or #users == 0 then
- -- No users detected, run the BSOD program
- shell.run(ERROR_FOLDER .. BSOD_PROGRAM)
- elseif checkCredentials(enteredUsername) then
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.lime)
- print("Access granted. Welcome, " .. enteredUsername .. "!")
- os.sleep(2) -- Display the success message for 2 seconds
- -- Your main OS code goes here
- else
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.red)
- print("Access denied.")
- os.sleep(2) -- Display the access denied message for 2 seconds
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement