Created attachment 636010 [details]
Redefine mkostemp() to mkstemp() if uclibc is used
Description of problem:
In latest versions of libvirt mkostemp() GNU function is used. This function does not exist in uclibc and therefore the build fails on Alpine Linux, an uclibc-based distribution.
Version-Release number of selected component (if applicable):
Try building the package
Steps to Reproduce:
3. make install
./.libs/libvirt_util.a(libvirt_util_la-logging.o): In function `virLogOutputToJournald':
logging.c:(.text+0xa2a): undefined reference to `mkostemp'
Be able to build successfully on uclibc
See patch attached
You should mention what you're seeing on libvir list. There's a thread going on currently about the release of 1.0.0 where your experience would be really helpful (Subject "Availability of Release Candidate 2 for 1.0.0") I've mentioned this BZ already.
A future revision of POSIX will probably be adding mkostemp() as a required function, since use of mkstemp() in a multi-threaded program that forks children is a recipe for unintentionally leaking the temporary file to a child: http://austingroupbugs.net/view.php?id=411
So I argue that this is a bug in uclibc for missing out on safer interfaces.
That said, gnulib provides mkostemp() for all platforms, so it is also a bug in libvirt for not listing mkostemp in bootstrap.conf. I'll push the one-liner fix upstream shortly.
Alternative patch proposed:
Libvirt 1.0.0 will have this:
Author: Eric Blake <firstname.lastname@example.org>
Date: Wed Oct 31 08:13:47 2012 -0600
build: prefer mkostemp for multi-thread safety
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.
The commit above fixed the issue on uclibc.
And we promptly regressed this for the 1.0.0 release, taking three additional commits to get it back to the correct state: 30b398d, bd0cb27, d055498. Oh well.