[pulseaudio-commits] 8 commits - configure.ac man/pulse-client.conf.5.xml.in man/pulse-daemon.conf.5.xml.in src/daemon src/Makefile.am src/pulse src/pulsecore

Colin Guthrie colin at kemper.freedesktop.org
Mon Nov 3 07:58:53 PST 2014


 configure.ac                                  |   83 ++++++++++++++++++++------
 man/pulse-client.conf.5.xml.in                |    2 
 man/pulse-daemon.conf.5.xml.in                |    2 
 src/Makefile.am                               |   26 ++++++--
 src/daemon/cmdline.c                          |    2 
 src/daemon/main.c                             |   36 +++++++++--
 src/daemon/start-pulseaudio-x11.in            |    2 
 src/daemon/systemd/user/pulseaudio.service.in |   10 +++
 src/daemon/systemd/user/pulseaudio.socket     |   10 +++
 src/pulse/client-conf.c                       |    4 +
 src/pulse/client.conf.in                      |    2 
 src/pulsecore/log.c                           |   12 +--
 src/pulsecore/log.h                           |    2 
 src/pulsecore/socket-server.c                 |   68 ++++++++++++++-------
 src/pulsecore/socket-util.c                   |   18 +++++
 15 files changed, 214 insertions(+), 65 deletions(-)

New commits:
commit bdbc561619c6af07ebbe11e5ebd78a8101052794
Author: Colin Guthrie <colin at mageia.org>
Date:   Sat Oct 18 19:33:59 2014 +0200

    build-sys: Minor cosmetic tidyup of configure summary

diff --git a/configure.ac b/configure.ac
index 3fa1bc9..26ebd8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1566,9 +1566,10 @@ echo "
         headset backend:           ${BLUETOOTH_HEADSET_BACKEND}
     Enable udev:                   ${ENABLE_UDEV}
       Enable HAL->udev compat:     ${ENABLE_HAL_COMPAT}
-    Enable systemd daemon:         ${ENABLE_SYSTEMD_DAEMON}
-    Enable systemd login:          ${ENABLE_SYSTEMD_LOGIN}
-    Enable systemd journal:        ${ENABLE_SYSTEMD_JOURNAL}
+    Enable systemd
+      Daemon (Socket Activation):  ${ENABLE_SYSTEMD_DAEMON}
+      Login (Session Tracking):    ${ENABLE_SYSTEMD_LOGIN}
+      Journal (Logging):           ${ENABLE_SYSTEMD_JOURNAL}
     Enable TCP Wrappers:           ${ENABLE_TCPWRAP}
     Enable libsamplerate:          ${ENABLE_LIBSAMPLERATE}
     Enable IPv6:                   ${ENABLE_IPV6}

commit 7276faca72e9696d4891daff139aee52509f43bf
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 15:37:33 2014 +0200

    launch: Disable autospawn by default when systemd daemon support is enabled.
    
    When enabled, this method is prefered over pulseaudio's built in
    systems so we should try our best to ensure that it cannot be spawned
    outside of the mechanisms desired.
    
    Packagers should call 'systemctl --global enable pulseaudio.socket' to
    enable the socket for all users, or alternatively ship an enabling
    symlink in /usr/lib/systemd/user/sockets.target.wants/ folder. It may
    also make sense for distributions to add in a ConditionNNN= line to the
    socket unit if they have a downstream mechanism for enabling or
    disabling pulseaudio.
    
    If individual users wish to opt out of this vendor (or administrator)
    decision, they can call 'systemctl --user mask pulseaudio.socket'

