Change tempnam(2) to mkdtemp(1)

This gets rid of the warning about security (and apparently it's the Correct™ way of doing it).

Compiles and runs fine on Linux (Solaris doesn't compile because the fixes are in the Transaction branch, FreeBSD hangs on tests even with normal master)