]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] rspamadm roll -r must not generate new keys 3447/head
authorChristian Roessner <c@roessner.co>
Mon, 20 Jul 2020 12:41:40 +0000 (14:41 +0200)
committerChristian Roessner <c@roessner.co>
Mon, 20 Jul 2020 12:41:40 +0000 (14:41 +0200)
lualib/rspamadm/vault.lua

index d0b448a8d401829fd715a989ccd4af83751d2072..6414d9273ee6299f814c683381177d43ce40fe94 100644 (file)
@@ -455,30 +455,33 @@ local function roll_handler(opts, domain)
         end, fun.tail(keys))
         os.exit(1)
       end
-      -- OK to process
-      -- Insert keys for each algorithm in pairs <old_key(s)>, <new_key>
-      local sk,pk = genkey({algorithm = alg, bits = keys[1].bits})
-      local selector = string.format('%s-%s', alg,
-          os.date("!%Y%m%d"))
-
-      if selector == keys[1].selector then
-        selector = selector .. '-1'
-      end
-      local nelt = {
-        selector = selector,
-        domain = domain,
-        key = tostring(sk),
-        pubkey = tostring(pk),
-        alg = alg,
-        bits = keys[1].bits,
-        valid_start = os.time(),
-      }
+      -- Do not create new keys, if we only want to remove expired keys
+      if not opts.remove_expired then
+        -- OK to process
+        -- Insert keys for each algorithm in pairs <old_key(s)>, <new_key>
+        local sk,pk = genkey({algorithm = alg, bits = keys[1].bits})
+        local selector = string.format('%s-%s', alg,
+            os.date("!%Y%m%d"))
+
+        if selector == keys[1].selector then
+          selector = selector .. '-1'
+        end
+        local nelt = {
+          selector = selector,
+          domain = domain,
+          key = tostring(sk),
+          pubkey = tostring(pk),
+          alg = alg,
+          bits = keys[1].bits,
+          valid_start = os.time(),
+        }
+
+        if opts.expire then
+          nelt.valid_end = os.time() + opts.expire * 3600 * 24
+        end
 
-      if opts.expire then
-        nelt.valid_end = os.time() + opts.expire * 3600 * 24
+        table.insert(res.selectors, nelt)
       end
-
-      table.insert(res.selectors, nelt)
       for _,k in ipairs(keys) do
         table.insert(res.selectors, k)
       end