Advertisement
Adohk

secure.src

Aug 25th, 2019
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. //command: chmod
  2. if params.len < 2 or (params.len == 3 and params[0] != "-R") then exit("Usage: secure [-R(recurse)] [+/-] [path]")
  3.  
  4. user = active_user
  5. permissions = params[0]
  6. pathFile = params[1]
  7. isRecursive = 0
  8.  
  9. if params.len == 3 then
  10.     permissions = params[1]
  11.     pathFile = params[2]
  12.     isRecursive = 1
  13. end if
  14.  
  15. file = get_shell.host_computer.File(pathFile)
  16. if file == null then exit("secure: can't find " + pathFile)
  17. outputMod = ""
  18. if permissions == "+" then
  19.   outputMod = file.chmod("o+wrx", isRecursive)
  20.   outputMod = file.chmod("g+wrx", isRecursive)
  21.   outputMod = file.chmod("u+wrx", isRecursive)
  22. else if permissions == "-" then
  23.   outputMod = file.chmod("o-wrx", isRecursive)
  24.   outputMod = file.chmod("g-wrx", isRecursive)
  25.   outputMod = file.chmod("u-wrx", isRecursive)
  26. end if
  27.  
  28. outputOwner = file.set_owner(user, isRecursive)
  29. outputGroup = file.set_group(user, isRecursive)
  30. output = "Mod: " + outputMod + "Own: " + outputOwner + "Grp: " + outputGroup
  31. if outputMod and outputOwner and outputGroup then print(output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement