commit ac183a2: [Minor] Fix signing with `skip_process` flag

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Nov 11 10:28:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-11-11 10:22:01 +0000
URL: https://github.com/rspamd/rspamd/commit/ac183a2c2bc1d74218c9c49e36551728f40ff558 (HEAD -> master)

[Minor] Fix signing with `skip_process` flag

---
 lualib/lua_mime.lua |  4 ----
 src/lua/lua_task.c  | 18 +++++++++++++-----
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index 4e61b4a20..24c02daae 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -515,10 +515,6 @@ end
 -- Adds/removes headers both internal and in the milter reply
 --]]
 exports.modify_headers = function(task, hdr_alterations)
-  if task:has_flag('skip_process') then
-    -- Cannot set flags for skipped (and unprocessed) task
-    return
-  end
   local add = hdr_alterations.add or {}
   local remove = hdr_alterations.remove or {}
 
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index bc9ab8750..48006fa84 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -444,6 +444,7 @@ LUA_FUNCTION_DEF (task, get_headers);
  * remove from the end
  * Order in addition means addition from the top: 0 means the most top header, 1 one after, etc
  * negative order means addtion to the end, e.g. -1 is appending header.
+ * @return {bool} true if header could be modified (always true unless we don't have an unparsed message)
  */
 LUA_FUNCTION_DEF (task, modify_header);
 
@@ -6671,17 +6672,24 @@ lua_task_modify_header (lua_State *L)
 	const gchar *hname = luaL_checkstring (L, 2);
 
 	if (hname && task && lua_type (L, 3) == LUA_TTABLE) {
-		ucl_object_t *mods = ucl_object_lua_import (L, 3);
+		if (task->message) {
+			ucl_object_t *mods = ucl_object_lua_import(L, 3);
+
+			rspamd_message_set_modified_header(task,
+					MESSAGE_FIELD_CHECK (task, raw_headers), hname, mods);
+			ucl_object_unref(mods);
 
-		rspamd_message_set_modified_header (task,
-				MESSAGE_FIELD_CHECK (task, raw_headers), hname, mods);
-		ucl_object_unref (mods);
+			lua_pushboolean (L, true);
+		}
+		else {
+			lua_pushboolean (L, false);
+		}
 	}
 	else {
 		return luaL_error (L, "invalid arguments");
 	}
 
-	return 0;
+	return 1;
 }
 
 static gint


More information about the Commits mailing list