]> granicus.if.org Git - p11-kit/commitdiff
tests: Add tmpdir argument to p11_test_copy_setgid
authorDaiki Ueno <dueno@redhat.com>
Sat, 1 Jun 2019 07:17:00 +0000 (09:17 +0200)
committerDaiki Ueno <ueno@gnu.org>
Tue, 18 Jun 2019 12:17:28 +0000 (14:17 +0200)
To prevent BUILDDIR being embedded in the library.

common/test-compat.c
common/test.c
common/test.h
p11-kit/test-conf.c

index 8b5d2e6464449d2a700a7b63a88ec7de847296f7..e1deac8cb3ed5097717f2fca84784a7959c8e173 100644 (file)
@@ -70,7 +70,7 @@ test_getauxval (void)
        ret = p11_test_run_child (args, true);
        assert_num_eq (ret, 0);
 
-       path = p11_test_copy_setgid (args[0]);
+       path = p11_test_copy_setgid (args[0], BUILDDIR);
        if (path == NULL)
                return;
 
@@ -95,7 +95,7 @@ test_secure_getenv (void)
        ret = p11_test_run_child (args, true);
        assert_num_eq (ret, 5);
 
-       path = p11_test_copy_setgid (args[0]);
+       path = p11_test_copy_setgid (args[0], BUILDDIR);
        if (path == NULL)
                return;
 
index 3827ab0d09fa150b9141fdc4c4b9e03411f0438a..9749a91f5f86f10afd72089c5a003959ae1f6159 100644 (file)
@@ -579,7 +579,8 @@ copy_file (const char *input,
 }
 
 char *
-p11_test_copy_setgid (const char *input)
+p11_test_copy_setgid (const char *input,
+                     const char *tmpdir)
 {
        gid_t groups[128];
                char *path;
@@ -600,7 +601,9 @@ p11_test_copy_setgid (const char *input)
                return NULL;
        }
 
-       path = strdup (BUILDDIR "/test-setgid.XXXXXX");
+       if (asprintf(&path, "%s/test-setgid.XXXXXX", tmpdir) < 0)
+               assert_not_reached();
+
        assert (path != NULL);
 
        fd = mkstemp (path);
index 1c952b0da481b19fe859d59686566d124cb9f7b6..81b90f674a1ebb8341a6d6219006e3a10a2d473d 100644 (file)
@@ -162,7 +162,8 @@ void        p11_test_file_delete    (const char *directory,
 
 #ifdef OS_UNIX
 
-char *      p11_test_copy_setgid    (const char *path);
+char *      p11_test_copy_setgid    (const char *path,
+                                    const char *tmpdir);
 
 int         p11_test_run_child      (const char **argv,
                                      bool quiet_out);
index a140aaa67327eb28aaa2271831ccd2c492a9195e..f4ef0f665c628adc77c8d4ff9db7bee1788c0b26 100644 (file)
@@ -410,7 +410,7 @@ test_setuid (void)
        ret = p11_test_run_child (args, true);
        assert_num_eq (ret, 33);
 
-       path = p11_test_copy_setgid (args[0]);
+       path = p11_test_copy_setgid (args[0], BUILDDIR);
        if (path == NULL)
                return;