pipe-sink, pipe-source: fix file permissions
authorTanu Kaskinen <tanuk@iki.fi>
Wed, 4 Jul 2018 10:40:12 +0000 (13:40 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Tue, 10 Jul 2018 11:44:46 +0000 (14:44 +0300)
We recently changed the umask of the daemon from 022 to 077, which broke
module-pipe-sink in the system mode, because nobody was allowed to read
from the pipe.

module-pipe-source in the system mode was probably always broken,
because the old umask of 022 should prevent anyone from writing to the
pipe.

This patch uses chmod() after the file creation to set the permissions
to 0666, which is what the fkfifo() call tried to set.

link: https://bugs.freedesktop.org/show_bug.cgi?id=107070
src/modules/module-pipe-sink.c
src/modules/module-pipe-source.c

index 765e751..213924f 100644 (file)
@@ -466,9 +466,15 @@ int pa__init(pa_module *m) {
             pa_log("mkfifo('%s'): %s", u->filename, pa_cstrerror(errno));
             goto fail;
         }
-    } else
+    } else {
         u->do_unlink_fifo = true;
 
+        /* Our umask is 077, so the pipe won't be created with the requested
+         * permissions. Let's fix the permissions with chmod(). */
+        if (chmod(u->filename, 0666) < 0)
+            pa_log_warn("chomd('%s'): %s", u->filename, pa_cstrerror(errno));
+    }
+
     if ((u->fd = pa_open_cloexec(u->filename, O_RDWR, 0)) < 0) {
         pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
         goto fail;
index f8284c1..74ec055 100644 (file)
@@ -243,7 +243,13 @@ int pa__init(pa_module *m) {
     if (mkfifo(u->filename, 0666) < 0) {
         pa_log("mkfifo('%s'): %s", u->filename, pa_cstrerror(errno));
         goto fail;
+    } else {
+        /* Our umask is 077, so the pipe won't be created with the requested
+         * permissions. Let's fix the permissions with chmod(). */
+        if (chmod(u->filename, 0666) < 0)
+            pa_log_warn("chomd('%s'): %s", u->filename, pa_cstrerror(errno));
     }
+
     if ((u->fd = pa_open_cloexec(u->filename, O_RDWR, 0)) < 0) {
         pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
         goto fail;