security
This commit is contained in:
parent
9228bcaa42
commit
0dc30ce223
@ -3,4 +3,9 @@ Raspberry Jam Mod for Minetest
|
||||
|
||||
Implements most of Raspberry PI Minecraft API in Minetest.
|
||||
|
||||
Currently requires mod security to be turned off.
|
||||
If you have secure.enable_security = true in minetest.conf, then make sure you have raspberryjammod
|
||||
listed under secure.trusted_mods. Raspberry Jam Mod cannot be rewritten without needing to be trusted,
|
||||
because of the following essential features:
|
||||
- loading tcp/ip socket dynamic library
|
||||
- executing and terminating python interpreter with /py command.
|
||||
|
@ -2,9 +2,9 @@ The MIT License (MIT)
|
||||
|
||||
RaspberryJamMod Copyright (c) 2015 Alexander R. Pruss
|
||||
Lua Copyright (c) 1994–2015 Lua.org, PUC-Rio.
|
||||
luasocket Copyright (c) Diego Nehab (with socket.lua changed by ARP to load x64/x86 as needed)
|
||||
tools.lua adapted from lua-websockets Copyright (c) 2012 Gerhard Lipp (with base64 inactivated)
|
||||
base64.lua Copyright (c) 2014 Mark Rogaski and (C) 2012 Paul Moore (changed by ARP to MIME encoding)
|
||||
luasocket Copyright (c) Diego Nehab (with socket.lua changed by ARP to load x64/x86 as needed, and minetest compatibility)
|
||||
tools.lua adapted from lua-websockets Copyright (c) 2012 Gerhard Lipp (with base64 inactivated and minetest compatibility)
|
||||
base64.lua Copyright (c) 2014 Mark Rogaski and (C) 2012 Paul Moore (changed by ARP to MIME encoding and minetest compatibility)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,3 +1,8 @@
|
||||
if minetest.request_insecure_environment then
|
||||
ie = minetest.request_insecure_environment()
|
||||
else
|
||||
ie = _G
|
||||
end
|
||||
--[[--------------------------------------------------------------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
@ -53,7 +58,7 @@ local Base64 = {}
|
||||
-- Imports
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
require("bit")
|
||||
bit = ie.require("bit")
|
||||
|
||||
local band, bor, lshift, rshift = bit.band, bit.bor, bit.lshift, bit.rshift
|
||||
|
||||
|
@ -3,10 +3,19 @@
|
||||
-- Note: The x-coordinate is reversed in sign between minetest and minecraft,
|
||||
-- and the API compensates for this.
|
||||
|
||||
local source = debug.getinfo(1).source:sub(2)
|
||||
if minetest.request_insecure_environment then
|
||||
ie = minetest.request_insecure_environment()
|
||||
else
|
||||
ie = _G
|
||||
end
|
||||
|
||||
print(ie.package)
|
||||
print(ie.package.path)
|
||||
|
||||
local source = ie.debug.getinfo(1).source:sub(2)
|
||||
-- Detect windows via backslashes in paths
|
||||
local mypath = minetest.get_modpath(minetest.get_current_modname())
|
||||
local is_windows = (nil ~= string.find(package.path..package.cpath..source..mypath, "%\\%?"))
|
||||
local is_windows = (nil ~= string.find(ie.package.path..ie.package.cpath..source..mypath, "%\\%?"))
|
||||
local path_separator
|
||||
if is_windows then
|
||||
path_separator = "\\"
|
||||
@ -17,15 +26,15 @@ mypath = mypath .. path_separator
|
||||
|
||||
local script_window_id = "minetest-rjm-python-script"
|
||||
|
||||
package.path = package.path .. ";" .. mypath .. "?.lua"
|
||||
ie.package.path = ie.package.path .. ";" .. mypath .. "?.lua"
|
||||
if is_windows then
|
||||
package.cpath = package.cpath .. ";" .. mypath .. "?.dll"
|
||||
ie.package.cpath = ie.package.cpath .. ";" .. mypath .. "?.dll"
|
||||
else
|
||||
package.cpath = package.cpath .. ";" .. mypath .. "?.so"
|
||||
ie.package.cpath = ie.package.cpath .. ";" .. mypath .. "?.so"
|
||||
end
|
||||
|
||||
local block = require("block")
|
||||
local socket = require("socket")
|
||||
local block = ie.require("block")
|
||||
local socket = ie.require("socket")
|
||||
|
||||
local block_hits = {}
|
||||
local chat_record = {}
|
||||
@ -38,7 +47,7 @@ max_player_id = 0
|
||||
default_player_id = -1
|
||||
world_immutable = false
|
||||
|
||||
local settings = Settings(mypath .. path_separator .. "settings.conf")
|
||||
local settings = Settings(mypath .. "settings.conf")
|
||||
local update_settings = false
|
||||
python_interpreter = settings:get("python")
|
||||
if python_interpreter == nil then
|
||||
@ -75,8 +84,8 @@ server:settimeout(0)
|
||||
local ws_server = nil
|
||||
|
||||
if ws then
|
||||
tools = require("tools")
|
||||
base64 = require("base64")
|
||||
tools = ie.require("tools")
|
||||
base64 = ie.require("base64")
|
||||
ws_server = socket.bind(remote_address, 14711)
|
||||
ws_server:setoption('tcp-nodelay',true)
|
||||
ws_server:settimeout(0)
|
||||
@ -491,13 +500,13 @@ function background_launch(window_identifier, cmd)
|
||||
if not is_windows then return false end
|
||||
local cmdline = 'start "' .. window_identifier .. '" /MIN ' .. cmd
|
||||
minetest.log("action", "launching ["..cmdline.."]")
|
||||
os.execute(cmdline)
|
||||
ie.os.execute(cmdline)
|
||||
end
|
||||
|
||||
function kill(window_identifier)
|
||||
-- TODO: non-Windows
|
||||
minetest.log('taskkill /F /FI "WINDOWTITLE eq ' .. window_identifier .. '"')
|
||||
os.execute('taskkill /F /FI "WINDOWTITLE eq ' .. window_identifier .. '"')
|
||||
ie.os.execute('taskkill /F /FI "WINDOWTITLE eq ' .. window_identifier .. '"')
|
||||
end
|
||||
|
||||
function safe_handle_command(source,line)
|
||||
|
@ -1,3 +1,8 @@
|
||||
if minetest.request_insecure_environment then
|
||||
ie = minetest.request_insecure_environment()
|
||||
else
|
||||
ie = _G
|
||||
end
|
||||
-----------------------------------------------------------------------------
|
||||
-- LuaSocket helper module
|
||||
-- Author: Diego Nehab
|
||||
@ -8,15 +13,15 @@
|
||||
-- Declare module and import dependencies
|
||||
-----------------------------------------------------------------------------
|
||||
local base = _G
|
||||
local string = require("string")
|
||||
local math = require("math")
|
||||
local string = ie.require("string")
|
||||
local math = ie.require("math")
|
||||
local socket
|
||||
local status,err = pcall(function() socket = require("socket.core") end)
|
||||
local status,err = pcall(function() socket = ie.require("socket.core") end)
|
||||
if not status then
|
||||
socket = require("socket.cx64")
|
||||
socket = ie.require("socket.cx64")
|
||||
end
|
||||
|
||||
module("socket")
|
||||
ie.module("socket")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Exported auxiliar functions
|
||||
|
@ -1,4 +1,10 @@
|
||||
local bit = require 'bit'
|
||||
if minetest.request_insecure_environment then
|
||||
ie = minetest.request_insecure_environment()
|
||||
else
|
||||
ie = _G
|
||||
end
|
||||
|
||||
local bit = ie.require 'bit'
|
||||
local rol = bit.rol
|
||||
local bxor = bit.bxor
|
||||
local bor = bit.bor
|
||||
|
Loading…
x
Reference in New Issue
Block a user