Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorAndrejs Kozlovs <andrejs.kozlovs@zabbix.com>2021-10-08 15:28:00 +0300
committerAndrejs Kozlovs <andrejs.kozlovs@zabbix.com>2021-10-08 15:28:00 +0300
commit515eaffd4bcb328534889571fa89e11d91bb19aa (patch)
tree56b177c06066086b5c93d99901f43e078fe8c198 /src/libs
parent2bff1fbb66b2fa026d159990c1a47d9837689988 (diff)
........S. [ZBX-20006] fixed merge issue, float and password processing
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/zbxaudit/audit.c31
-rw-r--r--src/libs/zbxaudit/audit.h2
-rw-r--r--src/libs/zbxaudit/audit_host.c4
-rw-r--r--src/libs/zbxaudit/audit_httptest.c13
-rw-r--r--src/libs/zbxaudit/audit_httptest.h5
-rw-r--r--src/libs/zbxaudit/audit_item.c14
-rw-r--r--src/libs/zbxdbhigh/host.c7
7 files changed, 54 insertions, 22 deletions
diff --git a/src/libs/zbxaudit/audit.c b/src/libs/zbxaudit/audit.c
index 2c8a2a6353c..920574e5263 100644
--- a/src/libs/zbxaudit/audit.c
+++ b/src/libs/zbxaudit/audit.c
@@ -311,11 +311,16 @@ static int audit_field_default(const char *table_name, const char *field_name, c
if (NULL != table_name && NULL != (table = DBget_table(table_name)) &&
NULL != (field = DBget_field(table, field_name)))
{
-
- if (NULL != value && NULL != field->default_value && 0 == strcmp(value, field->default_value))
+ if (NULL != value && NULL != field->default_value && (0 == strcmp(value, field->default_value) ||
+ (ZBX_TYPE_FLOAT == field->type && SUCCEED == zbx_double_compare(atof(value),
+ atof(field->default_value)))))
+ {
ret = SUCCEED;
+ }
else if ((NULL == value || (ZBX_TYPE_ID == field->type && 0 == id)) && NULL == field->default_value)
+ {
ret = SUCCEED;
+ }
}
return ret;
@@ -343,6 +348,28 @@ void zbx_audit_update_json_append_string(const zbx_uint64_t id, const char *audi
append_str_json(&((*found_audit_entry)->details_json), audit_op, key, value);
}
+void zbx_audit_update_json_append_string_secret(const zbx_uint64_t id, const char *audit_op, const char *key,
+ const char *value, const char *table, const char *field)
+{
+ zbx_audit_entry_t local_audit_entry, **found_audit_entry;
+ zbx_audit_entry_t *local_audit_entry_x = &local_audit_entry;
+
+ if (SUCCEED == audit_field_default(table, field, value, 0))
+ return;
+
+ local_audit_entry.id = id;
+
+ found_audit_entry = (zbx_audit_entry_t**)zbx_hashset_search(&zbx_audit, &(local_audit_entry_x));
+
+ if (NULL == found_audit_entry)
+ {
+ THIS_SHOULD_NEVER_HAPPEN;
+ exit(EXIT_FAILURE);
+ }
+
+ append_str_json(&((*found_audit_entry)->details_json), audit_op, key, ZBX_MACRO_SECRET_MASK);
+}
+
void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audit_op, const char *key,
uint64_t value, const char *table, const char *field)
{
diff --git a/src/libs/zbxaudit/audit.h b/src/libs/zbxaudit/audit.h
index 099e6e361b6..93b128f6643 100644
--- a/src/libs/zbxaudit/audit.h
+++ b/src/libs/zbxaudit/audit.h
@@ -77,6 +77,8 @@ void zbx_audit_init(int audit_mode_set);
void zbx_audit_flush(void);
void zbx_audit_update_json_append_string(const zbx_uint64_t id, const char *audit_op, const char *key,
const char *value, const char *table, const char *field);
+void zbx_audit_update_json_append_string_secret(const zbx_uint64_t id, const char *audit_op, const char *key,
+ const char *value, const char *table, const char *field);
void zbx_audit_update_json_append_uint64(const zbx_uint64_t id, const char *audit_op, const char *key,
uint64_t value, const char *table, const char *field);
void zbx_audit_update_json_append_no_value(const zbx_uint64_t id, const char *audit_op, const char *key);
diff --git a/src/libs/zbxaudit/audit_host.c b/src/libs/zbxaudit/audit_host.c
index 1fd331969f1..c498f369b4d 100644
--- a/src/libs/zbxaudit/audit_host.c
+++ b/src/libs/zbxaudit/audit_host.c
@@ -139,9 +139,9 @@ void zbx_audit_host_update_json_add_tls_and_psk(zbx_uint64_t hostid, int tls_con
AUDIT_TABLE_NAME, "tls_connect");
zbx_audit_update_json_append_int(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_accept", tls_accept,
AUDIT_TABLE_NAME, "tls_accept");
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.psk_identity", tls_psk_identity,
+ zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_psk_identity", tls_psk_identity,
AUDIT_TABLE_NAME, "tls_psk_identity");
- zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.psk", tls_psk, AUDIT_TABLE_NAME,
+ zbx_audit_update_json_append_string(hostid, AUDIT_DETAILS_ACTION_ADD, "host.tls_psk", tls_psk, AUDIT_TABLE_NAME,
"tls_psk");
#undef AUDIT_TABLE_NAME
}
diff --git a/src/libs/zbxaudit/audit_httptest.c b/src/libs/zbxaudit/audit_httptest.c
index f1fa18c0f61..82c109775d6 100644
--- a/src/libs/zbxaudit/audit_httptest.c
+++ b/src/libs/zbxaudit/audit_httptest.c
@@ -54,8 +54,9 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64_t templateid, const char *name,
const char *delay, unsigned char status, const char *agent, unsigned char authentication,
- const char *httpuser, const char *http_proxy, int retries, const char *ssl_cert_file,
- const char *ssl_key_file, int verify_peer, int verify_host, zbx_uint64_t hostid)
+ const char *httpuser, const char *httppassword, const char *http_proxy, int retries,
+ const char *ssl_cert_file, const char *ssl_key_file, const char *ssl_key_password, int verify_peer,
+ int verify_host, zbx_uint64_t hostid)
{
char audit_key_templateid[AUDIT_DETAILS_KEY_LEN], audit_key_name[AUDIT_DETAILS_KEY_LEN],
audit_key_delay[AUDIT_DETAILS_KEY_LEN], audit_key_status[AUDIT_DETAILS_KEY_LEN],
@@ -98,14 +99,14 @@ void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64
ADD_STR(agent, AUDIT_TABLE_NAME, "agent")
ADD_INT(authentication, AUDIT_TABLE_NAME, "authentication")
ADD_STR(httpuser, AUDIT_TABLE_NAME, "http_user")
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.httppassword",
- ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "http_password");
+ zbx_audit_update_json_append_string_secret(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.httppassword",
+ httppassword, AUDIT_TABLE_NAME, "http_password");
ADD_STR(http_proxy, AUDIT_TABLE_NAME, "http_proxy")
ADD_INT(retries, AUDIT_TABLE_NAME, "retries")
ADD_STR(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file")
ADD_STR(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file")
- zbx_audit_update_json_append_string(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.ssl_key_password",
- ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "ssl_key_password");
+ zbx_audit_update_json_append_string_secret(httptestid, AUDIT_DETAILS_ACTION_ADD, "httptest.ssl_key_password",
+ ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
ADD_INT(verify_peer, AUDIT_TABLE_NAME, "verify_peer")
ADD_INT(verify_host, AUDIT_TABLE_NAME, "verify_host")
ADD_UINT64(hostid, AUDIT_TABLE_NAME, "hostid")
diff --git a/src/libs/zbxaudit/audit_httptest.h b/src/libs/zbxaudit/audit_httptest.h
index 79de31a6073..2850da900cd 100644
--- a/src/libs/zbxaudit/audit_httptest.h
+++ b/src/libs/zbxaudit/audit_httptest.h
@@ -29,8 +29,9 @@ void zbx_audit_httptest_create_entry(int audit_action, zbx_uint64_t httptestid,
void zbx_audit_httptest_update_json_add_data(zbx_uint64_t httptestid, zbx_uint64_t templateid, const char *name,
const char *delay, unsigned char status, const char *agent, unsigned char authentication,
- const char *httpuser, const char *http_proxy, int retries, const char *ssl_cert_file,
- const char *ssl_key_file, int verify_peer, int verify_host, zbx_uint64_t hostid);
+ const char *httpuser, const char *httppassword, const char *http_proxy, int retries,
+ const char *ssl_cert_file, const char *ssl_key_file, const char *ssl_key_password, int verify_peer,
+ int verify_host, zbx_uint64_t hostid);
#define PREPARE_AUDIT_HTTPTEST_UPDATE_H(resource, type1) \
void zbx_audit_httptest_update_json_update_##resource(zbx_uint64_t httptestid, type1 resource##_old, \
diff --git a/src/libs/zbxaudit/audit_item.c b/src/libs/zbxaudit/audit_item.c
index 11e55740a02..72e1f51652f 100644
--- a/src/libs/zbxaudit/audit_item.c
+++ b/src/libs/zbxaudit/audit_item.c
@@ -153,8 +153,8 @@ void zbx_audit_item_update_json_add_data(zbx_uint64_t itemid, const zbx_template
ADD_JSON_UI(output_format, AUDIT_TABLE_NAME, "output_format");
ADD_JSON_S(params, AUDIT_TABLE_NAME, "params");
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(password),
- ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "password");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(password),
+ item->password, AUDIT_TABLE_NAME, "password");
ADD_JSON_UI(post_type, AUDIT_TABLE_NAME, "post_type");
ADD_JSON_S(posts, AUDIT_TABLE_NAME, "posts");
@@ -167,8 +167,8 @@ void zbx_audit_item_update_json_add_data(zbx_uint64_t itemid, const zbx_template
ADD_JSON_S(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file");
ADD_JSON_S(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file");
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(ssl_key_password),
- ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "ssl_key_password");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_DETAILS_ACTION_ADD, IT_OR_ITP_OR_DR(ssl_key_password),
+ item->ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
ADD_JSON_UI(status, AUDIT_TABLE_NAME, "status");
ADD_JSON_S(status_codes, AUDIT_TABLE_NAME, "status_codes");
@@ -248,7 +248,7 @@ void zbx_audit_item_update_json_add_lld_data(zbx_uint64_t itemid, const zbx_lld_
ADD_JSON_S(snmp_oid, AUDIT_TABLE_NAME, "snmp_oid");
ADD_JSON_P_UI(authtype, AUDIT_TABLE_NAME, "authtype");
ADD_JSON_S(username, AUDIT_TABLE_NAME, "username");
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(password), ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "password");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_DETAILS_ACTION_ADD, IT(password), item->password, AUDIT_TABLE_NAME, "password");
ADD_JSON_P_S(publickey, AUDIT_TABLE_NAME, "publickey");
ADD_JSON_P_S(privatekey, AUDIT_TABLE_NAME, "privatekey");
ADD_JSON_S(description, AUDIT_TABLE_NAME, "description");
@@ -270,8 +270,8 @@ void zbx_audit_item_update_json_add_lld_data(zbx_uint64_t itemid, const zbx_lld_
ADD_JSON_P_UI(output_format, AUDIT_TABLE_NAME, "output_format");
ADD_JSON_S(ssl_cert_file, AUDIT_TABLE_NAME, "ssl_cert_file");
ADD_JSON_S(ssl_key_file, AUDIT_TABLE_NAME, "ssl_key_file");
- zbx_audit_update_json_append_string(itemid, AUDIT_DETAILS_ACTION_ADD, IT(ssl_key_password),
- ZBX_MACRO_SECRET_MASK, AUDIT_TABLE_NAME, "ssl_key_password");
+ zbx_audit_update_json_append_string_secret(itemid, AUDIT_DETAILS_ACTION_ADD, IT(ssl_key_password),
+ item->ssl_key_password, AUDIT_TABLE_NAME, "ssl_key_password");
ADD_JSON_P_UI(verify_peer, AUDIT_TABLE_NAME, "verify_peer");
ADD_JSON_P_UI(verify_host, AUDIT_TABLE_NAME, "verify_host");
ADD_JSON_P_UI(allow_traps, AUDIT_TABLE_NAME, "allow_traps");
diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
index ba8abd1694f..ba396be88be 100644
--- a/src/libs/zbxdbhigh/host.c
+++ b/src/libs/zbxdbhigh/host.c
@@ -5330,9 +5330,10 @@ static void DBsave_httptests(zbx_uint64_t hostid, const zbx_vector_ptr_t *httpte
zbx_audit_httptest_update_json_add_data(httptest->httptestid, httptest->templateid,
httptest->name, httptest->delay, (int)httptest->status, httptest->agent,
- (int)httptest->authentication, httptest->http_user, httptest->http_proxy,
- httptest->retries, httptest->ssl_cert_file, httptest->ssl_key_file,
- httptest->verify_peer, httptest->verify_host, hostid);
+ (int)httptest->authentication, httptest->http_user, httptest->http_password,
+ httptest->http_proxy, httptest->retries, httptest->ssl_cert_file,
+ httptest->ssl_key_file, httptest->ssl_key_password, httptest->verify_peer,
+ httptest->verify_host, hostid);
for (j = 0; j < httptest->httpsteps.values_num; j++)
{