SHOW:
|
|
- or go back to the newest paste.
1 | open = fs.open | |
2 | --Checks for program in ./su | |
3 | rBCKP = os.reboot | |
4 | function os.reboot() | |
5 | os.reboot = rBCKP | |
6 | fs.delete("/.tempsu") | |
7 | File = fs.open("/.tempsu","a") | |
8 | File.close() | |
9 | os.reboot() | |
10 | - | if string.find(Cont,progname) then |
10 | + | end |
11 | ||
12 | function chkSU(progname) | |
13 | fs.open = open | |
14 | if fs.exists("/.su") then | |
15 | SU = fs.open("/.su","r") | |
16 | TSU = fs.open("/.tempsu","r") | |
17 | TSUA = TSU.readAll() | |
18 | Cont = SU.readAll() | |
19 | TSU.close() | |
20 | SU.close() | |
21 | if fs.exists(progname) then | |
22 | A = ("/??"..progname.."/??") | |
23 | - | SU.write(progname) |
23 | + | if string.find(Cont,A) or string.find(TSUA,A) then |
24 | return true | |
25 | else | |
26 | return false | |
27 | - | function tempSU() |
27 | + | |
28 | else | |
29 | print("Program Not Found In System") | |
30 | end | |
31 | end | |
32 | end | |
33 | --Adds Program to .su | |
34 | local function addRoot(progname) | |
35 | SU = fs.open("/.su","a") | |
36 | SU.writeLine("/??"..progname.."/??") | |
37 | SU.close() | |
38 | end | |
39 | - | local evnt, key, held = os.pullEvent("key") |
39 | + | |
40 | - | if key == 21 then |
40 | + | local function tempSU(progname) |
41 | local TempFile = fs.open("/.tempsu","a") | |
42 | TempFile.writeLine("/??"..progname.."/??") | |
43 | - | elseif key == 49 then |
43 | + | TempFile.close() |
44 | end | |
45 | - | elseif key == 20 then |
45 | + | |
46 | --or not to run root functions | |
47 | function PromptUser(progname) | |
48 | term.setBackgroundColor(colors.white) | |
49 | term.setTextColor(colors.black) | |
50 | term.clear() | |
51 | term.setCursorPos(1,1) | |
52 | print(progname.."is trying to use root functions.") | |
53 | print("Allow "..progname.." root access?") | |
54 | print("Enter Y (yes) N (no) or T (temproot)") | |
55 | local ans = read() | |
56 | if ans == "Y" then | |
57 | --ALLOW ROOT ACCESS PERMANANTLY | |
58 | addRoot(progname) | |
59 | term.setBackgroundColor(colors.black) | |
60 | - | return "Root Already Gained" |
60 | + | |
61 | term.clear() | |
62 | - | PromptUser(A) |
62 | + | |
63 | return true | |
64 | elseif ans == "N" then | |
65 | --DENY ROOT ACCESS UNTIL REQUESTED AGAIN | |
66 | term.setBackgroundColor(colors.black) | |
67 | term.setTextColor(colors.white) | |
68 | term.clear() | |
69 | term.setCursorPos(1,1) | |
70 | return false | |
71 | elseif ans == "T" then | |
72 | --GIVE ROOT ACCESS FOR THIS BOOT | |
73 | term.setBackgroundColor(colors.black) | |
74 | term.setTextColor(colors.white) | |
75 | term.clear() | |
76 | term.setCursorPos(1,1) | |
77 | tempSU(progname) | |
78 | return true | |
79 | else | |
80 | print("exiting root manager") | |
81 | sleep(1) | |
82 | term.setBackgroundColor(colors.black) | |
83 | term.setTextColor(colors.white) | |
84 | term.clear() | |
85 | term.setCursorPos(1,1) | |
86 | end | |
87 | sleep(0) | |
88 | end | |
89 | --Requests SU on program 'A' | |
90 | function SUReq(A) | |
91 | if chkSU(A) == true then | |
92 | return true | |
93 | else | |
94 | return PromptUser(A) | |
95 | end | |
96 | end |