glnx-fdio: try $TMPDIR if /var/tmp doesn't exist
glnx_open_anonymous_tmpfile
attempts to create an fd in /var/tmp
regardless of the value of $TMPDIR
.
This is usually okay, but can fail in some contexts, such as in the
NixOS build environment, which doesn't have /var
mapped at all.
To avoid failing in this case, if the inner call to
glnx_open_anonymous_tmpfile_full
fails, we retrieve the value of
$TMPDIR
and try calling glnx_open_anonymous_tmpfile_full
again with
that directory instead.
In the fast path (i.e. where /var/tmp
exists), functionality is
unchanged.
Opened at @walters' suggestion following my workaround-patch to ostree (ostree#2200).