From a92a59c7610d81058de73451ed55fe222e5efe35 Mon Sep 17 00:00:00 2001 From: Karol Babioch Date: Fri, 6 Apr 2018 16:59:28 +0200 Subject: [PATCH] util_test: Use mkdtemp() instead of tempnam() The latter function is considered insecure and deprecated on some platforms. This will create the directory with 0700 implicitely, where it was 0755 beforehand. Since this is a more secure default and the test suite runs fine, we don't bother to chmod the directory. --- tests/util_test.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/util_test.c b/tests/util_test.c index 7b33168..8863e33 100644 --- a/tests/util_test.c +++ b/tests/util_test.c @@ -180,12 +180,10 @@ static void test_check_user_challenge_file(void) { unlink(buf); /* create temporary directory */ - tmpdir_path = tempnam(NULL, "pamtest"); + char template[] = "/tmp/pamtest.XXXXXX"; + tmpdir_path = mkdtemp(template); assert(tmpdir_path != NULL); - ret = mkdir(tmpdir_path, 0755); - assert(ret == 0); - /* set user data */ user.pw_name = "tester"; user.pw_dir = tmpdir_path; @@ -242,7 +240,6 @@ static void test_check_user_challenge_file(void) { /* remove temporary directory */ ret = rmdir(tmpdir_path); assert(ret == 0); - free(tmpdir_path); free(buf); /* check test results */