summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/gpgv.cc
diff options
context:
space:
mode:
authorThomas Bechtold <thomasbechtold@jpberlin.de>2013-12-22 11:40:49 +0100
committerMichael Vogt <mvo@debian.org>2013-12-22 14:50:37 +0100
commit38beb8b5936e9d85a5bb99bf3860f082bbe34439 (patch)
tree9a520bd124ceb83416ea1f3c6d4aa8537d575bb3 /apt-pkg/contrib/gpgv.cc
parent62f6ecbf2f204d95e98fc5480c5a0db43b52d2be (diff)
apt-pkg/contrib/gpgv.cc: use /tmp as fallback dir
if the directory given by $TMPDIR is not available, use /tmp as fallback.
Diffstat (limited to 'apt-pkg/contrib/gpgv.cc')
-rw-r--r--apt-pkg/contrib/gpgv.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index f47e7ea48..8f619fee2 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -10,6 +10,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include<apt-pkg/configuration.h>
#include<apt-pkg/error.h>
@@ -22,11 +23,15 @@
static char * GenerateTemporaryFileTemplate(const char *basename) /*{{{*/
{
const char *tmpdir = getenv("TMPDIR");
+
#ifdef P_tmpdir
if (!tmpdir)
tmpdir = P_tmpdir;
#endif
- if (!tmpdir)
+
+ // check that tmpdir is set and exists
+ struct stat st;
+ if (!tmpdir || stat(tmpdir, &st) != 0)
tmpdir = "/tmp";
std::string out;