Merge pull request #22 from JamesClarke7283/master

Fix crash in protected area in drive when user violates area protection and allow "protection_bypass" to bypass ME security.
This commit is contained in:
theFox6 2024-01-17 09:38:57 +01:00 committed by GitHub
commit e00028cc09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 10 deletions

@ -5,6 +5,7 @@ read_globals = {
"dump",
"ItemStack",
"pipeworks",
"unified_inventory",
"PseudoRandom",
"stairsplus",
"intllib",

@ -4,8 +4,6 @@
local me = microexpansion
local substitute_basic_materials = microexpansion.settings.simple_craft == true or not minetest.get_modpath("basic_materials")
local gold_wire_recipe = nil
if minetest.get_modpath("mcl_core") then
gold_wire_recipe = {
{ 2, {

@ -4,9 +4,6 @@ local me = microexpansion
-- custom items that are used by multiple devices
local steel_infused_obsidian_ingot_recipe = nil
local machine_casing_recipe = nil
if minetest.get_modpath("mcl_core") then
steel_infused_obsidian_ingot_recipe = {
{ 2, {

@ -79,14 +79,17 @@ end
function network:get_access_level(player)
local name
local has_bypass = minetest.check_player_privs(player, "protection_bypass")
if not player then
return self.default_access_level
elseif has_bypass then
return me.constants.security.access_levels.full
elseif type(player) == "string" then
name = player
else
name = player:get_player_name()
end
if not self.access then
if not self.access and not has_bypass then
return self.default_access_level
end
return self.access[name] or self.default_access_level

@ -349,13 +349,14 @@ microexpansion.register_node("drive", {
me.send_event(pos,"disconnect")
end,
allow_metadata_inventory_put = function(pos, _, _, stack, player)
local name = player:get_player_name()
local network = me.get_connected_network(pos)
if network then
if network:get_access_level(player) < access_level.interact then
return 0
end
elseif minetest.is_protected(pos, player) then
minetest.record_protection_violation(pos, player)
elseif minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
end
if minetest.get_item_group(stack:get_name(), "microexpansion_cell") == 0 then
@ -384,14 +385,15 @@ microexpansion.register_node("drive", {
me.send_event(pos,"items",{net=network})
end,
allow_metadata_inventory_take = function(pos,_,_,stack, player) --args: pos, listname, index, stack, player
local name = player:get_player_name()
local network = me.get_connected_network(pos)
if network then
write_drive_cells(pos,network)
if network:get_access_level(player) < access_level.interact then
return 0
end
elseif minetest.is_protected(pos, player) then
minetest.record_protection_violation(pos, player)
elseif minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return 0
end
return stack:get_count()