From: Tobias Ulmer Date: Wed, 15 May 2013 18:03:13 +0000 (+0200) Subject: Add error checking to directory() loops X-Git-Tag: e2factory-2.3.15rc1~500 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=24e6445a636c8077282ecfbc7c161d1a187ebb54;p=e2factory.git Add error checking to directory() loops Signed-off-by: Tobias Ulmer --- diff --git a/generic/plugin.lua b/generic/plugin.lua index e8fb1ba..4a5b22c 100644 --- a/generic/plugin.lua +++ b/generic/plugin.lua @@ -142,7 +142,11 @@ function plugin.load_plugins(dir, ctx) e2lib.logf(4, "loading plugins from: %s", dir) local pfn = {} - for fn in e2lib.directory(dir) do + for fn, re in e2lib.directory(dir) do + if not fn then + return false, e:cat(re) + end + table.insert(pfn, fn) end diff --git a/local/e2-cf.lua b/local/e2-cf.lua index 669afeb..371e20a 100644 --- a/local/e2-cf.lua +++ b/local/e2-cf.lua @@ -104,7 +104,12 @@ local function shadow_config_down(src_res, pathname) return false, err.new("config in %s would be shadowed", cfdir) end - for f in e2lib.directory(cfdir, false, true) do + local re + for f, re in e2lib.directory(cfdir, false, true) do + if not f then + return false, re + end + if e2lib.isdir(e2lib.join(cfdir, f)) then return shadow_config_down(src_res, e2lib.join(pathname, f)) end diff --git a/local/e2build.lua b/local/e2build.lua index 23b87a6..5817254 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -538,7 +538,11 @@ function e2build.unpack_result(info, r, dep, destdir) if not rc then return false, e:cat(re) end - for f in e2lib.directory(".") do + for f, re in e2lib.directory(".") do + if not f then + return false, e:cat(re) + end + rc, re = e2lib.mv(f, destdir) if not rc then return false, e:cat(re) @@ -572,7 +576,11 @@ local function write_build_driver(info, r, destdir) bd=bd..string.format("source %s/env/builtin\n", res.build_config.Tc) bd=bd..string.format("source %s/env/env\n", res.build_config.Tc) local brc_noinit = bd - for x in e2lib.directory(info.root .. "/proj/init") do + for x, re in e2lib.directory(info.root .. "/proj/init") do + if not x then + return false, e:cat(re) + end + if not e2lib.is_backup_file(x) then bd=bd..string.format("source %s/init/%s\n", res.build_config.Tc, x) end @@ -701,7 +709,11 @@ local function sources(info, r, return_flags) local res = info.results[r] local rc, re local e = err.new("installing init files") - for x in e2lib.directory(info.root .. "/proj/init") do + for x, re in e2lib.directory(info.root .. "/proj/init") do + if not x then + return false, e:cat(re) + end + if not e2lib.is_backup_file(x) then local location = string.format("proj/init/%s", x) local abslocation = string.format("%s/%s", info.root, location) @@ -820,7 +832,12 @@ local function deploy(info, r, return_flags) return true end local files = {} - for f in e2lib.directory("result/files") do + local re + for f, re in e2lib.directory("result/files") do + if not f then + return false, re + end + table.insert(files, string.format("files/%s", f)) end table.insert(files, "checksums") diff --git a/local/e2tool.lua b/local/e2tool.lua index 35f016e..f8c5a94 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -903,7 +903,11 @@ end --- gather source paths. local function gather_source_paths(info, basedir, sources) sources = sources or {} - for dir in e2lib.directory(info.root .. "/" .. e2tool.sourcedir(basedir)) do + for dir, re in e2lib.directory(e2lib.join(info.root, e2tool.sourcedir(basedir))) do + if not dir then + return false, re + end + local tmp if basedir then tmp = basedir .. "/" .. dir @@ -977,7 +981,12 @@ local function load_source_config(info) local e = err.new("error loading source configuration") info.sources = {} - for _,src in ipairs(gather_source_paths(info)) do + local sources, re = gather_source_paths(info) + if not sources then + return false, e:cat(re) + end + + for _,src in ipairs(sources) do local list, re local path = e2tool.sourceconfig(src) local types = { "e2source", } @@ -1074,7 +1083,11 @@ end --- gather result paths. local function gather_result_paths(info, basedir, results) results = results or {} - for dir in e2lib.directory(info.root .. "/" .. e2tool.resultdir(basedir)) do + for dir, re in e2lib.directory(e2lib.join(info.root, e2tool.resultdir(basedir))) do + if not dir then + return false, re + end + local tmp if basedir then tmp = basedir .. "/" .. dir @@ -1099,7 +1112,12 @@ local function load_result_config(info) local e = err.new("error loading result configuration") info.results = {} - for _,res in ipairs(gather_result_paths(info)) do + local results, re = gather_result_paths(info) + if not results then + return false, e:cat(re) + end + + for _,res in ipairs(results) do local list, re local path = e2tool.resultconfig(res) local types = { "e2result", } @@ -1860,7 +1878,11 @@ local function projid(info) end -- catch proj/init/* local hc = hash.hash_start() - for f in e2lib.directory(info.root .. "/proj/init") do + for f, re in e2lib.directory(e2lib.join(info.root, "proj/init")) do + if not f then + return false, re + end + if not e2lib.is_backup_file(f) then local location = string.format("proj/init/%s", e2lib.basename(f))