summaryrefslogtreecommitdiff
path: root/common/path.c
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2013-07-17 09:51:32 +0200
committerStef Walter <stef@thewalter.net>2013-07-18 08:13:20 +0200
commit81a6e16539e5e4a27c55194ae095cc4a75d08ade (patch)
tree70e409e938e60c326f95d85ac059efb58f48286a /common/path.c
parenteb8f5859b1349f8147ba47a1da8032df192f2370 (diff)
tools: Use $TMPDIR instead of $TEMP
TMPDIR is a more standard environment variable for locating the temp directory on Unix. In addition since this is only used in tests, remove the code from the generic p11_path_expand() func. In general remove the possibility for forks to put $HOME or $TEMP environment variables in configured paths. This was possible due to code in p11_path_expand() but not something we supported. https://bugzilla.redhat.com/show_bug.cgi?id=985017
Diffstat (limited to 'common/path.c')
-rw-r--r--common/path.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/common/path.c b/common/path.c
index 818befc..0ff1431 100644
--- a/common/path.c
+++ b/common/path.c
@@ -49,7 +49,6 @@
#include <string.h>
#ifdef OS_UNIX
-#include <paths.h>
#include <pwd.h>
#include <unistd.h>
#endif
@@ -135,41 +134,6 @@ expand_homedir (const char *remainder)
}
}
-static char *
-expand_tempdir (const char *remainder)
-{
- const char *env;
-
- if (remainder[0] == '\0')
- remainder = NULL;
-
- env = getenv ("TEMP");
- if (env && env[0]) {
- return p11_path_build (env, remainder, NULL);
-
- } else {
-#ifdef OS_UNIX
-#ifdef _PATH_TMP
- return p11_path_build (_PATH_TMP, remainder, NULL);
-#else
- return p11_path_build ("/tmp", remainder, NULL);
-#endif
-
-#else /* OS_WIN32 */
- char directory[MAX_PATH + 1];
-
- if (!GetTempPathA (MAX_PATH + 1, directory)) {
- p11_message ("couldn't lookup temp directory");
- errno = ENOTDIR;
- return NULL;
- }
-
- return p11_path_build (directory, remainder, NULL);
-
-#endif /* OS_WIN32 */
- }
-}
-
static inline bool
is_path_component_or_null (char ch)
{
@@ -189,14 +153,6 @@ p11_path_expand (const char *path)
is_path_component_or_null (path[1])) {
return expand_homedir (path + 1);
- } else if (strncmp (path, "$HOME", 5) == 0 &&
- is_path_component_or_null (path[5])) {
- return expand_homedir (path + 5);
-
- } else if (strncmp (path, "$TEMP", 5) == 0 &&
- is_path_component_or_null (path[5])) {
- return expand_tempdir (path + 5);
-
} else {
return strdup (path);
}