Disable hashes for charts and alerts if openssl is not available or cloud is disabled (#12071)
* disable hashes for charts and alerts if openssl is not available * create hashes if disable_cloud has not been defined and https has been defined
Emmanuel Vasilakis committed
Feb 8, 2022 at 16:30 UTC
713018281adf353262bac8eb85763448f12635e7
2 files changed
+21
database/sqlite/sqlite_functions.c
+9
@@ -1646,8 +1646,14 @@ int sql_store_chart_hash(
1646
return 1;
1647
}
1648
1649
+/*
1650
+ chart hashes are used for cloud communication.
1651
+ if cloud is disabled or openssl is not available (which will prevent cloud connectivity)
1652
+ skip hash calculations
1653
+*/
1654
void compute_chart_hash(RRDSET *st)
1655
{
1656
+#if !defined DISABLE_CLOUD && defined ENABLE_HTTPS
1657
EVP_MD_CTX *evpctx;
1658
unsigned char hash_value[EVP_MAX_MD_SIZE];
1659
unsigned int hash_len;
@@ -1693,6 +1699,9 @@ void compute_chart_hash(RRDSET *st)
1699
st->module_name,
1700
st->priority,
1701
st->chart_type);
1702
+#else
1703
+ UNUSED(st);
1704
+#endif
1705
return;
1706
}
1707
database/sqlite/sqlite_health.c
+12
@@ -890,11 +890,19 @@ int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg)
890
return 1;
891
}
892
893
+/*
894
+ alert hashes are used for cloud communication.
895
+ if cloud is disabled or openssl is not available (which will prevent cloud connectivity)
896
+ skip hash calculations
897
+*/
898
+#if !defined DISABLE_CLOUD && defined ENABLE_HTTPS
899
#define DIGEST_ALERT_CONFIG_VAL(v) ((v) ? EVP_DigestUpdate(evpctx, (v), strlen((v))) : EVP_DigestUpdate(evpctx, "", 1))
900
+#endif
901
int alert_hash_and_store_config(
902
uuid_t hash_id,
903
struct alert_config *cfg)
904
{
905
+#if !defined DISABLE_CLOUD && defined ENABLE_HTTPS
906
EVP_MD_CTX *evpctx;
907
unsigned char hash_value[EVP_MAX_MD_SIZE];
908
unsigned int hash_len;
@@ -939,6 +947,10 @@ int alert_hash_and_store_config(
947
948
/* store everything, so it can be recreated when not in memory or just a subset ? */
949
(void)sql_store_alert_config_hash( (uuid_t *)&hash_value, cfg);
950
+#else
951
+ UNUSED(hash_id);
952
+ UNUSED(cfg);
953
+#endif
954
955
return 1;
956
}