Create temporary files in the target directory
Whenever we need to create a temporary file while writing to disk on a
POSIX system, try to create it in the same directory as the final file
instead of the current working directory. The target directory can
reasonably be expected to be writable (and if it isn't, creating the
file will fail anyway), but the current working directory may not be.
While here, consistently use __archive_mkstemp(), and increase the
template from six to eight random characters.
Fixes:
2e73ea3a7db1 ("Fix max path-length metadata writing (#2243)")
Fixes:
e12c955dca63 ("Unify temporary directory handling")