Jump to content




FS - Method to check if "edit startup" is entered instead of "startup"


  • You cannot reply to this topic
5 replies to this topic

#1 Goof

  • Members
  • 751 posts

Posted 08 May 2013 - 09: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:
Spoiler


#2 digpoe

  • Members
  • 92 posts

Posted 08 May 2013 - 09:06 AM

I've not read your code, so I don't know if you read the terminal commands, but if you do:

[code]
local blockedFiles = {"startup", "reboot"} --reboot is used as example so you can block more than one file from being edited.
for _, v in ipairs(blockedFiles) do
if input:find("edit "..v) then
print("You can't modify the "..v.." file!")
end
end

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 May 2013 - 09:13 AM

I would suggest to changing the function override for fs.open so that if they are attempting to read it, it's allowed, but writing and deleting is denied
fs.open = function(path, mode)
  if mode == 'r' then
    -- allow open, they are trying to read it
  else
    -- reject
  end
end


#4 digpoe

  • Members
  • 92 posts

Posted 08 May 2013 - 09:14 AM

View Posttheoriginalbit, on 08 May 2013 - 09:13 AM, said:

I would suggest to changing the function override for fs.open so that if they are attempting to read it, it's allowed, but writing and deleting is denied
fs.open = function(path, mode)
  if mode == 'r' then
	-- allow open, they are trying to read it
  else
	-- reject
  end
end

But that means you can't modify any kind of file?

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 08 May 2013 - 09:23 AM

View Postdigpoe, on 08 May 2013 - 09:14 AM, said:

But that means you can't modify any kind of file?
Well keeping OP original logic in there, no, it will allow it if it's not locked. the code I suggested is just some additional logic that would allow the program to be run, but not edited, if it is locked.

#6 Goof

  • Members
  • 751 posts

Posted 08 May 2013 - 09:24 AM

View Postdigpoe, on 08 May 2013 - 09:14 AM, said:

View Posttheoriginalbit, on 08 May 2013 - 09:13 AM, said:

I would suggest to changing the function override for fs.open so that if they are attempting to read it, it's allowed, but writing and deleting is denied
fs.open = function(path, mode)
  if mode == 'r' then
	-- allow open, they are trying to read it
  else
	-- reject
  end
end

But that means you can't modify any kind of file?
Yes.. and thats exactly what i wanted... :D


Thanks everyone :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users