X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Futil.lua;h=06a889cfc8115734656bb86d793fa4530d15bade;hb=b2eceb0bccff967bd371cd266148e7cac5eae439;hp=0e7334be87dc769c943ab5e464c52018c6bb928c;hpb=1e1a706db5040d94ec5fd98a1fbf3563637b6c67;p=oweals%2Fluci.git diff --git a/modules/luci-base/luasrc/util.lua b/modules/luci-base/luasrc/util.lua index 0e7334be8..06a889cfc 100644 --- a/modules/luci-base/luasrc/util.lua +++ b/modules/luci-base/luasrc/util.lua @@ -164,6 +164,10 @@ function striptags(value) return value and tparser.striptags(tostring(value)) end +function shellquote(value) + return string.format("'%s'", string.gsub(value or "", "'", "'\\''")) +end + -- for bash, ash and similar shells single-quoted strings are taken -- literally except for single quotes (which terminate the string) -- (and the exception noted below for dash (-) at the start of a @@ -652,10 +656,11 @@ end function checklib(fullpathexe, wantedlib) local fs = require "nixio.fs" local haveldd = fs.access('/usr/bin/ldd') - if not haveldd then + local haveexe = fs.access(fullpathexe) + if not haveldd or not haveexe then return false end - local libs = exec("/usr/bin/ldd " .. fullpathexe) + local libs = exec(string.format("/usr/bin/ldd %s", shellquote(fullpathexe))) if not libs then return false end