Skip to content

Commit 2ffad34

Browse files
authored
Create accessLevel.src
1 parent 31005d3 commit 2ffad34

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Diff for: tools/accessLevel.src

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
toFolder = function(file, folderpath)
2+
while file.path != "/"
3+
file = file.parent
4+
end while
5+
6+
for item in folderpath.split("/")
7+
for itempath in file.get_folders
8+
if itempath.path.split("/")[-1] == item then
9+
file = itempath
10+
break
11+
end if
12+
end for
13+
if file.path.split("/")[-1] != item then return null
14+
end for
15+
16+
return file
17+
end function
18+
19+
20+
21+
accessLevel = function(result)
22+
if typeof(result) == "computer" then return accessLevel(result.File("/"))
23+
if typeof(result) == "shell" then return accessLevel(result.host_computer.File("/"))
24+
if typeof(result) == "file" then
25+
if toFolder(result, "/etc").set_owner("root") == "" then return "root"
26+
for user in toFolder(result, "/home").get_folders
27+
if ["root", "guest"].indexOf(user.path.split("/")[-1]) == null then
28+
if user.has_permission("r") then return "user"
29+
end if
30+
end for
31+
return "guest"
32+
end if
33+
34+
return "unknown"
35+
end function

0 commit comments

Comments
 (0)