]> git.ipfire.org Git - pakfire.git/commitdiff
jail: Enable accouting in the parent group
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Dec 2024 15:22:24 +0000 (15:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Dec 2024 15:22:24 +0000 (15:22 +0000)
We cannot enable any of this in the child group because then we cannot
fork anything into it any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/jail.c

index 13e8276747eecfe9ece3ac69f3e25d11fc3e2d83..147782d901380f51bd084693ebe8e6d81da1223c 100644 (file)
@@ -1505,15 +1505,8 @@ static int __pakfire_jail_exec(struct pakfire_jail* jail,
                // Fetch our UUID
                const char* uuid = pakfire_jail_uuid(jail);
 
-               // Create a temporary cgroup
-               r = pakfire_cgroup_child(&ctx.cgroup, jail->cgroup, uuid, 0);
-               if (r < 0) {
-                       ERROR(jail->ctx, "Could not create cgroup for jail: %s\n", strerror(-r));
-                       goto ERROR;
-               }
-
                // Enable accounting to collect stats
-               r = pakfire_cgroup_enable_accounting(ctx.cgroup);
+               r = pakfire_cgroup_enable_accounting(jail->cgroup);
                if (r < 0) {
                        switch (-r) {
                                case ENOTSUP:
@@ -1525,6 +1518,13 @@ static int __pakfire_jail_exec(struct pakfire_jail* jail,
                        }
                }
 
+               // Create a temporary cgroup
+               r = pakfire_cgroup_child(&ctx.cgroup, jail->cgroup, uuid, 0);
+               if (r < 0) {
+                       ERROR(jail->ctx, "Could not create cgroup for jail: %s\n", strerror(-r));
+                       goto ERROR;
+               }
+
                // Clone into this cgroup
                args.cgroup = r = pakfire_cgroup_fd(ctx.cgroup);
                if (r < 0) {