diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-03-25 22:15:08 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-03-25 22:15:08 +0000 |
commit | 7ffbc4a042b46a0bbd236c6807badf84b54fc8a6 (patch) | |
tree | 9fe4e5533ace6444aaa875b6fd48a1a1692a5e05 /Build | |
parent | 67a0d74b3ba80ada1c0ae1e1b3fc523bd0136699 (diff) |
sync (runscript.tlu)
git-svn-id: svn://tug.org/texlive/trunk@47116 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-x | Build/source/texk/texlive/w32_wrapper/runscript.tlu | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/Build/source/texk/texlive/w32_wrapper/runscript.tlu b/Build/source/texk/texlive/w32_wrapper/runscript.tlu index 983e0081844..77873abd39d 100755 --- a/Build/source/texk/texlive/w32_wrapper/runscript.tlu +++ b/Build/source/texk/texlive/w32_wrapper/runscript.tlu @@ -1,7 +1,7 @@ -local svnrevision = string.match("$Revision: 46914 $", "%d+") or "0" -local svndate = string.match("$Date: 2018-03-10 04:48:22 +0100 (Sat, 10 Mar 2018) $", "[-%d]+") or "2009-12-04" +local svnrevision = string.match("$Revision: 46945 $", "%d+") or "0" +local svndate = string.match("$Date: 2018-03-13 14:42:02 +0900 (火, 13 3 2018) $", "[-%d]+") or "2009-12-04" local bannerstr = "runscript wrapper utility (rev. " .. svnrevision .. ", " .. svndate .. ")\n" .. "usage: runscript script-name [arguments]\n" .. @@ -262,6 +262,8 @@ local docstr = [[ 2017/05/06 - introduce sys_user_progs, make checks for updmap/fmtutil use sys_user_progs instead, add kanji-config-updmap + 2018/03/12 + - introduce a new function gettexmfdist() for security. ]] -- HELPER SUBROUTINES -- @@ -386,6 +388,44 @@ local function mkdir_plus(dir) end end +-- +-- return the TEXMFDIST directory in TeX Live +-- +local function gettexmfdist() + local ffi = require("ffi") + ffi.cdef[[ + typedef void* HANDLE; + typedef char* LPCSTR; + int GetModuleFileNameA(HANDLE h, LPCSTR l, int i); + HANDLE GetModuleHandleA(const char *a); + ]] + local buffer = ffi.new("char[?]", 512) + local runscripthandle = ffi.C.GetModuleHandleA("runscript.dll") + if runscripthandle == nil then + return nil + end + local err = ffi.C.GetModuleFileNameA(runscripthandle, buffer, 256) + if err == 0 then + return nil + end + local str = ffi.string(buffer) + str = string.gsub(str, "\\","/") + str = string.reverse(str) + local a, b +-- remove /runscript.dll + a, b = string.find(str, '/', 1, true) + str = string.sub(str,a+1) +-- remove /win32 + a, b = string.find(str, '/', 1, true) + str = string.sub(str,a+1) +-- remove /bin + a, b = string.find(str, '/', 1, true) + str = string.sub(str,a+1) + str = string.reverse(str) + str = str .. '/texmf-dist' + return str +end + -- MAIN_CHUNK -- encapsulated in a function for more robust execution with pcall local function MAIN_CHUNK() @@ -472,7 +512,12 @@ kpse.set_program_name(lua_binary, progname) -- various dir-vars local TEXDIR = kpse.var_value('SELFAUTOPARENT') -local TEXMFDIST = kpse.var_value('TEXMFDIST') +-- local TEXMFDIST = kpse.var_value('TEXMFDIST') +-- use a new function to obtain TEXMFDIST +local TEXMFDIST = gettexmfdist() +if TEXMFDIST == nil then + TEXMFDIST = kpse.var_value('TEXMFDIST') +end local BINDIR = kpse.var_value('SELFAUTOLOC') local PATH = os.getenv('PATH') or '' |