[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.12-84-g564ef2b

Lennart Poettering gitmailer-noreply at 0pointer.de
Mon Sep 29 13:00:28 PDT 2008


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  f5c301d9f475ca62b32f48514d703266bf9b6445 (commit)

- Log -----------------------------------------------------------------
564ef2b... have make_random_dir respect $TMPDIR
-----------------------------------------------------------------------

Summary of changes:
 src/pulsecore/core-util.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

-----------------------------------------------------------------------

commit 564ef2b71fe67b58c5dfd6dd767467dad13f475e
Author: Stelian Ionescu <stelian.ionescu-zeus at poste.it>
Date:   Tue Sep 23 00:26:31 2008 +0200

    have make_random_dir respect $TMPDIR
    
    with the attached patch, make_random_dir first tries to use $TMPDIR,
    then $TMP finally defaulting to "/tmp"
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index a9e2a70..d7c5caf 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1315,31 +1315,43 @@ static char* make_random_dir(mode_t m) {
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
         "0123456789";
 
-    char fn[24] = "/tmp/pulse-";
+    const char *tmpdir;
+    char *fn;
+    size_t pathlen;
 
-    fn[sizeof(fn)-1] = 0;
+    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/pulse-XXXXXXXXXXXX", tmpdir);
+    pathlen = strlen(fn);
 
     for (;;) {
-        unsigned i;
+        size_t i;
         int r;
         mode_t u;
         int saved_errno;
 
-        for (i = 11; i < sizeof(fn)-1; i++)
+        for (i = pathlen - 12; i < pathlen; i++)
             fn[i] = table[rand() % (sizeof(table)-1)];
 
         u = umask((~m) & 0777);
         r = mkdir(fn, m);
+
         saved_errno = errno;
         umask(u);
+        errno = saved_errno;
 
         if (r >= 0)
-            return pa_xstrdup(fn);
-
-        errno = saved_errno;
+            return fn;
 
         if (errno != EEXIST) {
             pa_log_error("Failed to create random directory %s: %s", fn, pa_cstrerror(errno));
+            pa_xfree(fn);
             return NULL;
         }
     }

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list