Guest User

AdvLock - New security

a guest
May 8th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. function securePaths()
  2.     del = 0
  3.     local lockedFiles = {"startup", ".advLock"}
  4.     local oldFsDelete = fs.delete
  5.     fs.delete = function(...)
  6.         local tArg = {...}
  7.        
  8.  
  9.         if not fs.isLocked then
  10.             return oldFsDelete(unpack(tArg))
  11.         end
  12.         for lockedFile = 1, #lockedFiles do
  13.             if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
  14.                 error("AdvLock: You do not have access to delete this file!", 3)
  15.             elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then   
  16.                 error("AdvLock: You do not have access to delete this folder!", 3)
  17.             else
  18.                 del = del + 1
  19.             end
  20.         end
  21.         if del == #lockedFiles then
  22.             del = 0
  23.             return oldFsDelete(unpack(tArg))
  24.         end
  25.     end
  26.     del = 0
  27.     local oldFsOpen = fs.open
  28.     fs.open = function(...)
  29.         local tArg = {...}
  30.        
  31.  
  32.         if not fs.isLocked then
  33.             return oldFsOpen(unpack(tArg))
  34.         end
  35.         for lockedFile = 1, #lockedFiles do
  36.             if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
  37.                 error("AdvLock: You do not have access to edit this file!", 3)
  38.             elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then   
  39.                 error("AdvLock: You do not have access to edit this folder!", 3)
  40.             else
  41.                 del = del + 1
  42.             end
  43.         end
  44.         if del == #lockedFiles then
  45.             del = 0
  46.             return oldFsOpen(unpack(tArg))
  47.         end
  48.     end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment