summaryrefslogtreecommitdiffstats
path: root/registry/registry.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-31 12:58:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-31 12:58:11 +0000
commitf99c4526d94d3e04124c5c48ab4a3da6ca53a458 (patch)
treea2ed8860030cc49f492b09b3222d593c65619800 /registry/registry.c
parentAdding upstream version 1.29.3. (diff)
downloadnetdata-f99c4526d94d3e04124c5c48ab4a3da6ca53a458.tar.xz
netdata-f99c4526d94d3e04124c5c48ab4a3da6ca53a458.zip
Adding upstream version 1.30.0.upstream/1.30.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'registry/registry.c')
-rw-r--r--registry/registry.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/registry/registry.c b/registry/registry.c
index b14f4ee4..8148745f 100644
--- a/registry/registry.c
+++ b/registry/registry.c
@@ -23,7 +23,7 @@ static inline void registry_unlock(void) {
// COOKIES
static void registry_set_cookie(struct web_client *w, const char *guid) {
- char edate[100];
+ char edate[100], domain[512];
time_t et = now_realtime_sec() + registry.persons_expiration;
struct tm etmbuf, *etm = gmtime_r(&et, &etmbuf);
strftime(edate, sizeof(edate), "%a, %d %b %Y %H:%M:%S %Z", etm);
@@ -31,7 +31,22 @@ static void registry_set_cookie(struct web_client *w, const char *guid) {
snprintfz(w->cookie1, NETDATA_WEB_REQUEST_COOKIE_SIZE, NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s", guid, edate);
if(registry.registry_domain && registry.registry_domain[0])
- snprintfz(w->cookie2, NETDATA_WEB_REQUEST_COOKIE_SIZE, NETDATA_REGISTRY_COOKIE_NAME "=%s; Domain=%s; Expires=%s", guid, registry.registry_domain, edate);
+ snprintfz(domain, 511, "Domain=%s", registry.registry_domain);
+ else
+ domain[0]='\0';
+
+ int length = snprintfz(w->cookie2, NETDATA_WEB_REQUEST_COOKIE_SIZE,
+ NETDATA_REGISTRY_COOKIE_NAME "=%s; Expires=%s; %s",
+ guid, edate, domain);
+
+ size_t remaining_length = NETDATA_WEB_REQUEST_COOKIE_SIZE - length;
+ // 25 is the necessary length to add new cookies
+ if (registry.enable_cookies_samesite_secure) {
+ if (length > 0 && remaining_length > 25)
+ snprintfz(&w->cookie2[length], remaining_length, "; SameSite=None; Secure");
+ else
+ error("Netdata does not have enough space to store cookies SameSite and Secure");
+ }
}
static inline void registry_set_person_cookie(struct web_client *w, REGISTRY_PERSON *p) {