commit d7c3fa7: [Minor] Add public flag to the groups

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Aug 30 18:42:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-30 18:36:40 +0100
URL: https://github.com/rspamd/rspamd/commit/d7c3fa7fe56623e0d8a339a9b43c353e01676a90

[Minor] Add public flag to the groups

---
 src/libserver/cfg_file.h |  1 +
 src/libserver/cfg_rcl.c  | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 1fd56441c..9573b776a 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -109,6 +109,7 @@ enum rspamd_symbol_group_flags {
 	RSPAMD_SYMBOL_GROUP_DISABLED = (1 << 0),
 	RSPAMD_SYMBOL_GROUP_ONE_SHOT = (1 << 1),
 	RSPAMD_SYMBOL_GROUP_UNGROUPED = (1 << 2),
+	RSPAMD_SYMBOL_GROUP_PUBLIC = (1 << 3),
 };
 
 /**
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 5a10a6c3e..d224b4029 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -389,6 +389,36 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
 		}
 	}
 
+	if ((elt = ucl_object_lookup (obj, "public")) != NULL) {
+		if (ucl_object_type (elt) != UCL_BOOLEAN) {
+			g_set_error (err,
+					CFG_RCL_ERROR,
+					EINVAL,
+					"public attribute is not boolean for symbol: '%s'",
+					key);
+
+			return FALSE;
+		}
+		if (ucl_object_toboolean (elt)) {
+			gr->flags |= RSPAMD_SYMBOL_GROUP_PUBLIC;
+		}
+	}
+
+	if ((elt = ucl_object_lookup (obj, "private")) != NULL) {
+		if (ucl_object_type (elt) != UCL_BOOLEAN) {
+			g_set_error (err,
+					CFG_RCL_ERROR,
+					EINVAL,
+					"private attribute is not boolean for symbol: '%s'",
+					key);
+
+			return FALSE;
+		}
+		if (!ucl_object_toboolean (elt)) {
+			gr->flags |= RSPAMD_SYMBOL_GROUP_PUBLIC;
+		}
+	}
+
 	elt = ucl_object_lookup (obj, "description");
 	if (elt) {
 		description = ucl_object_tostring (elt);


More information about the Commits mailing list