mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
vircgroupmock: Mock access() to some more files
Currently, if access(path, mode) is invoked, we check if @path has this special prefix SYSFS_PREFIX. If it does, we modify the path a bit and call realaccess. If it doesn't we act just like a wrapper and call realaccess directly. However, we are mocking fopen() as well. And as one can clearly see there, fopen("/proc/cgroups") will succeed. Hence, we have an error in our mocked access(): We need to check whether @path is not equal to /proc/cgroups as it may not exists on real system we're running however we definitely know how to fopen() it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9eb68903f5
commit
32799f1a9d
@ -498,6 +498,14 @@ int access(const char *path, int mode)
|
|||||||
}
|
}
|
||||||
ret = realaccess(newpath, mode);
|
ret = realaccess(newpath, mode);
|
||||||
free(newpath);
|
free(newpath);
|
||||||
|
} else if (STREQ(path, "/proc/cgroups") ||
|
||||||
|
STREQ(path, "/proc/self/cgroup")) {
|
||||||
|
/* These files are readable for all. */
|
||||||
|
ret = (mode == F_OK || mode == R_OK) ? 0 : -1;
|
||||||
|
} else if (STREQ(path, "/proc/mounts")) {
|
||||||
|
/* This one is accessible anytime for anybody. In fact, it's just
|
||||||
|
* a symlink to /proc/self/mounts. */
|
||||||
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
ret = realaccess(path, mode);
|
ret = realaccess(path, mode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user