-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccessLevel.src
35 lines (29 loc) · 1.03 KB
/
accessLevel.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
toFolder = function(file, folderpath)
while file.path != "/"
file = file.parent
end while
for item in folderpath.split("/")
for itempath in file.get_folders
if itempath.path.split("/")[-1] == item then
file = itempath
break
end if
end for
if file.path.split("/")[-1] != item then return null
end for
return file
end function
accessLevel = function(result)
if typeof(result) == "computer" then return accessLevel(result.File("/"))
if typeof(result) == "shell" then return accessLevel(result.host_computer.File("/"))
if typeof(result) == "file" then
if toFolder(result, "/etc").set_owner("root") == "" then return "root"
for user in toFolder(result, "/home").get_folders
if ["root", "guest"].indexOf(user.path.split("/")[-1]) == null then
if user.has_permission("r") then return "user"
end if
end for
return "guest"
end if
return "unknown"
end function