From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 5CB4625245 for ; Tue, 23 Jul 2019 18:32:13 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uYhvfruzucWZ for ; Tue, 23 Jul 2019 18:32:13 -0400 (EDT) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 16BAB24119 for ; Tue, 23 Jul 2019 18:32:12 -0400 (EDT) Received: by mail-lj1-f194.google.com with SMTP id m23so42512713lje.12 for ; Tue, 23 Jul 2019 15:32:12 -0700 (PDT) From: Cyrill Gorcunov Subject: [tarantool-patches] [PATCH 5/5] box/lua/console: Limit lua output for local sessions only Date: Wed, 24 Jul 2019 01:31:13 +0300 Message-Id: <20190723223113.16084-6-gorcunov@gmail.com> In-Reply-To: <20190723223113.16084-1-gorcunov@gmail.com> References: <20190723223113.16084-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tml Cc: Alexander Turenko , Kirill Yukhin , Konstantin Osipov , Cyrill Gorcunov To make full support of lua mode on remote connection we need pass this option to remote server. Also we need to provide a compatibility layer for servers from previous series and thus recode yaml output on client side. This will be done in next patches, for now simply limit the usage of lua output to local sessions only. Part-of #3834 --- src/box/lua/console.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index db57a6d80..b736eaa57 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -129,6 +129,28 @@ local function output_save(fmt, opts) } end +local function output_verify_remote(greeting) + -- + -- FIXME + -- For now we disable operating in Lua output + -- mode for remote connections, simply because + -- we need to extend output processing and pass + -- it into remote peer. Also for old servers which + -- won't support Lua more we will need to provide + -- compatibility layer and decode yaml manually. + -- + -- Thus we require both output settings (per session + -- and by default to be set to yaml). + local d = box.session.storage.console_output + if (d ~= nil and d["fmt"] == "lua") or + (d == nil and ouput_default_handler["fmt"] == "lua") then + local msg1 = "Lua mode is not support right now. " + local msg2 = "Please switch back to yaml output." + return false, msg1 .. msg2 + end + return true, nil +end + local function format(status, ...) local d = box.session.storage.console_output if d == nil then @@ -599,6 +621,14 @@ local function connect(uri, opts) log.verbose(greeting) box.error(box.error.NO_CONNECTION) end + + local ok, res = output_verify_remote(greeting) + if not ok then + connection:close() + pcall(self.on_client_disconnect, self) + error(res) + end + local remote if greeting.protocol == 'Lua console' then remote = wrap_text_socket(connection, u, -- 2.20.1