From: Alexander Moisseev Date: Fri, 9 Mar 2018 16:36:16 +0000 (+0300) Subject: [Minor] configwizard: minor fixes X-Git-Tag: 1.7.0~22^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F2064%2Fhead;p=rspamd.git [Minor] configwizard: minor fixes - Fix prompt - Remove the trailing slash of a pathname, if present --- diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua index 24a0dbfc5..d42f4c3f3 100644 --- a/lualib/rspamadm/configwizard.lua +++ b/lualib/rspamadm/configwizard.lua @@ -220,6 +220,12 @@ local function setup_redis(cfg, changes) end local function setup_dkim_signing(cfg, changes) + -- Remove the trailing slash of a pathname, if present. + local function remove_trailing_slash(path) + if string.sub(path, -1) ~= "/" then return path end + return string.sub(path, 1, string.len(path) - 1) + end + local domains = {} local has_domains = false @@ -227,7 +233,7 @@ local function setup_dkim_signing(cfg, changes) local prompt = string.format("Enter output directory for the keys [default: %s]: ", highlight(dkim_keys_dir)) - dkim_keys_dir = readline_default(prompt, dkim_keys_dir) + dkim_keys_dir = remove_trailing_slash(readline_default(prompt, dkim_keys_dir)) local ret, err = rspamd_util.mkdir(dkim_keys_dir, true) @@ -258,7 +264,7 @@ local function setup_dkim_signing(cfg, changes) end until #domain ~= 0 - local selector = readline_default("Enter domain to sign [default: dkim]: ", 'dkim') + local selector = readline_default("Enter selector [default: dkim]: ", 'dkim') if not selector then selector = 'dkim' end local privkey_file = string.format("%s/%s.%s.key", dkim_keys_dir, domain,