// libseccomp
#include <seccomp.h>
+// libuuid
+#include <uuid.h>
+
#include <pakfire/arch.h>
#include <pakfire/cgroup.h>
#include <pakfire/jail.h>
struct pakfire* pakfire;
int nrefs;
+ // A unique ID for each jail
+ uuid_t uuid;
+ char __uuid[UUID_STR_LEN];
+
// Flags
int flags;
// Store flags
j->flags = flags;
+ // Generate a random UUID
+ uuid_generate_random(j->uuid);
+
DEBUG(j->pakfire, "Allocated new jail at %p\n", j);
// Set default log callback
return jail->flags & flag;
}
+static const char* pakfire_jail_uuid(struct pakfire_jail* jail) {
+ if (*jail->__uuid)
+ uuid_unparse_lower(jail->uuid, jail->__uuid);
+
+ return jail->__uuid;
+}
+
// Resource Limits
PAKFIRE_EXPORT int pakfire_jail_nice(struct pakfire_jail* jail, int nice) {
if (jail->cgroup) {
args.flags |= CLONE_INTO_CGROUP;
-#warning TODO randomize the name
+ // Fetch our UUID
+ const char* uuid = pakfire_jail_uuid(jail);
// Create a temporary cgroup
- r = pakfire_cgroup_child(&ctx.cgroup, jail->cgroup, "jail", 0);
+ r = pakfire_cgroup_child(&ctx.cgroup, jail->cgroup, uuid, 0);
if (r) {
ERROR(jail->pakfire, "Could not create cgroup for jail: %m\n");
goto ERROR;