diff --git a/configure.ac b/configure.ac
index 23905ad..3fa1bc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1219,6 +1219,9 @@ AS_IF([test "x$enable_systemd_daemon" != "xno"],
 AS_IF([test "x$enable_systemd_daemon" = "xyes" && test "x$HAVE_SYSTEMD_DAEMON" = "x0"],
     [AC_MSG_ERROR([*** Needed systemd daemon support not found])])
 
+AS_IF([test "x$HAVE_SYSTEMD_DAEMON" = "x1"], [ PA_DEFAULT_AUTOSPAWN=no ], [ PA_DEFAULT_AUTOSPAWN=yes ])
+AC_SUBST(PA_DEFAULT_AUTOSPAWN)
+
 AC_SUBST(HAVE_SYSTEMD_DAEMON)
 AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$HAVE_SYSTEMD_DAEMON" = x1])
 AS_IF([test "x$HAVE_SYSTEMD_DAEMON" = "x1"], AC_DEFINE([HAVE_SYSTEMD_DAEMON], 1, [Have SYSTEMDDAEMON?]))
diff --git a/man/pulse-client.conf.5.xml.in b/man/pulse-client.conf.5.xml.in
index 45f02da..7025df7 100644
--- a/man/pulse-client.conf.5.xml.in
+++ b/man/pulse-client.conf.5.xml.in
@@ -69,7 +69,7 @@ USA.
 
     <option>
       <p><opt>autospawn=</opt> Autospawn a PulseAudio daemon when
-      needed. Takes a boolean value, defaults to <opt>yes</opt>.</p>
+      needed. Takes a boolean value, defaults to <opt>@PA_DEFAULT_AUTOSPAWN@</opt>.</p>
     </option>
 
     <option>
diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c
index e0acc23..80ddae0 100644
--- a/src/pulse/client-conf.c
+++ b/src/pulse/client-conf.c
@@ -65,7 +65,11 @@ static const pa_client_conf default_conf = {
     .cookie_from_x11_valid = false,
     .cookie_file_from_application = NULL,
     .cookie_file_from_client_conf = NULL,
+#ifdef HAVE_SYSTEMD_DAEMON
+    .autospawn = false,
+#else
     .autospawn = true,
+#endif
     .disable_shm = false,
     .shm_size = 0,
     .auto_connect_localhost = false,
diff --git a/src/pulse/client.conf.in b/src/pulse/client.conf.in
index 17753b0..446e22a 100644
--- a/src/pulse/client.conf.in
+++ b/src/pulse/client.conf.in
@@ -24,7 +24,7 @@
 ; default-server =
 ; default-dbus-server =
 
-; autospawn = yes
+; autospawn = @PA_DEFAULT_AUTOSPAWN@
 ; daemon-binary = @PA_BINARY@
 ; extra-arguments = --log-target=syslog
 

commit e542e810041efef6497597ee55b4c7d5c349ba3e
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 15:10:14 2014 +0200

    launch: Add systemd units for launching pulseaudio user instances

diff --git a/configure.ac b/configure.ac
index 25cb207..23905ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1203,6 +1203,13 @@ AS_IF([test "x$HAVE_SYSTEMD" = "x1"],
         HAVE_SYSTEMD_JOURNAL=1
     ])
 
+AC_ARG_WITH([systemduserunitdir],
+        AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user service files]),
+        [], [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)])
+if test "x$with_systemduserunitdir" != xno; then
+        AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
+fi
+
 #### systemd daemon support (optional) ####
 
 AS_IF([test "x$enable_systemd_daemon" != "xno"],
@@ -1458,6 +1465,10 @@ AC_CONFIG_FILES([src/default.pa:src/daemon/default.pa.in],
     [m4 src/default.pa > src/default.pa.gen && mv src/default.pa.gen src/default.pa])
 AC_CONFIG_FILES([src/system.pa:src/daemon/system.pa.in],
     [m4 src/system.pa > src/system.pa.gen && mv src/system.pa.gen src/system.pa])
+AS_IF([test "$HAVE_SYSTEMD_DAEMON" = "x1"],
+    [
+        AC_CONFIG_FILES([src/pulseaudio.service:src/daemon/systemd/user/pulseaudio.service.in])
+    ])
 
 # CMake related ProjectConfig files
 PA_LIBDIR="$libdir"
diff --git a/src/Makefile.am b/src/Makefile.am
index c037db7..a4a66c5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,8 @@ EXTRA_DIST = \
 		depmod.py \
 		daemon/esdcompat.in \
 		daemon/start-pulseaudio-x11.in \
+		daemon/systemd/user/pulseaudio.service.in \
+		daemon/systemd/user/pulseaudio.socket \
 		utils/padsp.in \
 		utils/qpaeq \
 		modules/module-defs.h.m4 \
@@ -217,6 +219,14 @@ pax11publish_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
 pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINOR@.la $(X11_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
+if HAVE_SYSTEMD_DAEMON
+
+systemduserunit_DATA = \
+    pulseaudio.service \
+    daemon/systemd/user/pulseaudio.socket
+
+endif
+
 ###################################
 #         Test programs           #
 ###################################
@@ -2152,7 +2162,7 @@ module_rygel_media_server_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 ###################################
 
 CLEANFILES += daemon/pulseaudio.desktop
-DISTCLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11
+DISTCLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 pulseaudio.service
 
 if OS_IS_WIN32
 SYMLINK_PROGRAM=cd $(DESTDIR)$(bindir) && cp
diff --git a/src/daemon/systemd/user/pulseaudio.service.in b/src/daemon/systemd/user/pulseaudio.service.in
new file mode 100644
index 0000000..e08ff1e
--- /dev/null
+++ b/src/daemon/systemd/user/pulseaudio.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Sound Service
+
+[Service]
+ExecStart=@PA_BINARY@ --daemonize=no
+Restart=on-failure
+
+[Install]
+Also=pulseaudio.socket
+WantedBy=default.target
diff --git a/src/daemon/systemd/user/pulseaudio.socket b/src/daemon/systemd/user/pulseaudio.socket
new file mode 100644
index 0000000..332ece8
--- /dev/null
+++ b/src/daemon/systemd/user/pulseaudio.socket
@@ -0,0 +1,10 @@
+[Unit]
+Description=Sound System
+
+[Socket]
+Priority=6
+Backlog=5
+ListenStream=%t/pulse/native
+
+[Install]
+WantedBy=sockets.target

commit 42156d2b5ac797e5f28f8d0d38b691053f3f6fc7
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 14:43:18 2014 +0200

    launch: Avoid specifically starting PA and rely on autospawn/socket activation
    
    This --start is patched out in several downstreams to allow users to easily
    disable PA by simply disabling autospawn.
    
    If autospawn is enabled, then the first pactl command will start it and if not
    it will fail and the script will exit.
    
    When switching to systemd socket activation, we very much do not want to
    start PA manually here. We could replace it with a
      systemctl --user start pulseaudio
    but really it just makes sense to rely on the socket activation as this
    should apply equally to non-systemd setups which use PA's own autospawn.

diff --git a/src/daemon/start-pulseaudio-x11.in b/src/daemon/start-pulseaudio-x11.in
index 620e50f..63ed740 100755
--- a/src/daemon/start-pulseaudio-x11.in
+++ b/src/daemon/start-pulseaudio-x11.in
@@ -19,8 +19,6 @@
 
 set -e
 
- at PA_BINARY@ --start "$@"
-
 if [ x"$DISPLAY" != x ] ; then
 
     @PACTL_BINARY@ load-module module-x11-publish "display=$DISPLAY" > /dev/null

commit 467b4b9bee66257da7ce51c1158f9fe2178daac1
Author: Colin Guthrie <colin at mageia.org>
Date:   Thu Oct 16 10:05:19 2014 +0100

    socket-server: Add support for systemd socket activation.
    
    This adds support to module-native-protocol-unix to take over already
    listening sockets passed in via socket activation (e.g. from systemd)
    
    Most of the code is isolated to socket-server but some cleanup code also
    had to be tweaked to ensure we do not overzealously close open fds.

diff --git a/configure.ac b/configure.ac
index 98a3ee2..25cb207 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1180,6 +1180,9 @@ ORC_CHECK([0.4.11])
 
 #### systemd support (optional) ####
 
+AC_ARG_ENABLE([systemd-daemon],
+    AS_HELP_STRING([--disable-systemd-daemon],[Disable optional systemd daemon (socket activation) support]))
+
 AC_ARG_ENABLE([systemd-login],
     AS_HELP_STRING([--disable-systemd-login],[Disable optional systemd login support]))
 
@@ -1189,16 +1192,30 @@ AC_ARG_ENABLE([systemd-journal],
 # Newer systemd's combine their subcomponent libraries into one
 # If it exists, we should use it for the further checks
 
-AS_IF([test "x$enable_systemd_login" != "xno" || test "x$enable_systemd_journal" != "xno"],
+AS_IF([test "x$enable_systemd_daemon" != "xno" || test "x$enable_systemd_login" != "xno" || test "x$enable_systemd_journal" != "xno"],
     [PKG_CHECK_MODULES(SYSTEMD, [ libsystemd ], HAVE_SYSTEMD=1, HAVE_SYSTEMD=0)],
     HAVE_SYSTEMD=0)
 
 AS_IF([test "x$HAVE_SYSTEMD" = "x1"],
     [
+        HAVE_SYSTEMD_DAEMON=1
         HAVE_SYSTEMD_LOGIN=1
         HAVE_SYSTEMD_JOURNAL=1
     ])
 
+#### systemd daemon support (optional) ####
+
+AS_IF([test "x$enable_systemd_daemon" != "xno"],
+    [AS_IF([test "x$HAVE_SYSTEMD_DAEMON" != "x1"], [PKG_CHECK_MODULES(SYSTEMDDAEMON, [ libsystemd-daemon ], HAVE_SYSTEMD_DAEMON=1, HAVE_SYSTEMD_DAEMON=0)])],
+    HAVE_SYSTEMD_DAEMON=0)
+
+AS_IF([test "x$enable_systemd_daemon" = "xyes" && test "x$HAVE_SYSTEMD_DAEMON" = "x0"],
+    [AC_MSG_ERROR([*** Needed systemd daemon support not found])])
+
+AC_SUBST(HAVE_SYSTEMD_DAEMON)
+AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$HAVE_SYSTEMD_DAEMON" = x1])
+AS_IF([test "x$HAVE_SYSTEMD_DAEMON" = "x1"], AC_DEFINE([HAVE_SYSTEMD_DAEMON], 1, [Have SYSTEMDDAEMON?]))
+
 #### systemd login support (optional) ####
 
 AS_IF([test "x$enable_systemd_login" != "xno"],
@@ -1473,6 +1490,7 @@ AS_IF([test "x$HAVE_LIRC" = "x1"], ENABLE_LIRC=yes, ENABLE_LIRC=no)
 AS_IF([test "x$HAVE_XEN" = "x1"], ENABLE_XEN=yes, ENABLE_XEN=no)
 AS_IF([test "x$HAVE_DBUS" = "x1"], ENABLE_DBUS=yes, ENABLE_DBUS=no)
 AS_IF([test "x$HAVE_UDEV" = "x1"], ENABLE_UDEV=yes, ENABLE_UDEV=no)
+AS_IF([test "x$HAVE_SYSTEMD_DAEMON" = "x1"], ENABLE_SYSTEMD_DAEMON=yes, ENABLE_SYSTEMD_DAEMON=no)
 AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], ENABLE_SYSTEMD_LOGIN=yes, ENABLE_SYSTEMD_LOGIN=no)
 AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], ENABLE_SYSTEMD_JOURNAL=yes, ENABLE_SYSTEMD_JOURNAL=no)
 AS_IF([test "x$HAVE_BLUEZ_4" = "x1"], ENABLE_BLUEZ_4=yes, ENABLE_BLUEZ_4=no)
@@ -1534,6 +1552,7 @@ echo "
         headset backend:           ${BLUETOOTH_HEADSET_BACKEND}
     Enable udev:                   ${ENABLE_UDEV}
       Enable HAL->udev compat:     ${ENABLE_HAL_COMPAT}
+    Enable systemd daemon:         ${ENABLE_SYSTEMD_DAEMON}
     Enable systemd login:          ${ENABLE_SYSTEMD_LOGIN}
     Enable systemd journal:        ${ENABLE_SYSTEMD_JOURNAL}
     Enable TCP Wrappers:           ${ENABLE_TCPWRAP}
diff --git a/src/Makefile.am b/src/Makefile.am
index 71e2034..c037db7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -706,6 +706,10 @@ libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(X11_CFLAGS)
 libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(X11_LIBS)
 endif
 
+if HAVE_SYSTEMD_DAEMON
+libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(SYSTEMD_FLAGS) $(SYSTEMDDAEMON_FLAGS)
+libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(SYSTEMD_LIBS) $(SYSTEMDDAEMON_LIBS)
+endif
 if HAVE_SYSTEMD_JOURNAL
 libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(SYSTEMD_FLAGS) $(SYSTEMDJOURNAL_FLAGS)
 libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(SYSTEMD_LIBS) $(SYSTEMDJOURNAL_LIBS)
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 372f4e1..0ffc7bd 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -58,6 +58,10 @@
 #include <dbus/dbus.h>
 #endif
 
+#ifdef HAVE_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
 #include <pulse/client-conf.h>
 #include <pulse/mainloop.h>
 #include <pulse/mainloop-signal.h>
@@ -374,7 +378,7 @@ int main(int argc, char *argv[]) {
     int r = 0, retval = 1, d = 0;
     bool valid_pid_file = false;
     bool ltdl_init = false;
-    int passed_fd = -1;
+    int n_fds = 0, *passed_fds = NULL;
     const char *e;
 #ifdef HAVE_FORK
     int daemon_pipe[2] = { -1, -1 };
@@ -431,11 +435,28 @@ int main(int argc, char *argv[]) {
     }
 #endif
 
-    if ((e = getenv("PULSE_PASSED_FD"))) {
-        passed_fd = atoi(e);
+#ifdef HAVE_SYSTEMD_DAEMON
+    n_fds = sd_listen_fds(0);
+    if (n_fds > 0) {
+        int i = n_fds;
 
-        if (passed_fd <= 2)
-            passed_fd = -1;
+        passed_fds = pa_xnew(int, n_fds+2);
+        passed_fds[n_fds] = passed_fds[n_fds+1] = -1;
+        while (i--)
+            passed_fds[i] = SD_LISTEN_FDS_START + i;
+    }
+#endif
+
+    if (!passed_fds) {
+        n_fds = 0;
+        passed_fds = pa_xnew(int, 2);
+        passed_fds[0] = passed_fds[1] = -1;
+    }
+
+    if ((e = getenv("PULSE_PASSED_FD"))) {
+        int passed_fd = atoi(e);
+        if (passed_fd > 2)
+            passed_fds[n_fds] = passed_fd;
     }
 
     /* We might be autospawned, in which case have no idea in which
@@ -444,7 +465,8 @@ int main(int argc, char *argv[]) {
 
     pa_reset_personality();
     pa_drop_root();
-    pa_close_all(passed_fd, -1);
+    pa_close_allv(passed_fds);
+    pa_xfree(passed_fds);
     pa_reset_sigs(-1);
     pa_unblock_sigs(-1);
     pa_reset_priority();
diff --git a/src/pulsecore/socket-server.c b/src/pulsecore/socket-server.c
index 25a2f8a..2138cbc 100644
--- a/src/pulsecore/socket-server.c
+++ b/src/pulsecore/socket-server.c
@@ -56,6 +56,10 @@ int deny_severity = LOG_WARNING;
 
 #endif /* HAVE_LIBWRAP */
 
+#ifdef HAVE_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
 #include <pulse/xmalloc.h>
 #include <pulse/util.h>
 
@@ -74,6 +78,7 @@ struct pa_socket_server {
     PA_REFCNT_DECLARE;
     int fd;
     char *filename;
+    bool activated;
     char *tcpwrap_service;
 
     pa_socket_server_on_connection_cb_t on_connection;
@@ -174,43 +179,63 @@ pa_socket_server* pa_socket_server_ref(pa_socket_server *s) {
 
 pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename) {
     int fd = -1;
+    bool activated = false;
     struct sockaddr_un sa;
     pa_socket_server *s;
 
     pa_assert(m);
     pa_assert(filename);
 
-    if ((fd = pa_socket_cloexec(PF_UNIX, SOCK_STREAM, 0)) < 0) {
-        pa_log("socket(): %s", pa_cstrerror(errno));
-        goto fail;
+#ifdef HAVE_SYSTEMD_DAEMON
+    {
+        int n = sd_listen_fds(0);
+        if (n > 0) {
+            for (int i = 0; i < n; ++i) {
+                if (sd_is_socket_unix(SD_LISTEN_FDS_START + i, SOCK_STREAM, 1, filename, 0) > 0) {
+                    fd = SD_LISTEN_FDS_START + i;
+                    activated = true;
+                    pa_log_info("Found socket activation socket for '%s' \\o/", filename);
+                    break;
+                }
+            }
+        }
     }
+#endif
 
-    memset(&sa, 0, sizeof(sa));
-    sa.sun_family = AF_UNIX;
-    pa_strlcpy(sa.sun_path, filename, sizeof(sa.sun_path));
+    if (fd < 0) {
+        if ((fd = pa_socket_cloexec(PF_UNIX, SOCK_STREAM, 0)) < 0) {
+            pa_log("socket(PF_UNIX): %s", pa_cstrerror(errno));
+            goto fail;
+        }
 
-    pa_make_socket_low_delay(fd);
+        memset(&sa, 0, sizeof(sa));
+        sa.sun_family = AF_UNIX;
+        pa_strlcpy(sa.sun_path, filename, sizeof(sa.sun_path));
 
-    if (bind(fd, (struct sockaddr*) &sa, (socklen_t) SUN_LEN(&sa)) < 0) {
-        pa_log("bind(): %s", pa_cstrerror(errno));
-        goto fail;
-    }
+        pa_make_socket_low_delay(fd);
 
-    /* Allow access from all clients. Sockets like this one should
-     * always be put inside a directory with proper access rights,
-     * because not all OS check the access rights on the socket
-     * inodes. */
-    chmod(filename, 0777);
+        if (bind(fd, (struct sockaddr*) &sa, (socklen_t) SUN_LEN(&sa)) < 0) {
+            pa_log("bind(): %s", pa_cstrerror(errno));
+            goto fail;
+        }
 
-    if (listen(fd, 5) < 0) {
-        pa_log("listen(): %s", pa_cstrerror(errno));
-        goto fail;
+        /* Allow access from all clients. Sockets like this one should
+        * always be put inside a directory with proper access rights,
+        * because not all OS check the access rights on the socket
+        * inodes. */
+        chmod(filename, 0777);
+
+        if (listen(fd, 5) < 0) {
+            pa_log("listen(): %s", pa_cstrerror(errno));
+            goto fail;
+        }
     }
 
     pa_assert_se(s = pa_socket_server_new(m, fd));
 
     s->filename = pa_xstrdup(filename);
     s->type = SOCKET_SERVER_UNIX;
+    s->activated = activated;
 
     return s;
 
@@ -421,10 +446,9 @@ pa_socket_server* pa_socket_server_new_ipv6_string(pa_mainloop_api *m, const cha
 static void socket_server_free(pa_socket_server*s) {
     pa_assert(s);
 
-    if (s->filename) {
+    if (!s->activated && s->filename)
         unlink(s->filename);
-        pa_xfree(s->filename);
-    }
+    pa_xfree(s->filename);
 
     pa_close(s->fd);
 
diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index e1c0b55..ccb9442 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -52,6 +52,9 @@
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
+#ifdef HAVE_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
 
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
@@ -255,6 +258,21 @@ int pa_unix_socket_remove_stale(const char *fn) {
 
     pa_assert(fn);
 
+#ifdef HAVE_SYSTEMD_DAEMON
+    {
+        int n = sd_listen_fds(0);
+        if (n > 0) {
+            for (int i = 0; i < n; ++i) {
+                if (sd_is_socket_unix(SD_LISTEN_FDS_START + i, SOCK_STREAM, 1, fn, 0) > 0) {
+                    /* This is a socket activated socket, therefore do not consider
+                    * it stale. */
+                    return 0;
+                }
+            }
+        }
+    }
+#endif
+
     if ((r = pa_unix_socket_is_stale(fn)) < 0)
         return errno != ENOENT ? -1 : 0;
 

commit fb1ca6f0c1799259bad85bee8d984d62871584b9
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 13:51:25 2014 +0200

    build-sys: Add support for newer systemd without compatibility libs
    
    In newer versions of systemd some libraries were combined for the sake of
    general simplicity.
    
    This change checks against the newer name first and avoids separate pkgconfig
    checks if it's found. We probably want to keep support for the older library
    names for some time. systemd does allow for the shipping of compatibility
    pkgconfig files to not break downstream code like ourselves which is why this
    likely hasn't been "fixed" until now.
    
    With this change we no longer rely on systemd having been built with those
    compatibility pkgconfig files.

diff --git a/configure.ac b/configure.ac
index c7595ae..98a3ee2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1178,13 +1178,31 @@ AM_CONDITIONAL([HAVE_GCOV], [test "x$HAVE_GCOV" = x1])
 
 ORC_CHECK([0.4.11])
 
-#### systemd login support (optional) ####
+#### systemd support (optional) ####
 
 AC_ARG_ENABLE([systemd-login],
     AS_HELP_STRING([--disable-systemd-login],[Disable optional systemd login support]))
 
+AC_ARG_ENABLE([systemd-journal],
+    AS_HELP_STRING([--disable-systemd-journal],[Disable optional systemd journal support]))
+
+# Newer systemd's combine their subcomponent libraries into one
+# If it exists, we should use it for the further checks
+
+AS_IF([test "x$enable_systemd_login" != "xno" || test "x$enable_systemd_journal" != "xno"],
+    [PKG_CHECK_MODULES(SYSTEMD, [ libsystemd ], HAVE_SYSTEMD=1, HAVE_SYSTEMD=0)],
+    HAVE_SYSTEMD=0)
+
+AS_IF([test "x$HAVE_SYSTEMD" = "x1"],
+    [
+        HAVE_SYSTEMD_LOGIN=1
+        HAVE_SYSTEMD_JOURNAL=1
+    ])
+
+#### systemd login support (optional) ####
+
 AS_IF([test "x$enable_systemd_login" != "xno"],
-    [PKG_CHECK_MODULES(SYSTEMDLOGIN, [ libsystemd-login ], HAVE_SYSTEMD_LOGIN=1, HAVE_SYSTEMD_LOGIN=0)],
+    [AS_IF([test "x$HAVE_SYSTEMD_LOGIN" != "x1"], [PKG_CHECK_MODULES(SYSTEMDLOGIN, [ libsystemd-login ], HAVE_SYSTEMD_LOGIN=1, HAVE_SYSTEMD_LOGIN=0)])],
     HAVE_SYSTEMD_LOGIN=0)
 
 AS_IF([test "x$enable_systemd_login" = "xyes" && test "x$HAVE_SYSTEMD_LOGIN" = "x0"],
@@ -1196,11 +1214,8 @@ AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], AC_DEFINE([HAVE_SYSTEMD_LOGIN], 1, [
 
 #### systemd journal support (optional) ####
 
-AC_ARG_ENABLE([systemd-journal],
-    AS_HELP_STRING([--disable-systemd-journal],[Disable optional systemd journal support]))
-
 AS_IF([test "x$enable_systemd_journal" != "xno"],
-    [PKG_CHECK_MODULES(SYSTEMDJOURNAL, [ libsystemd-journal ], HAVE_SYSTEMD_JOURNAL=1, HAVE_SYSTEMD_JOURNAL=0)],
+    [AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" != "x1"], [PKG_CHECK_MODULES(SYSTEMDJOURNAL, [ libsystemd-journal ], HAVE_SYSTEMD_JOURNAL=1, HAVE_SYSTEMD_JOURNAL=0)])],
     HAVE_SYSTEMD_JOURNAL=0)
 
 AS_IF([test "x$enable_systemd_journal" = "xyes" && test "x$HAVE_SYSTEMD_JOURNAL" = "x0"],
diff --git a/src/Makefile.am b/src/Makefile.am
index d264209..71e2034 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -707,8 +707,8 @@ libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(X11_LIBS)
 endif
 
 if HAVE_SYSTEMD_JOURNAL
-libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(SYSTEMDJOURNAL_FLAGS)
-libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(SYSTEMDJOURNAL_LIBS)
+libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(SYSTEMD_FLAGS) $(SYSTEMDJOURNAL_FLAGS)
+libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(SYSTEMD_LIBS) $(SYSTEMDJOURNAL_LIBS)
 endif
 
 # proplist-util.h uses these header files, but not the library itself!
@@ -2061,8 +2061,8 @@ module_console_kit_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_systemd_login_la_SOURCES = modules/module-systemd-login.c
 module_systemd_login_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_systemd_login_la_LIBADD = $(MODULE_LIBADD) $(SYSTEMDLOGIN_LIBS)
-module_systemd_login_la_CFLAGS = $(AM_CFLAGS) $(SYSTEMDLOGIN_CFLAGS)
+module_systemd_login_la_LIBADD = $(MODULE_LIBADD) $(SYSTEMD_LIBS) $(SYSTEMDLOGIN_LIBS)
+module_systemd_login_la_CFLAGS = $(AM_CFLAGS) $(SYSTEMD_CFLAGS) $(SYSTEMDLOGIN_CFLAGS)
 
 # GConf support
 module_gconf_la_SOURCES = modules/gconf/module-gconf.c

commit f7da58b73fd9f324d5a96746a2cdfc05eb37047a
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 13:32:03 2014 +0200

    build-sys: Clarify some systemd sub-component variable/define names.
    
    We currently use the term SYSTEMD when referring to libsystemd-login
    and JOURNAL when referring to libsystemd-journal.
    
    I will be shortly adding support for libsystemd-daemon and in
    preparation I figured it would be a good idea to clarify the names
    used currently before adding another!

diff --git a/configure.ac b/configure.ac
index f165eb4..c7595ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1178,29 +1178,29 @@ AM_CONDITIONAL([HAVE_GCOV], [test "x$HAVE_GCOV" = x1])
 
 ORC_CHECK([0.4.11])
 
-#### systemd support (optional) ####
+#### systemd login support (optional) ####
 
-AC_ARG_ENABLE([systemd],
-    AS_HELP_STRING([--disable-systemd],[Disable optional systemd support]))
+AC_ARG_ENABLE([systemd-login],
+    AS_HELP_STRING([--disable-systemd-login],[Disable optional systemd login support]))
 
-AS_IF([test "x$enable_systemd" != "xno"],
-    [PKG_CHECK_MODULES(SYSTEMD, [ libsystemd-login ], HAVE_SYSTEMD=1, HAVE_SYSTEMD=0)],
-    HAVE_SYSTEMD=0)
+AS_IF([test "x$enable_systemd_login" != "xno"],
+    [PKG_CHECK_MODULES(SYSTEMDLOGIN, [ libsystemd-login ], HAVE_SYSTEMD_LOGIN=1, HAVE_SYSTEMD_LOGIN=0)],
+    HAVE_SYSTEMD_LOGIN=0)
 
-AS_IF([test "x$enable_systemd" = "xyes" && test "x$HAVE_SYSTEMD" = "x0"],
-    [AC_MSG_ERROR([*** Needed systemd support not found])])
+AS_IF([test "x$enable_systemd_login" = "xyes" && test "x$HAVE_SYSTEMD_LOGIN" = "x0"],
+    [AC_MSG_ERROR([*** Needed systemd login support not found])])
 
-AC_SUBST(HAVE_SYSTEMD)
-AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$HAVE_SYSTEMD" = x1])
-AS_IF([test "x$HAVE_SYSTEMD" = "x1"], AC_DEFINE([HAVE_SYSTEMD], 1, [Have SYSTEMD?]))
+AC_SUBST(HAVE_SYSTEMD_LOGIN)
+AM_CONDITIONAL([HAVE_SYSTEMD_LOGIN], [test "x$HAVE_SYSTEMD_LOGIN" = x1])
+AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], AC_DEFINE([HAVE_SYSTEMD_LOGIN], 1, [Have SYSTEMDLOGIN?]))
 
-#### journal support (optional) ####
+#### systemd journal support (optional) ####
 
 AC_ARG_ENABLE([systemd-journal],
     AS_HELP_STRING([--disable-systemd-journal],[Disable optional systemd journal support]))
 
 AS_IF([test "x$enable_systemd_journal" != "xno"],
-    [PKG_CHECK_MODULES(JOURNAL, [ libsystemd-journal ], HAVE_SYSTEMD_JOURNAL=1, HAVE_SYSTEMD_JOURNAL=0)],
+    [PKG_CHECK_MODULES(SYSTEMDJOURNAL, [ libsystemd-journal ], HAVE_SYSTEMD_JOURNAL=1, HAVE_SYSTEMD_JOURNAL=0)],
     HAVE_SYSTEMD_JOURNAL=0)
 
 AS_IF([test "x$enable_systemd_journal" = "xyes" && test "x$HAVE_SYSTEMD_JOURNAL" = "x0"],
@@ -1208,7 +1208,7 @@ AS_IF([test "x$enable_systemd_journal" = "xyes" && test "x$HAVE_SYSTEMD_JOURNAL"
 
 AC_SUBST(HAVE_SYSTEMD_JOURNAL)
 AM_CONDITIONAL([HAVE_SYSTEMD_JOURNAL], [test "x$HAVE_SYSTEMD_JOURNAL" = x1])
-AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], AC_DEFINE([HAVE_JOURNAL], 1, [Have JOURNAL?]))
+AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], AC_DEFINE([HAVE_SYSTEMD_JOURNAL], 1, [Have SYSTEMDJOURNAL?]))
 
 #### Build and Install man pages ####
 
@@ -1458,7 +1458,7 @@ AS_IF([test "x$HAVE_LIRC" = "x1"], ENABLE_LIRC=yes, ENABLE_LIRC=no)
 AS_IF([test "x$HAVE_XEN" = "x1"], ENABLE_XEN=yes, ENABLE_XEN=no)
 AS_IF([test "x$HAVE_DBUS" = "x1"], ENABLE_DBUS=yes, ENABLE_DBUS=no)
 AS_IF([test "x$HAVE_UDEV" = "x1"], ENABLE_UDEV=yes, ENABLE_UDEV=no)
-AS_IF([test "x$HAVE_SYSTEMD" = "x1"], ENABLE_SYSTEMD=yes, ENABLE_SYSTEMD=no)
+AS_IF([test "x$HAVE_SYSTEMD_LOGIN" = "x1"], ENABLE_SYSTEMD_LOGIN=yes, ENABLE_SYSTEMD_LOGIN=no)
 AS_IF([test "x$HAVE_SYSTEMD_JOURNAL" = "x1"], ENABLE_SYSTEMD_JOURNAL=yes, ENABLE_SYSTEMD_JOURNAL=no)
 AS_IF([test "x$HAVE_BLUEZ_4" = "x1"], ENABLE_BLUEZ_4=yes, ENABLE_BLUEZ_4=no)
 AS_IF([test "x$HAVE_BLUEZ_5" = "x1"], ENABLE_BLUEZ_5=yes, ENABLE_BLUEZ_5=no)
@@ -1519,7 +1519,7 @@ echo "
         headset backend:           ${BLUETOOTH_HEADSET_BACKEND}
     Enable udev:                   ${ENABLE_UDEV}
       Enable HAL->udev compat:     ${ENABLE_HAL_COMPAT}
-    Enable systemd login:          ${ENABLE_SYSTEMD}
+    Enable systemd login:          ${ENABLE_SYSTEMD_LOGIN}
     Enable systemd journal:        ${ENABLE_SYSTEMD_JOURNAL}
     Enable TCP Wrappers:           ${ENABLE_TCPWRAP}
     Enable libsamplerate:          ${ENABLE_LIBSAMPLERATE}
diff --git a/src/Makefile.am b/src/Makefile.am
index 4219ece..d264209 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -707,8 +707,8 @@ libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(X11_LIBS)
 endif
 
 if HAVE_SYSTEMD_JOURNAL
-libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(JOURNAL_FLAGS)
-libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(JOURNAL_LIBS)
+libpulsecommon_ at PA_MAJORMINOR@_la_CFLAGS += $(SYSTEMDJOURNAL_FLAGS)
+libpulsecommon_ at PA_MAJORMINOR@_la_LDFLAGS += $(SYSTEMDJOURNAL_LIBS)
 endif
 
 # proplist-util.h uses these header files, but not the library itself!
@@ -1353,7 +1353,7 @@ modlibexec_LTLIBRARIES += \
 		module-udev-detect.la
 endif
 
-if HAVE_SYSTEMD
+if HAVE_SYSTEMD_LOGIN
 modlibexec_LTLIBRARIES += \
 		module-systemd-login.la
 endif
@@ -2061,8 +2061,8 @@ module_console_kit_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_systemd_login_la_SOURCES = modules/module-systemd-login.c
 module_systemd_login_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_systemd_login_la_LIBADD = $(MODULE_LIBADD) $(SYSTEMD_LIBS)
-module_systemd_login_la_CFLAGS = $(AM_CFLAGS) $(SYSTEMD_CFLAGS)
+module_systemd_login_la_LIBADD = $(MODULE_LIBADD) $(SYSTEMDLOGIN_LIBS)
+module_systemd_login_la_CFLAGS = $(AM_CFLAGS) $(SYSTEMDLOGIN_CFLAGS)
 
 # GConf support
 module_gconf_la_SOURCES = modules/gconf/module-gconf.c
diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index 68579c5..2ffc61f 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -323,7 +323,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_LOG_TARGET:
                 if (pa_daemon_conf_set_log_target(conf, optarg) < 0) {
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
                     pa_log(_("Invalid log target: use either 'syslog', 'journal','stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>'."));
 #else
                     pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>'."));
diff --git a/src/daemon/main.c b/src/daemon/main.c
index d2a8a8a..372f4e1 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -788,7 +788,7 @@ int main(int argc, char *argv[]) {
 #endif
 
         if (!conf->log_target) {
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
             pa_log_target target = { .type = PA_LOG_JOURNAL, .file = NULL };
 #else
             pa_log_target target = { .type = PA_LOG_SYSLOG, .file = NULL };
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index cf96dce..9e29c78 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -40,7 +40,7 @@
 #include <syslog.h>
 #endif
 
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
 #include <systemd/sd-journal.h>
 #endif
 
@@ -96,7 +96,7 @@ static const int level_to_syslog[] = {
 
 /* These are actually equivalent to the syslog ones
  * but we don't want to depend on syslog.h */
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
 static const int level_to_journal[] = {
     [PA_LOG_ERROR]  = 3,
     [PA_LOG_WARN]   = 4,
@@ -145,7 +145,7 @@ int pa_log_set_target(pa_log_target *t) {
     switch (t->type) {
         case PA_LOG_STDERR:
         case PA_LOG_SYSLOG:
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
         case PA_LOG_JOURNAL:
 #endif
         case PA_LOG_NULL:
@@ -488,7 +488,7 @@ void pa_log_levelv_meta(
                 break;
 #endif
 
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
             case PA_LOG_JOURNAL:
                 if (sd_journal_send("MESSAGE=%s", t,
                                 "PRIORITY=%i", level_to_journal[level],
@@ -619,7 +619,7 @@ pa_log_target *pa_log_parse_target(const char *string) {
         t = pa_log_target_new(PA_LOG_STDERR, NULL);
     else if (pa_streq(string, "syslog"))
         t = pa_log_target_new(PA_LOG_SYSLOG, NULL);
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
     else if (pa_streq(string, "journal"))
         t = pa_log_target_new(PA_LOG_JOURNAL, NULL);
 #endif
@@ -647,7 +647,7 @@ char *pa_log_target_to_string(const pa_log_target *t) {
         case PA_LOG_SYSLOG:
             string = pa_xstrdup("syslog");
             break;
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
         case PA_LOG_JOURNAL:
             string = pa_xstrdup("journal");
             break;
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 5e9611d..14ae857 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -35,7 +35,7 @@
 typedef enum pa_log_target_type {
     PA_LOG_STDERR,      /* default */
     PA_LOG_SYSLOG,
-#ifdef HAVE_JOURNAL
+#ifdef HAVE_SYSTEMD_JOURNAL
     PA_LOG_JOURNAL,     /* systemd journal */
 #endif
     PA_LOG_NULL,        /* to /dev/null */

commit e7755291670c595129657d3a07634d6ad881a76c
Author: Colin Guthrie <colin at mageia.org>
Date:   Fri Oct 17 13:09:14 2014 +0200

    man: Fix XDG_RUNTIME_DIR variable reference.

diff --git a/man/pulse-daemon.conf.5.xml.in b/man/pulse-daemon.conf.5.xml.in
index 8bd076d..754312e 100644
--- a/man/pulse-daemon.conf.5.xml.in
+++ b/man/pulse-daemon.conf.5.xml.in
@@ -124,7 +124,7 @@ USA.
 
     <option>
       <p><opt>use-pid-file=</opt> Create a PID file in the runtime directory
-      (<file>$XDG_RUNTIMEDIR/pulse/pid</file>). If this is enabled you may
+      (<file>$XDG_RUNTIME_DIR/pulse/pid</file>). If this is enabled you may
       use commands like <opt>--kill</opt> or <opt>--check</opt>. If
       you are planning to start more than one PulseAudio process per
       user, you better disable this option since it effectively



More information about the pulseaudio-commits mailing list