[pulseaudio-commits] 4 commits - src/modules src/pulsecore

Arun Raghavan arun at kemper.freedesktop.org
Wed Jun 13 04:10:25 PDT 2012


 src/modules/module-role-cork.c |    4 ++--
 src/pulsecore/authkey.c        |    3 +++
 src/pulsecore/core-util.c      |   33 +++++++++++++++++++++++++++++++++
 src/pulsecore/core-util.h      |    1 +
 4 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit a91359956f166005749247eaa5f4001a4555689d
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Mon Jun 11 13:15:00 2012 +0530

    auth: Create cookie directory if it doesn't exist
    
    Makes sure the cookie directory exists before trying to create the
    cookie. This might be the case on freshly installed headless systems.

diff --git a/src/pulsecore/authkey.c b/src/pulsecore/authkey.c
index c37d3fe..73e4f5e 100644
--- a/src/pulsecore/authkey.c
+++ b/src/pulsecore/authkey.c
@@ -82,6 +82,9 @@ static int load(const char *fn, pa_bool_t create, void *data, size_t length) {
     pa_assert(data);
     pa_assert(length > 0);
 
+    if (create)
+        pa_make_secure_parent_dir(fn, pa_in_system_mode() ? 0755U : 0700U, -1, -1);
+
     if ((fd = pa_open_cloexec(fn, (create ? O_RDWR|O_CREAT : O_RDONLY)|O_BINARY, S_IRUSR|S_IWUSR)) < 0) {
 
         if (!create || errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) {

commit 59968f8e2cd90eb06c6d8b247811129cfe3980ea
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Mon Jun 11 13:12:50 2012 +0530

    core-util: Make pa_make_secure_dir() act like mkdir -p
    
    This makes pa_make_secure_dir() create any missing parent directories in
    the given path as well. This is useful, for example, on a pristine
    system with a clean $HOME that needs ~/.config/pulse/ to be created when
    ~/.config does not exist.

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 154a748..834c69b 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -220,9 +220,11 @@ void pa_make_fd_cloexec(int fd) {
 int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
     struct stat st;
     int r, saved_errno;
+    pa_bool_t retry = TRUE;
 
     pa_assert(dir);
 
+again:
 #ifdef OS_IS_WIN32
     r = mkdir(dir);
 #else
@@ -234,6 +236,14 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
 }
 #endif
 
+    if (r < 0 && errno == ENOENT && retry) {
+        /* If a parent directory in the path doesn't exist, try to create that
+         * first, then try again. */
+        pa_make_secure_parent_dir(dir, m, uid, gid);
+        retry = FALSE;
+        goto again;
+    }
+
     if (r < 0 && errno != EEXIST)
         return -1;
 

commit b942af65fedbc171601644001e88414d14669a0f
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Wed Jun 13 16:31:59 2012 +0530

    core-util: Add a pa_split_in_place() string utility function
    
    For specialised uses of pa_split() such as finding substrings for
    comparison, this avoids the need to repeatedly allocate and deallocate
    memory.

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index d79d289..154a748 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -937,6 +937,29 @@ char *pa_split(const char *c, const char *delimiter, const char**state) {
     return pa_xstrndup(current, l);
 }
 
+/* Split the specified string wherever one of the strings in delimiter
+ * occurs. Each time it is called returns a pointer to the substring within the
+ * string and the length in 'n'. Note that the resultant string cannot be used
+ * as-is without the length parameter, since it is merely pointing to a point
+ * within the original string. The variable state points to, should be
+ * initialized to NULL before the first call. */
+const char *pa_split_in_place(const char *c, const char *delimiter, int *n, const char**state) {
+    const char *current = *state ? *state : c;
+    size_t l;
+
+    if (!*current)
+        return NULL;
+
+    l = strcspn(current, delimiter);
+    *state = current+l;
+
+    if (**state)
+        (*state)++;
+
+    *n = l;
+    return current;
+}
+
 /* Split a string into words. Otherwise similar to pa_split(). */
 char *pa_split_spaces(const char *c, const char **state) {
     const char *current = *state ? *state : c;
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 4a1c096..a3c2247 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -100,6 +100,7 @@ static inline const char *pa_strna(const char *x) {
 }
 
 char *pa_split(const char *c, const char*delimiters, const char **state);
+const char *pa_split_in_place(const char *c, const char*delimiters, int *n, const char **state);
 char *pa_split_spaces(const char *c, const char **state);
 
 char *pa_strip_nl(char *s);

commit 51c8d5a477d36f0646243a092994036b3781e9c1
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Wed Jun 13 16:29:35 2012 +0530

    role-cork: Fix a minor leak

diff --git a/src/modules/module-role-cork.c b/src/modules/module-role-cork.c
index a4270a4..8d003da 100644
--- a/src/modules/module-role-cork.c
+++ b/src/modules/module-role-cork.c
@@ -227,7 +227,7 @@ int pa__init(pa_module *m) {
         char *n = NULL;
         while ((n = pa_split(roles, ",", &split_state)))
             if (n[0] != '\0')
-                pa_idxset_put(u->trigger_roles, pa_xstrdup(n), NULL);
+                pa_idxset_put(u->trigger_roles, n, NULL);
     }
     if (pa_idxset_isempty(u->trigger_roles)) {
         pa_log_debug("Using role 'phone' as trigger role.");
@@ -241,7 +241,7 @@ int pa__init(pa_module *m) {
         char *n = NULL;
         while ((n = pa_split(roles, ",", &split_state)))
             if (n[0] != '\0')
-                pa_idxset_put(u->cork_roles, pa_xstrdup(n), NULL);
+                pa_idxset_put(u->cork_roles, n, NULL);
     }
     if (pa_idxset_isempty(u->cork_roles)) {
         pa_log_debug("Using roles 'music' and 'video' as cork roles.");



More information about the pulseaudio-commits mailing list