Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open = fs.open
- --Checks for program in ./su
- function chkSU(progname)
- fs.open = open
- if fs.exists("/.su") then
- SU = fs.open("/.su","r")
- Cont = SU.readAll()
- SU.close()
- if fs.exists(progname) then
- if string.find(Cont,progname) then
- return true
- else
- return false
- end
- else
- print("Program Not Found In System")
- end
- end
- end
- --Adds Program to .su
- local function addRoot(progname)
- SU = fs.open("/.su","a")
- SU.write(progname)
- SU.close()
- end
- --Adds Program to .tempSU
- function tempSU()
- end
- --Prompts the user for input on whether
- --or not to run root functions
- function PromptUser(progname)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print(progname.."is trying to use root functions.")
- print("Allow "..progname.." root access?")
- local evnt, key, held = os.pullEvent("key")
- if key == 21 then
- --ALLOW ROOT ACCESS PERMANANTLY
- addRoot(progname)
- elseif key == 49 then
- --DENY ROOT ACCESS UNTIL REQUESTED AGAIN
- elseif key == 20 then
- --GIVE ROOT ACCESS FOR THIS BOOT
- else
- print("exiting root manager")
- sleep(1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- end
- sleep(0)
- end
- --Requests SU on program 'A'
- function SUReq(A)
- if chkSU(A) == true then
- return "Root Already Gained"
- else
- PromptUser(A)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment