]> git.saurik.com Git - apt.git/commitdiff
apt-pkg/contrib/gpgv.cc: use /tmp as fallback dir
authorThomas Bechtold <thomasbechtold@jpberlin.de>
Sun, 22 Dec 2013 10:40:49 +0000 (11:40 +0100)
committerMichael Vogt <mvo@debian.org>
Sun, 22 Dec 2013 13:50:37 +0000 (14:50 +0100)
if the directory given by $TMPDIR is not available, use /tmp as fallback.

apt-pkg/contrib/gpgv.cc

index f47e7ea4868f1334b7c7a5b7cbc1a5c41af690f2..8f619fee2ce67d7b54da98742cd4ebeaf203b9a9 100644 (file)
@@ -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>
 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;