summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-09-17 20:58:36 +0200
committerLennart Poettering <lennart@poettering.net>2009-09-17 20:58:36 +0200
commit2d9168ceb388cbb6dba49cc3a531921f78ec3295 (patch)
tree7aeae7015c8da1d23b5d72a1af56dc3cbd9d8159
parent3de5c49e4289bb646919bdced6fccb82ced51ad0 (diff)
Improve TMPDIR handling
Patch from 'jnelson', http://pulseaudio.org/ticket/653
-rw-r--r--src/pulsecore/core-util.c2
-rw-r--r--src/utils/padsp.c15
2 files changed, 15 insertions, 2 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 7a9f458c..690f34c9 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1390,7 +1390,7 @@ static char* make_random_dir(mode_t m) {
if (!tmpdir || !pa_is_path_absolute(tmpdir))
tmpdir = "/tmp";
- fn = pa_sprintf_malloc("%s/pulse-XXXXXXXXXXXX", tmpdir);
+ fn = pa_sprintf_malloc("%s" PA_PATH_SEP "pulse-XXXXXXXXXXXX", tmpdir);
pathlen = strlen(fn);
for (;;) {
diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 41bfd741..c8c0874d 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -1394,10 +1394,21 @@ static int sndstat_open(int flags, int *_errno) {
"Mixers:\n"
"0: PulseAudio Virtual OSS\n";
- char fn[] = "/tmp/padsp-sndstat-XXXXXX";
+ char *fn;
mode_t u;
int fd = -1;
int e;
+ const char *tmpdir;
+
+ if (!(tmpdir = getenv("TMPDIR")))
+ if (!(tmpdir = getenv("TMP")))
+ if (!(tmpdir = getenv("TEMP")))
+ tmpdir = getenv("TEMPDIR");
+
+ if (!tmpdir || !pa_is_path_absolute(tmpdir))
+ tmpdir = "/tmp";
+
+ fn = pa_sprintf_malloc("%s" PA_PATH_SEP "padsp-sndstat-XXXXXX", tmpdir);
debug(DEBUG_LEVEL_NORMAL, __FILE__": sndstat_open()\n");
@@ -1423,6 +1434,7 @@ static int sndstat_open(int flags, int *_errno) {
}
unlink(fn);
+ pa_xfree(fn);
if (write(fd, sndstat, sizeof(sndstat) -1) != sizeof(sndstat)-1) {
*_errno = errno;
@@ -1439,6 +1451,7 @@ static int sndstat_open(int flags, int *_errno) {
return fd;
fail:
+ pa_xfree(fn);
if (fd >= 0)
close(fd);
return -1;