diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /registry | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'registry')
-rw-r--r-- | registry/registry.c | 18 | ||||
-rw-r--r-- | registry/registry_db.c | 13 |
2 files changed, 15 insertions, 16 deletions
diff --git a/registry/registry.c b/registry/registry.c index cd33e5ca0..3f3c4b274 100644 --- a/registry/registry.c +++ b/registry/registry.c @@ -27,21 +27,19 @@ static inline void registry_unlock(void) { // COOKIES static void registry_set_cookie(struct web_client *w, const char *guid) { - char e_date[100]; - time_t et = now_realtime_sec() + registry.persons_expiration; - struct tm e_tm_buf, *etm = gmtime_r(&et, &e_tm_buf); - strftime(e_date, sizeof(e_date), "%a, %d %b %Y %H:%M:%S %Z", etm); + char rfc7231_expires[RFC7231_MAX_LENGTH]; + rfc7231_datetime(rfc7231_expires, sizeof(rfc7231_expires), now_realtime_sec() + registry.persons_expiration); - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s\r\n", guid, e_date); - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; SameSite=Strict; Expires=%s\r\n", guid, e_date); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s\r\n", guid, rfc7231_expires); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; SameSite=Strict; Expires=%s\r\n", guid, rfc7231_expires); if(registry.enable_cookies_samesite_secure) - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; SameSite=None; Secure\r\n", guid, e_date); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; SameSite=None; Secure\r\n", guid, rfc7231_expires); if(registry.registry_domain && *registry.registry_domain) { - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s\r\n", guid, e_date, registry.registry_domain); - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s; SameSite=Strict\r\n", guid, e_date, registry.registry_domain); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s\r\n", guid, rfc7231_expires, registry.registry_domain); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s; SameSite=Strict\r\n", guid, rfc7231_expires, registry.registry_domain); if(registry.enable_cookies_samesite_secure) - buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s; SameSite=None; Secure\r\n", guid, e_date, registry.registry_domain); + buffer_sprintf(w->response.header, "Set-Cookie: " NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; Domain=%s; SameSite=None; Secure\r\n", guid, rfc7231_expires, registry.registry_domain); } w->response.has_cookies = true; diff --git a/registry/registry_db.c b/registry/registry_db.c index a5c3956a5..448ca29d3 100644 --- a/registry/registry_db.c +++ b/registry/registry_db.c @@ -112,7 +112,7 @@ int registry_db_save(void) { if(unlikely(!registry_db_should_be_saved())) return -2; - error_log_limit_unlimited(); + nd_log_limits_unlimited(); char tmp_filename[FILENAME_MAX + 1]; char old_filename[FILENAME_MAX + 1]; @@ -124,7 +124,7 @@ int registry_db_save(void) { FILE *fp = fopen(tmp_filename, "w"); if(!fp) { netdata_log_error("REGISTRY: Cannot create file: %s", tmp_filename); - error_log_limit_reset(); + nd_log_limits_reset(); return -1; } @@ -135,7 +135,7 @@ int registry_db_save(void) { if(bytes1 < 0) { netdata_log_error("REGISTRY: Cannot save registry machines - return value %d", bytes1); fclose(fp); - error_log_limit_reset(); + nd_log_limits_reset(); return bytes1; } netdata_log_debug(D_REGISTRY, "REGISTRY: saving machines took %d bytes", bytes1); @@ -145,7 +145,7 @@ int registry_db_save(void) { if(bytes2 < 0) { netdata_log_error("REGISTRY: Cannot save registry persons - return value %d", bytes2); fclose(fp); - error_log_limit_reset(); + nd_log_limits_reset(); return bytes2; } netdata_log_debug(D_REGISTRY, "REGISTRY: saving persons took %d bytes", bytes2); @@ -204,7 +204,7 @@ int registry_db_save(void) { } // continue operations - error_log_limit_reset(); + nd_log_limits_reset(); return -1; } @@ -222,7 +222,8 @@ size_t registry_db_load(void) { netdata_log_debug(D_REGISTRY, "REGISTRY: loading active db from: '%s'", registry.db_filename); FILE *fp = fopen(registry.db_filename, "r"); if(!fp) { - netdata_log_error("REGISTRY: cannot open registry file: '%s'", registry.db_filename); + if (errno != ENOENT) + netdata_log_error("REGISTRY: cannot open registry file: '%s'", registry.db_filename); return 0; } |