diff --git a/linux/CGroupUtils.c b/linux/CGroupUtils.c index e8d5f1de8..aa88201ad 100644 --- a/linux/CGroupUtils.c +++ b/linux/CGroupUtils.c @@ -78,6 +78,7 @@ static bool CGroup_filterName_internal(const char* cgroup, StrBuf_state* s, StrB const char* str_nspawn_payload_label = "/payload"; const char* str_snap_scope_prefix = "snap."; + const char* str_pod_scope_prefix = "libpod-"; const char* str_service_suffix = ".service"; const char* str_scope_suffix = ".scope"; @@ -290,6 +291,23 @@ static bool CGroup_filterName_internal(const char* cgroup, StrBuf_state* s, StrB cgroup = nextSlash; + continue; + } else if (Label_checkPrefix(labelStart, scopeNameLen, str_pod_scope_prefix)) { + const char* nextDot = String_strchrnul(labelStart + strlen(str_pod_scope_prefix), '.'); + + if (!StrBuf_putsz(s, w, "!pod:")) + return false; + + if (nextDot >= labelStart + scopeNameLen) { + nextDot = labelStart + scopeNameLen; + } + + if (!StrBuf_putsn(s, w, labelStart + strlen(str_pod_scope_prefix), + MINIMUM( nextDot - (labelStart + strlen(str_pod_scope_prefix)), 12))) + return false; + + cgroup = nextSlash; + continue; }