Mercurial > prosody-hg
comparison core/configmanager.lua @ 13918:f0d854c63c8d 13.0
core.configmanager: Fix referencing previous config options #1950
Leaving the proxy metatable resulted in errors later when unexpected
indices were accessed.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 27 Jul 2025 01:08:14 +0200 |
| parents | 1b4f2d010141 |
| children | 6da8b3db84de |
comparison
equal
deleted
inserted
replaced
| 13915:9a69918b5e63 | 13918:f0d854c63c8d |
|---|---|
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 local _G = _G; | 9 local _G = _G; |
| 10 local setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs = | 10 local getmetatable, setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs = |
| 11 setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs; | 11 getmetatable, setmetatable, rawget, rawset, io, os, error, dofile, type, pairs, ipairs; |
| 12 local format, math_max, t_insert = string.format, math.max, table.insert; | 12 local format, math_max, t_insert = string.format, math.max, table.insert; |
| 13 | 13 |
| 14 local envload = require"prosody.util.envload".envload; | 14 local envload = require"prosody.util.envload".envload; |
| 15 local deps = require"prosody.util.dependencies"; | 15 local deps = require"prosody.util.dependencies"; |
| 16 local it = require"prosody.util.iterators"; | 16 local it = require"prosody.util.iterators"; |
| 167 end | 167 end |
| 168 | 168 |
| 169 error("Invalid syntax - missing '=' perhaps?", 2); | 169 error("Invalid syntax - missing '=' perhaps?", 2); |
| 170 end; | 170 end; |
| 171 }; | 171 }; |
| 172 local function is_config_option_proxy(v) | |
| 173 return getmetatable(v) == config_option_proxy_mt; | |
| 174 end | |
| 172 | 175 |
| 173 -- For reading config values out of files. | 176 -- For reading config values out of files. |
| 174 local function filereader(basepath, defaultmode) | 177 local function filereader(basepath, defaultmode) |
| 175 return function(filename, mode) | 178 return function(filename, mode) |
| 176 local f, err = io.open(resolve_relative_path(basepath, filename)); | 179 local f, err = io.open(resolve_relative_path(basepath, filename)); |
| 260 local option_path = host.."/"..k; | 263 local option_path = host.."/"..k; |
| 261 if set_options[option_path] then | 264 if set_options[option_path] then |
| 262 t_insert(warnings, ("%s:%d: Duplicate option '%s'"):format(config_file, get_line_number(config_file), k)); | 265 t_insert(warnings, ("%s:%d: Duplicate option '%s'"):format(config_file, get_line_number(config_file), k)); |
| 263 end | 266 end |
| 264 set_options[option_path] = true; | 267 set_options[option_path] = true; |
| 268 if is_config_option_proxy(v) then | |
| 269 setmetatable(v, nil); | |
| 270 end | |
| 265 set(config_table, env.__currenthost or "*", k, v); | 271 set(config_table, env.__currenthost or "*", k, v); |
| 266 end | 272 end |
| 267 }); | 273 }); |
| 268 | 274 |
| 269 rawset(env, "__currenthost", "*") -- Default is global | 275 rawset(env, "__currenthost", "*") -- Default is global |
