aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgpcf <gpcf@gpcf.eu>2024-08-11 23:22:36 +0200
committergpcf <gpcf@gpcf.eu>2024-08-11 23:22:36 +0200
commit46fbf89acfe3d182bf497bfa622cd4876d53d7da (patch)
treee700b011492b499d73051187b97efb754e34db8e
parent9d7cec6151c0a9eca2454e9d6c85bc5596c5e946 (diff)
Fix privilege check when using the PC naming toolrelease-2.4.5
This fix prevents malicious modified clients from using the PC tool without the necessary privileges.
-rw-r--r--advtrains_luaautomation/pcnaming.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/advtrains_luaautomation/pcnaming.lua b/advtrains_luaautomation/pcnaming.lua
index 71f4d9a..5624b74 100644
--- a/advtrains_luaautomation/pcnaming.lua
+++ b/advtrains_luaautomation/pcnaming.lua
@@ -22,6 +22,9 @@ function atlatc.pcnaming.resolve_pos(pos, func_name)
error("Invalid position supplied to " .. (func_name or "???")..": " .. dump(pos))
end
+
+local pcrename = {}
+
minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
description = attrans("Passive Component Naming Tool\n\nRight-click to name a passive component."),
groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
@@ -43,6 +46,7 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
minetest.record_protection_violation(pos, pname)
return
end
+
local node = advtrains.ndb.get_node(pos)
local ndef = minetest.registered_nodes[node.name]
if node.name and (
@@ -57,16 +61,17 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
pn=name
end
end
- minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;Set name of component (empty to clear);"..minetest.formspec_escape(pn).."]")
+ pcrename[pname] = pos
+ minetest.show_formspec(pname, "atlatc_naming", "field[pn;Set name of component (empty to clear);"..minetest.formspec_escape(pn).."]")
end
end
end,
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
- local pts=string.match(formname, "^atlatc_naming_(.+)")
- if pts then
- local pos=minetest.string_to_pos(pts)
- if fields.pn then
+ if formname == "atlatc_naming" then
+ local pname = player:get_player_name()
+ local pos=pcrename[pname]
+ if fields.pn and pos then
--first remove all occurences
for name, npos in pairs(atlatc.pcnaming.name_map) do
if vector.equals(npos, pos) then
ef='#n195'>195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306