In a container cgsnapshot doesn't report owner/group
permissions, but on a bare-metal setup, it does.  Add
support to parse the permissions fields.

Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com>
---
 ftests/cgroup.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ftests/cgroup.py b/ftests/cgroup.py
index 947cbbe940ec..269657549d31 100644
--- a/ftests/cgroup.py
+++ b/ftests/cgroup.py
@@ -227,7 +227,7 @@ class Cgroup(object):
         if config.args.container:
             ret = config.container.run(cmd)
         else:
-            ret = Run.run(cmd)
+            ret = Run.run(cmd).decode('ascii')
 
         return ret
 
@@ -265,6 +265,9 @@ class Cgroup(object):
             GROUP = 1
             CONTROLLER = 2
             SETTING = 3
+            PERM = 4
+            ADMIN = 5
+            TASK = 6
 
         mode = parsemode.UNKNOWN
 
@@ -287,7 +290,9 @@ class Cgroup(object):
                     mode = parsemode.GROUP
 
             elif mode == parsemode.GROUP:
-                if line.endswith("{"):
+                if line.startswith("perm {"):
+                    mode = parsemode.PERM
+                elif line.endswith("{"):
                     ctrl_name = line.split()[0]
                     cg.controllers[ctrl_name] = Controller(ctrl_name)
 
@@ -327,6 +332,19 @@ class Cgroup(object):
                 else:
                     value += "{}\n".format(line)
 
+            elif mode == parsemode.PERM:
+                if line.startswith("admin {"):
+                    mode = parsemode.ADMIN
+                elif line.startswith("task {"):
+                    mode = parsemode.TASK
+                elif line.endswith("}"):
+                    mode = parsemode.GROUP
+
+            elif mode == parsemode.ADMIN or mode == parsemode.TASK:
+                # todo - handle these modes
+                if line.endswith("}"):
+                    mode = parsemode.PERM
+
         return cgdict
 
     @staticmethod
@@ -345,7 +363,7 @@ class Cgroup(object):
         if config.args.container:
             res = config.container.run(cmd)
         else:
-            res = Run.run(cmd)
+            res = Run.run(cmd).decode('ascii')
 
         # convert the cgsnapshot stdout to a dict of cgroup objects
         return Cgroup.snapshot_to_dict(res)
-- 
2.26.2



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to