Skip to content
Snippets Groups Projects
  • Vladimír Čunát's avatar
    b7629c55
    daemon/lua: get rid of __engine symbol in lua · b7629c55
    Vladimír Čunát authored
    In particular this gets rid of last light user data inside kresd.
    
    It was still causing problems on some systems, for example Debian Sid.
    The error was the same: "bad light userdata pointer" from luajit,
    but note that the problem can still be triggered by lua libraries,
    e.g. cqueues.
    Verified
    b7629c55
    History
    daemon/lua: get rid of __engine symbol in lua
    Vladimír Čunát authored
    In particular this gets rid of last light user data inside kresd.
    
    It was still causing problems on some systems, for example Debian Sid.
    The error was the same: "bad light userdata pointer" from luajit,
    but note that the problem can still be triggered by lua libraries,
    e.g. cqueues.
.luacheckrc 1.55 KiB
-- SPDX-License-Identifier: GPL-3.0-or-later
std = 'luajit'
new_read_globals = {
	'cache',
	'event',
	'help',
	'_hint_root_file',
	'hostname',
	'map',
	'modules',
	'net',
	'package_version',
	'quit',
	'resolve',
	'ta_update',
	'fromjson',
	'todname',
	'tojson',
	'user',
	'verbose',
	'worker',
	-- Sandbox declarations
	'kB',
	'MB',
	'GB',
	'sec',
	'second',
	'minute',
	'min',
	'hour',
	'day',
	'panic',
	'warn',
	'log',
	'mode',
	'reorder_RR',
	'option',
	'env',
	'kres',
	'libknot_SONAME',
	'libzscanner_SONAME',
	'table_print',
	'_ENV',
}

new_globals = {
	-- Modules are allowed to be set and accessed from global namespace
	'policy',
	'view',
	'stats',
	'http',
	'trust_anchors',
	'bogus_log',
}

-- Luacheck < 0.18 doesn't support new_read_globals
for _, v in ipairs(new_read_globals) do
	table.insert(new_globals, v)
end

-- Ignore test files
exclude_files = {
	'modules/policy/lua-aho-corasick', -- Vendored
	'tests/config/tapered',
}

-- Ignore some pedantic checks
ignore = {
	'4.1/err', -- Shadowing err
	'4.1/.',   -- Shadowing one letter variables
}

-- Sandbox can set global variables
files['**/daemon/lua'].ignore = {'111', '121', '122'}
files['**/daemon/lua/kres-gen.lua'].ignore = {'631'} -- Allow overly long lines
-- Tests and scripts can use global variables
files['scripts'].ignore = {'111', '112', '113'}
files['tests'].ignore = {'111', '112', '113'}
files['**/utils/upgrade'].ignore = {'111', '112', '113'}
files['**/modules/**/*.test.lua'].ignore = {'111', '112', '113', '121', '122'}
files['**/daemon/**/*.test.lua'].ignore = {'111', '112', '113', '121', '122'}