aboutsummaryrefslogtreecommitdiff
path: root/src/collision.cpp
diff options
context:
space:
mode:
authorCraig Davison <craig.davison3@gmail.com>2015-06-14 21:28:51 +0100
committerest31 <MTest31@outlook.com>2015-06-14 23:53:30 +0200
commitecdfbfc8dc1bc62acce0b041b5a3349f886843ec (patch)
tree13b350d8b8b2488c34fb94f56e23a5dbb846c714 /src/collision.cpp
parentee38bcd307e1a2e0e8b010956eff432329f3e8d8 (diff)
downloadminetest-ecdfbfc8dc1bc62acce0b041b5a3349f886843ec.tar.gz
minetest-ecdfbfc8dc1bc62acce0b041b5a3349f886843ec.tar.bz2
minetest-ecdfbfc8dc1bc62acce0b041b5a3349f886843ec.zip
Remove reference to deprecated privilege
Diffstat (limited to 'src/collision.cpp')
0 files changed, 0 insertions, 0 deletions
'#n119'>119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
-- Minetest: builtin/auth.lua

--
-- Authentication handler
--

function minetest.string_to_privs(str, delim)
	assert(type(str) == "string")
	delim = delim or ','
	privs = {}
	for _, priv in pairs(string.split(str, delim)) do
		privs[priv:trim()] = true
	end
	return privs
end

function minetest.privs_to_string(privs, delim)
	assert(type(privs) == "table")
	delim = delim or ','
	list = {}
	for priv, bool in pairs(privs) do
		if bool then
			table.insert(list, priv)
		end
	end
	return table.concat(list, delim)
end

assert(minetest.string_to_privs("a,b").b == true)
assert(minetest.privs_to_string({a=true,b=true}) == "a,b")

minetest.auth_file_path = minetest.get_worldpath().."/auth.txt"
minetest.auth_table = {}

local function read_auth_file()
	local newtable = {}
	local file, errmsg = io.open(minetest.auth_file_path, 'rb')
	if not file then
		minetest.log("info", minetest.auth_file_path.." could not be opened for reading ("..errmsg.."); assuming new world")
		return
	end
	for line in file:lines() do
		if line ~= "" then
			local name, password, privilegestring = string.match(line, "([^:]*):([^:]*):([^:]*)")
			if not name or not password or not privilegestring then
				error("Invalid line in auth.txt: "..dump(line))
			end
			local privileges = minetest.string_to_privs(privilegestring)
			newtable[name] = {password=password, privileges=privileges}
		end
	end
	io.close(file)
	minetest.auth_table = newtable
	minetest.notify_authentication_modified()
end

local function save_auth_file()
	local newtable = {}
	-- Check table for validness before attempting to save
	for name, stuff in pairs(minetest.auth_table) do
		assert(type(name) == "string")
		assert(name ~= "")
		assert(type(stuff) == "table")
		assert(type(stuff.password) == "string")
		assert(type(stuff.privileges) == "table")
	end
	local file, errmsg = io.open(minetest.auth_file_path, 'w+b')
	if not file then