diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2019-03-26 14:55:36 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2019-03-27 16:11:34 +0000 |
commit | 598641f460fce981405bd9cf07e7d6a34deb37bd (patch) | |
tree | a867a5a76beb0f8119795b7b5770194839ed87ef | |
parent | a6d822cee3d22d763d10ab343a462a4ce4cfa83b (diff) | |
download | libvirt-598641f460fce981405bd9cf07e7d6a34deb37bd.tar.gz |
tests: don't abort in fopen(/proc/mounts)
The mock fopen() function will abort if "/proc/mounts" is
requested with "r" permissions and VIR_CGROUP_MOCK_FILENAME
env var is not set.
Unfortunately this is triggering by the libselinux library
constructor when it tries to read /proc/mounts to find out
if selinuxfs is mounted in an unusual place.
This, however, only affects libselinux in Debian as that
opens with "r", while in Fedora / RHEL it opens "re" and
thus luckily never triggered the abort(), instead getting
an EACCESS.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | tests/vircgroupmock.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 06bd0a5f29..9c67a44b0d 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -460,8 +460,10 @@ FILE *fopen(const char *path, const char *mode) } if (type) { - if (!filename) - abort(); + if (!filename) { + errno = EACCES; + return NULL; + } if (virAsprintfQuiet(&filepath, "%s/vircgroupdata/%s.%s", abs_srcdir, filename, type) < 0) { abort(); |