Date: Thu, 16 Aug 2018 22:04:00 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337930 - in head/tests/sys: aio file kern kern/pipe posixshm Message-ID: <201808162204.w7GM40mQ053384@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Thu Aug 16 22:04:00 2018 New Revision: 337930 URL: https://svnweb.freebsd.org/changeset/base/337930 Log: Revert r337929 FreeBSD's mkstemp sets the temporary file's permissions to 600, and has ever since mkstemp was added in 1987. Coverity's warning is still relevant for portable programs since OpenGroup does not require that behavior, and POSIX didn't until 2008. But none of these programs are portable. Modified: head/tests/sys/aio/aio_kqueue_test.c head/tests/sys/aio/lio_kqueue_test.c head/tests/sys/file/dup_test.c head/tests/sys/file/flock_helper.c head/tests/sys/kern/kern_copyin.c head/tests/sys/kern/pipe/pipe_overcommit2_test.c head/tests/sys/kern/ptrace_test.c head/tests/sys/kern/unix_passfd_test.c head/tests/sys/posixshm/posixshm_test.c Modified: head/tests/sys/aio/aio_kqueue_test.c ============================================================================== --- head/tests/sys/aio/aio_kqueue_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/aio/aio_kqueue_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -36,7 +36,6 @@ #include <sys/types.h> #include <sys/event.h> -#include <sys/stat.h> #include <sys/time.h> #include <aio.h> #include <err.h> @@ -91,7 +90,6 @@ main (int argc, char *argv[]) if (argc == 1) { strcpy(pathname, PATH_TEMPLATE); - umask(0077); fd = mkstemp(pathname); file = pathname; tmp_file = 1; Modified: head/tests/sys/aio/lio_kqueue_test.c ============================================================================== --- head/tests/sys/aio/lio_kqueue_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/aio/lio_kqueue_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -32,7 +32,6 @@ #include <sys/types.h> #include <sys/event.h> -#include <sys/stat.h> #include <sys/time.h> #include <aio.h> #include <fcntl.h> @@ -87,7 +86,6 @@ main(int argc, char *argv[]) if (argc == 1) { strcpy(pathname, PATH_TEMPLATE); - umask(0077); fd = mkstemp(pathname); file = pathname; tmp_file = 1; Modified: head/tests/sys/file/dup_test.c ============================================================================== --- head/tests/sys/file/dup_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/file/dup_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -50,7 +50,6 @@ * open files limit work. */ -#include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> @@ -69,7 +68,6 @@ getafile(void) int fd; char temp[] = "/tmp/dup2XXXXXXXXX"; - umask(0077); if ((fd = mkstemp(temp)) < 0) err(1, "mkstemp"); remove(temp); Modified: head/tests/sys/file/flock_helper.c ============================================================================== --- head/tests/sys/file/flock_helper.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/file/flock_helper.c Thu Aug 16 22:04:00 2018 (r337930) @@ -92,7 +92,6 @@ make_file(const char *pathname, off_t sz) filename = malloc(len); strcpy(filename, pathname); strcat(filename, template); - umask(0077); fd = mkstemp(filename); if (fd < 0) err(1, "mkstemp"); Modified: head/tests/sys/kern/kern_copyin.c ============================================================================== --- head/tests/sys/kern/kern_copyin.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/kern/kern_copyin.c Thu Aug 16 22:04:00 2018 (r337930) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <sys/stat.h> #include <errno.h> #include <limits.h> #include <stdio.h> @@ -70,7 +69,6 @@ ATF_TC_BODY(kern_copyin, tc) atf_tc_skip("Platform is not supported."); #endif - umask(0077); scratch_file = mkstemp(template); ATF_REQUIRE(scratch_file != -1); unlink(template); Modified: head/tests/sys/kern/pipe/pipe_overcommit2_test.c ============================================================================== --- head/tests/sys/kern/pipe/pipe_overcommit2_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/kern/pipe/pipe_overcommit2_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -27,7 +27,6 @@ */ #include <sys/param.h> -#include <sys/stat.h> #include <err.h> #include <errno.h> #include <fcntl.h> @@ -51,7 +50,6 @@ main(void) lastfd = -1; - umask(0077); if (mkstemp(template) == -1) err(1, "mkstemp failed"); Modified: head/tests/sys/kern/ptrace_test.c ============================================================================== --- head/tests/sys/kern/ptrace_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/kern/ptrace_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include <sys/ptrace.h> #include <sys/queue.h> #include <sys/runq.h> -#include <sys/stat.h> #include <sys/syscall.h> #include <sys/sysctl.h> #include <sys/user.h> @@ -3348,7 +3347,6 @@ ATF_TC_BODY(ptrace__PT_ATTACH_with_SBDRY_thread, tc) ATF_REQUIRE(pthread_barrier_init(&barrier, &battr, 2) == 0); (void)snprintf(tmpfile, sizeof(tmpfile), "./ptrace.XXXXXX"); - umask(0077); fd = mkstemp(tmpfile); ATF_REQUIRE(fd >= 0); Modified: head/tests/sys/kern/unix_passfd_test.c ============================================================================== --- head/tests/sys/kern/unix_passfd_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/kern/unix_passfd_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -87,7 +87,6 @@ tempfile(int *fdp) snprintf(path, PATH_MAX, "%s/unix_passfd.XXXXXXXXXXXXXXX", getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")); - umask(0077); fd = mkstemp(path); ATF_REQUIRE_MSG(fd != -1, "mkstemp(%s) failed", path); (void)unlink(path); Modified: head/tests/sys/posixshm/posixshm_test.c ============================================================================== --- head/tests/sys/posixshm/posixshm_test.c Thu Aug 16 21:36:19 2018 (r337929) +++ head/tests/sys/posixshm/posixshm_test.c Thu Aug 16 22:04:00 2018 (r337930) @@ -54,7 +54,6 @@ gen_test_path(void) snprintf(test_path, sizeof(test_path), "%s/tmp.XXXXXX", getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")); test_path[sizeof(test_path) - 1] = '\0'; - umask(0077); ATF_REQUIRE_MSG(mkstemp(test_path) != -1, "mkstemp failed; errno=%d", errno); ATF_REQUIRE_MSG(unlink(test_path) == 0,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808162204.w7GM40mQ053384>