From 6bebd5747aa49d4a124d23d4967f65a771799fe5 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sat, 1 Jun 2019 09:17:00 +0200 Subject: tests: Add tmpdir argument to p11_test_copy_setgid To prevent BUILDDIR being embedded in the library. --- common/test-compat.c | 4 ++-- common/test.c | 7 +++++-- common/test.h | 3 ++- p11-kit/test-conf.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/test-compat.c b/common/test-compat.c index 8b5d2e6..e1deac8 100644 --- a/common/test-compat.c +++ b/common/test-compat.c @@ -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; diff --git a/common/test.c b/common/test.c index 3827ab0..9749a91 100644 --- a/common/test.c +++ b/common/test.c @@ -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); diff --git a/common/test.h b/common/test.h index 1c952b0..81b90f6 100644 --- a/common/test.h +++ b/common/test.h @@ -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); diff --git a/p11-kit/test-conf.c b/p11-kit/test-conf.c index a140aaa..f4ef0f6 100644 --- a/p11-kit/test-conf.c +++ b/p11-kit/test-conf.c @@ -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; -- cgit v1.1