1From babec3a50dd710d26b72f6c6d43bd79b04e954a6 Mon Sep 17 00:00:00 2001 2From: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> 3Date: Tue, 28 Apr 2015 14:32:43 +0300 4Subject: [PATCH] client-conf: Add allow-autospawn-for-root 5 6Usually autospawning for root is a bad idea, since it can easily 7interfere with other users' PulseAudio instances, but in embedded 8environments where only root exists, autospawning is fine. 9 10Upstream-Status: Denied [Upstream hasn't so far been convinced that 11this feature is needed. The view is that running the graphical session 12as root doesn't make sense even on embedded systems, or if it does, 13running PulseAudio in the system mode should be a good solution for 14that use case. If someone can prove otherwise, the patch would 15probably be accepted.] 16 17Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> 18--- 19 man/pulse-client.conf.5.xml.in | 9 +++++++++ 20 src/pulse/client-conf.c | 1 + 21 src/pulse/client-conf.h | 1 + 22 src/pulse/client.conf.in | 1 + 23 src/pulse/context.c | 2 +- 24 5 files changed, 13 insertions(+), 1 deletion(-) 25 26diff --git a/man/pulse-client.conf.5.xml.in b/man/pulse-client.conf.5.xml.in 27index b88898c..e737c96 100644 28--- a/man/pulse-client.conf.5.xml.in 29+++ b/man/pulse-client.conf.5.xml.in 30@@ -82,6 +82,15 @@ License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 31 </option> 32 33 <option> 34+ <p><opt>allow-autospawn-for-root=</opt> Allow autospawning also for root. 35+ Takes a boolean value, defaults to <opt>no</opt>. If the <opt>autospawn 36+ </opt> option is disabled, this option has no effect. Autospawning for 37+ root is disabled by default, because running PulseAudio as root will 38+ interfere with regular users' PulseAudio instances. This option should be 39+ enabled only in environments where there are no regular users at all.</p> 40+ </option> 41+ 42+ <option> 43 <p><opt>daemon-binary=</opt> Path to the PulseAudio daemon to 44 run when autospawning. Defaults to a path configured at compile 45 time.</p> 46diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c 47index a3c9486..9f68ee5 100644 48--- a/src/pulse/client-conf.c 49+++ b/src/pulse/client-conf.c 50@@ -138,6 +138,7 @@ void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_e 51 { "default-server", pa_config_parse_string, &c->default_server, NULL }, 52 { "default-dbus-server", pa_config_parse_string, &c->default_dbus_server, NULL }, 53 { "autospawn", pa_config_parse_bool, &c->autospawn, NULL }, 54+ { "allow-autospawn-for-root", pa_config_parse_bool, &c->allow_autospawn_for_root, NULL }, 55 { "cookie-file", pa_config_parse_string, &c->cookie_file_from_client_conf, NULL }, 56 { "disable-shm", pa_config_parse_bool, &c->disable_shm, NULL }, 57 { "enable-shm", pa_config_parse_not_bool, &c->disable_shm, NULL }, 58diff --git a/src/pulse/client-conf.h b/src/pulse/client-conf.h 59index 7691ec7..19db7ed 100644 60--- a/src/pulse/client-conf.h 61+++ b/src/pulse/client-conf.h 62@@ -38,6 +38,7 @@ typedef struct pa_client_conf { 63 char *cookie_file_from_application; 64 char *cookie_file_from_client_conf; 65 bool autospawn, disable_shm, disable_memfd, auto_connect_localhost, auto_connect_display; 66+ bool allow_autospawn_for_root; 67 size_t shm_size; 68 } pa_client_conf; 69 70diff --git a/src/pulse/client.conf.in b/src/pulse/client.conf.in 71index 26b7790..69830ef 100644 72--- a/src/pulse/client.conf.in 73+++ b/src/pulse/client.conf.in 74@@ -23,6 +23,7 @@ 75 ; default-dbus-server = 76 77 ; autospawn = yes 78+; allow-autospawn-for-root = no 79 ; daemon-binary = @PA_BINARY@ 80 ; extra-arguments = --log-target=syslog 81 82diff --git a/src/pulse/context.c b/src/pulse/context.c 83index 69be5f4..d6e13e8 100644 84--- a/src/pulse/context.c 85+++ b/src/pulse/context.c 86@@ -1027,7 +1027,7 @@ int pa_context_connect( 87 if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) { 88 89 #ifdef HAVE_GETUID 90- if (getuid() == 0) 91+ if (!c->conf->allow_autospawn_for_root && getuid() == 0) 92 pa_log_debug("Not doing autospawn since we are root."); 93 else { 94 c->do_autospawn = true; 95-- 962.8.1 97 98