From 4dbd6e9654752b3e4971e4cb69f2e09666f6b252 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 31 Oct 2012 08:13:47 -0600 Subject: [PATCH] build: prefer mkostemp for multi-thread safety https://bugzilla.redhat.com/show_bug.cgi?id=871756 Commit cd1e8d1 assumed that systems new enough to have journald also have mkostemp; but this is not true for uclibc. For that matter, use of mkstemp[s] is unsafe in a multi-threaded program. We should prefer mkostemp[s] in the first place. * bootstrap.conf (gnulib_modules): Add mkostemp, mkostemps; drop mkstemp and mkstemps. * cfg.mk (sc_prohibit_mkstemp): New syntax check. * tools/virsh.c (vshEditWriteToTempFile): Adjust caller. * src/qemu/qemu_driver.c (qemuDomainScreenshot) (qemudDomainMemoryPeek): Likewise. * src/secret/secret_driver.c (replaceFile): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise. --- bootstrap.conf | 4 ++-- cfg.mk | 6 ++++++ src/qemu/qemu_driver.c | 8 ++++---- src/secret/secret_driver.c | 4 ++-- src/vbox/vbox_tmpl.c | 4 ++-- tools/virsh.c | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 5d391fdadc..59dd2580f1 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -69,8 +69,8 @@ listen localeconv maintainer-makefile manywarnings -mkstemp -mkstemps +mkostemp +mkostemps mktempd net_if netdb diff --git a/cfg.mk b/cfg.mk index 50e6a50c69..cda04e418a 100644 --- a/cfg.mk +++ b/cfg.mk @@ -339,6 +339,12 @@ sc_prohibit_fork_wrappers: halt='use virCommand for child processes' \ $(_sc_search_regexp) +# Prefer mkostemp with O_CLOEXEC. +sc_prohibit_mkstemp: + @prohibit='[^"]\