commit 2a712a3: [Minor] Allow to ask password from terminal

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Nov 30 11:56:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-11-30 11:50:27 +0000
URL: https://github.com/rspamd/rspamd/commit/2a712a329f217418b5393764d644362164ef0ca5 (HEAD -> master)

[Minor] Allow to ask password from terminal

---
 lualib/rspamadm/clickhouse.lua | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lualib/rspamadm/clickhouse.lua b/lualib/rspamadm/clickhouse.lua
index f8f339654..d1bbbef1a 100644
--- a/lualib/rspamadm/clickhouse.lua
+++ b/lualib/rspamadm/clickhouse.lua
@@ -38,9 +38,14 @@ parser:option '-d --database'
 parser:flag '--no-ssl-verify'
       :description 'Disable SSL verification'
       :argname('no_ssl_verify')
-parser:option '-p --password'
-      :description 'Password to use for Clickhouse'
-      :argname('password')
+parser:mutex(
+    parser:option '-p --password'
+          :description 'Password to use for Clickhouse'
+          :argname('password'),
+    parser:flag '-a --ask-password'
+          :description 'Ask password from the terminal'
+          :argname('ask_password')
+)
 parser:option '-s --server'
       :description 'Address[:port] to connect to Clickhouse with'
       :argname('server')
@@ -228,6 +233,13 @@ local function handler(args)
   load_config(cmd_opts.config_file)
   local cfg_opts = rspamd_config:get_all_opt('clickhouse')
 
+  if cmd_opts.ask_password then
+    local rspamd_util = require "rspamd_util"
+
+    io.write('Password: ')
+    cmd_opts.password = rspamd_util.readpassphrase()
+  end
+
   local function override_settings(params)
     for _, which in ipairs(params) do
       if cmd_opts[which] == nil then


More information about the Commits mailing list