Posted 08 May 2013 - 10:00 AM
Hello!
im making a new update for AdvLock… and im trying to prevent editing startup files or boot files… but
would i be able to NOT prevent the way of "running" the files? like
right now when i type "edit startup" it says:
edit:50: AdvLock: You do not have access to edit this file!
but when i type in "startup" this is happening, too ( which i dont want)
edit:50: AdvLock: You do not have access to edit this file
could someone tell me how to check if the only argument for opening a file is "read" or if its "run"
Thanks in Advance.
code:
im making a new update for AdvLock… and im trying to prevent editing startup files or boot files… but
would i be able to NOT prevent the way of "running" the files? like
right now when i type "edit startup" it says:
edit:50: AdvLock: You do not have access to edit this file!
but when i type in "startup" this is happening, too ( which i dont want)
edit:50: AdvLock: You do not have access to edit this file
could someone tell me how to check if the only argument for opening a file is "read" or if its "run"
Thanks in Advance.
code:
Spoiler
Pastebin:
function securePaths()
del = 0
local lockedFiles = {"startup"}
local oldFsDelete = fs.delete
fs.delete = function(...)
local tArg = {...}
if not fs.isLocked then
return oldFsDelete(unpack(tArg))
end
for lockedFile = 1, #lockedFiles do
if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
error("AdvLock: You do not have access to delete this file!", 3)
elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then
error("AdvLock: You do not have access to delete this folder!", 3)
else
del = del + 1
end
end
if del == #lockedFiles then
del = 0
return oldFsDelete(unpack(tArg))
end
end
del = 0
local oldFsOpen = fs.open
fs.open = function(...)
local tArg = {...}
if not fs.isLocked then
return oldFsOpen(unpack(tArg))
end
for lockedFile = 1, #lockedFiles do
if string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and not fs.isDir(tArg[1]) then
error("AdvLock: You do not have access to edit this file!", 3)
elseif string.lower(tArg[1]) == string.lower(lockedFiles[lockedFile]) and fs.isDir(tArg[1]) then
error("AdvLock: You do not have access to edit this folder!", 3)
else
del = del + 1
end
end
if del == #lockedFiles then
del = 0
return oldFsOpen(unpack(tArg))
end
end
end