[libvirt] [PATCH for 1.2.6] securityselinuxlabeltest: Don't create dummy file in the srcdir

At the very beginning of the test we check if the underlying filesystem supports extended attributes as they are used to store fake SELinux labels. In order to check that, a dummy file is created and semi-random attribute is set. However, the file is created under: abs_srcdir "/securityselinuxlabeldata/testxattr" which has two problems: abs_srcdir is not required to be writable, so it should have been abs_builddir. The second one is - there's no "securityselinuxlabeldata" folder under abs_builddir. The problem was introduced in caf164f1. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/securityselinuxlabeltest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 3699d89..455eb74 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -65,10 +65,11 @@ testUserXattrEnabled(void) const char *con_value = "system_u:object_r:svirt_image_t:s0:c41,c264"; char *path = NULL; if (virAsprintf(&path, "%s/securityselinuxlabeldata/testxattr", - abs_srcdir) < 0) + abs_builddir) < 0) goto cleanup; - if (virFileTouch(path, 0600) < 0) + if (virFileMakePath(abs_builddir "/securityselinuxlabeldata") < 0 || + virFileTouch(path, 0600) < 0) goto cleanup; len = setxattr(path, "user.libvirt.selinux", con_value, @@ -83,6 +84,7 @@ testUserXattrEnabled(void) cleanup: unlink(path); + rmdir(abs_builddir "/securityselinuxlabeldata"); VIR_FREE(path); return ret; } -- 1.8.5.5

On 07/01/2014 02:58 PM, Michal Privoznik wrote:
At the very beginning of the test we check if the underlying filesystem supports extended attributes as they are used to store fake SELinux labels. In order to check that, a dummy file is created and semi-random attribute is set. However, the file is created under:
abs_srcdir "/securityselinuxlabeldata/testxattr"
which has two problems: abs_srcdir is not required to be writable, so it should have been abs_builddir. The second one is - there's no "securityselinuxlabeldata" folder under abs_builddir. The problem was introduced in caf164f1.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/securityselinuxlabeltest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ACK
participants (2)
-
Ján Tomko
-
Michal Privoznik