Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-3674

Bug in ts_lua plugin for adding package path

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 6.0.0
    • Lua, Plugins
    • None

    Description

      Specifically the following situation will make the server fail to restart

      – /tmp/global_lua.lua , used in plugin.config
      ts.add_package_path('/tmp/lib/?.lua')
      local g_config = require "g_config"

      function send_response()
      ts.client_response.header['g_Rhost'] = ts.ctx['rhost']
      ts.client_response.header['g_config'] = g_config.name
      return 0
      end

      function do_global_read_request()
      local req_host = ts.client_request.header.Host
      ts.ctx['rhost'] = string.reverse(req_host)
      ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
      return 0
      end

      – /tmp/lib/g_config.lua
      local g_config = {}
      g_config.name = 'xxx'
      return g_config

      – /tmp/remap_lua.lua , used in remap.config
      ts.add_package_path('/tmp/lib/?.lua')
      local r_config = require "r_config"

      function send_response()
      ts.client_response.header['r_Rhost'] = ts.ctx['rhost']
      ts.client_response.header['r_config'] = r_config.name
      return 0
      end

      function do_remap()
      local req_host = ts.client_request.header.Host
      ts.ctx['rhost'] = string.reverse(req_host)
      ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
      return 0
      end

      – /tmp/lib/r_config.lua
      local r_config = {}
      r_config.name = 'yyy'
      return r_config

      That's because of a bug in the code for adding package path. Providing a fix soon.

      Attachments

        Activity

          People

            kichan Shu Kit Francis Chan
            kichan Shu Kit Francis Chan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment