summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2023-11-20 22:20:50 +0100
committerBenBE <BenBE@geshi.org>2023-12-31 22:09:01 +0100
commitb149a506cff5caffe65b54db09e61a0a1f3ccca6 (patch)
tree9ae9dda9d9396e2093f2648c8c25db6c5bcab924
parent955208569cc2ede37de15172fab8cdb7bfbe80fb (diff)
Shorten docker container IDs to 12 characters
-rw-r--r--linux/CGroupUtils.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/linux/CGroupUtils.c b/linux/CGroupUtils.c
index 9554d672..f352b8e2 100644
--- a/linux/CGroupUtils.c
+++ b/linux/CGroupUtils.c
@@ -36,6 +36,7 @@ static const char* str_nspawn_payload_label = "/payload";
static const char* str_snap_scope_prefix = "snap.";
static const char* str_pod_scope_prefix = "libpod-";
+static const char* str_docker_scope_prefix = "docker-";
static const char* str_service_suffix = ".service";
static const char* str_scope_suffix = ".scope";
@@ -317,6 +318,23 @@ static bool CGroup_filterName_internal(const char* cgroup, StrBuf_state* s, StrB
cgroup = nextSlash;
continue;
+ } else if (Label_checkPrefix(labelStart, scopeNameLen, str_docker_scope_prefix)) {
+ const char* nextDot = String_strchrnul(labelStart + strlen(str_docker_scope_prefix), '.');
+
+ if (!StrBuf_putsz(s, w, "!docker:"))
+ return false;
+
+ if (nextDot >= labelStart + scopeNameLen) {
+ nextDot = labelStart + scopeNameLen;
+ }
+
+ if (!StrBuf_putsn(s, w, labelStart + strlen(str_docker_scope_prefix),
+ MINIMUM( nextDot - (labelStart + strlen(str_docker_scope_prefix)), 12)))
+ return false;
+
+ cgroup = nextSlash;
+
+ continue;
}
if (!w(s, '!'))
@@ -455,6 +473,23 @@ static bool CGroup_filterContainer_internal(const char* cgroup, StrBuf_state* s,
cgroup = nextSlash;
continue;
+ } else if (Label_checkPrefix(labelStart, scopeNameLen, str_docker_scope_prefix)) {
+ const char* nextDot = String_strchrnul(labelStart + strlen(str_docker_scope_prefix), '.');
+
+ if (!StrBuf_putsz(s, w, "!docker:"))
+ return false;
+
+ if (nextDot >= labelStart + scopeNameLen) {
+ nextDot = labelStart + scopeNameLen;
+ }
+
+ if (!StrBuf_putsn(s, w, labelStart + strlen(str_docker_scope_prefix),
+ MINIMUM( nextDot - (labelStart + strlen(str_docker_scope_prefix)), 12)))
+ return false;
+
+ cgroup = nextSlash;
+
+ continue;
}
cgroup = nextSlash;

© 2014-2024 Faster IT GmbH | imprint | privacy policy