void test_openat(const char *path)
{
	char *d = strdupa(path), *f, *tmpname;
	int fd, fd2;
	f = basename(d);
	d = dirname(d);
	fd = open(d, O_RDONLY);
	if (fd < 0) {
		fprintf(stderr, "Error in openat test: could not open parent dir\n");
		fprintf(stderr, "(this is expected on the second run)\n");
		return;
	}
	fd2 = openat(fd, f, O_RDONLY);
	if (fd2 >= 0 || errno != ENOENT) {
		fprintf(stderr, "leak at openat of %s\n", f);
		exit(1);
	}
	size_t len = strlen(path) + strlen("/cgroup.procs") + 1;
	tmpname = alloca(len);
	snprintf(tmpname, len, "%s/cgroup.procs", f);
	fd2 = openat(fd, tmpname, O_RDONLY);
	if (fd2 >= 0 || errno != ENOENT) {
		fprintf(stderr, "leak at openat of %s\n", tmpname);
		exit(1);
	}
	close(fd);
}
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.