mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
utils: fix parsing of cgroup with : in the name
a cgroup can have ':' in its name. Make sure the parser doesn't split more than 3 fields and leave untouched the ':' in the cgroup name. commit 6ee5f740a4ecb70636b888e78b02065ee984636c introduced the issue. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -64,7 +64,7 @@ func getCgroupProcess(procFile string) (string, error) {
|
|||||||
cgroup := "/"
|
cgroup := "/"
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
parts := strings.Split(line, ":")
|
parts := strings.SplitN(line, ":", 3)
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return "", errors.Errorf("cannot parse cgroup line %q", line)
|
return "", errors.Errorf("cannot parse cgroup line %q", line)
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ func MoveUnderCgroupSubtree(subtree string) error {
|
|||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
parts := strings.Split(line, ":")
|
parts := strings.SplitN(line, ":", 3)
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return errors.Errorf("cannot parse cgroup line %q", line)
|
return errors.Errorf("cannot parse cgroup line %q", line)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user