summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-04 11:15:28 +0100
committerMichael Vogt <mvo@debian.org>2014-01-04 11:15:28 +0100
commitc93d14fc05b50a8ee8bb7804579c2912f34c676b (patch)
tree1f45c51bd8d3ab33de2610f1663b3ec8e5f49c02 /apt-pkg/contrib
parente2fa0aa64d2249129543f82a213043d96469be1c (diff)
parent23bd09778261c945b460b46d855b1a6ef998cfd8 (diff)
Merge branch 'debian/sid' into feature/source-deb822
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc17
-rw-r--r--apt-pkg/contrib/fileutl.h2
-rw-r--r--apt-pkg/contrib/gpgv.cc12
3 files changed, 22 insertions, 9 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 7fbe4d604..efbf7aaf4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1827,3 +1827,20 @@ std::vector<std::string> Glob(std::string const &pattern, int flags)
return result;
}
/*}}}*/
+
+std::string GetTempDir()
+{
+ const char *tmpdir = getenv("TMPDIR");
+
+#ifdef P_tmpdir
+ if (!tmpdir)
+ tmpdir = P_tmpdir;
+#endif
+
+ // check that tmpdir is set and exists
+ struct stat st;
+ if (!tmpdir || strlen(tmpdir) == 0 || stat(tmpdir, &st) != 0)
+ tmpdir = "/tmp";
+
+ return string(tmpdir);
+}
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index e9a9aab28..e752e9621 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -165,6 +165,8 @@ bool DirectoryExists(std::string const &Path) __attrib_const;
bool CreateDirectory(std::string const &Parent, std::string const &Path);
time_t GetModificationTime(std::string const &Path);
+std::string GetTempDir();
+
/** \brief Ensure the existence of the given Path
*
* \param Parent directory of the Path directory - a trailing
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index f47e7ea48..f57a72d86 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>
@@ -21,16 +22,9 @@
/*}}}*/
static char * GenerateTemporaryFileTemplate(const char *basename) /*{{{*/
{
- const char *tmpdir = getenv("TMPDIR");
-#ifdef P_tmpdir
- if (!tmpdir)
- tmpdir = P_tmpdir;
-#endif
- if (!tmpdir)
- tmpdir = "/tmp";
-
std::string out;
- strprintf(out, "%s/%s.XXXXXX", tmpdir, basename);
+ std::string tmpdir = GetTempDir();
+ strprintf(out, "%s/%s.XXXXXX", tmpdir.c_str(), basename);
return strdup(out.c_str());
}
/*}}}*/