]> code.delx.au - pulseaudio/blobdiff - src/pulse/client-conf.c
client: introduce auto-connect-localhost= option in client.conf
[pulseaudio] / src / pulse / client-conf.c
index 71f8443d6dad5dfb7dc48d467684e00f2f44b97a..6c97802b0840e20108bb1baf3f98a51a72234131 100644 (file)
@@ -6,7 +6,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -57,11 +57,13 @@ static const pa_client_conf default_conf = {
     .default_sink = NULL,
     .default_source = NULL,
     .default_server = NULL,
+    .default_dbus_server = NULL,
     .autospawn = TRUE,
     .disable_shm = FALSE,
     .cookie_file = NULL,
     .cookie_valid = FALSE,
-    .shm_size = 0
+    .shm_size = 0,
+    .auto_connect_localhost = FALSE
 };
 
 pa_client_conf *pa_client_conf_new(void) {
@@ -81,6 +83,7 @@ void pa_client_conf_free(pa_client_conf *c) {
     pa_xfree(c->default_sink);
     pa_xfree(c->default_source);
     pa_xfree(c->default_server);
+    pa_xfree(c->default_dbus_server);
     pa_xfree(c->cookie_file);
     pa_xfree(c);
 }
@@ -92,31 +95,24 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
 
     /* Prepare the configuration parse table */
     pa_config_item table[] = {
-        { "daemon-binary",          pa_config_parse_string,  NULL, NULL },
-        { "extra-arguments",        pa_config_parse_string,  NULL, NULL },
-        { "default-sink",           pa_config_parse_string,  NULL, NULL },
-        { "default-source",         pa_config_parse_string,  NULL, NULL },
-        { "default-server",         pa_config_parse_string,  NULL, NULL },
-        { "autospawn",              pa_config_parse_bool,    NULL, NULL },
-        { "cookie-file",            pa_config_parse_string,  NULL, NULL },
-        { "disable-shm",            pa_config_parse_bool,    NULL, NULL },
-        { "shm-size-bytes",         pa_config_parse_size,    NULL, NULL },
-        { NULL,                     NULL,                    NULL, NULL },
+        { "daemon-binary",          pa_config_parse_string,   &c->daemon_binary, NULL },
+        { "extra-arguments",        pa_config_parse_string,   &c->extra_arguments, NULL },
+        { "default-sink",           pa_config_parse_string,   &c->default_sink, NULL },
+        { "default-source",         pa_config_parse_string,   &c->default_source, NULL },
+        { "default-server",         pa_config_parse_string,   &c->default_server, NULL },
+        { "default-dbus-server",    pa_config_parse_string,   &c->default_dbus_server, NULL },
+        { "autospawn",              pa_config_parse_bool,     &c->autospawn, NULL },
+        { "cookie-file",            pa_config_parse_string,   &c->cookie_file, NULL },
+        { "disable-shm",            pa_config_parse_bool,     &c->disable_shm, NULL },
+        { "enable-shm",             pa_config_parse_not_bool, &c->disable_shm, NULL },
+        { "shm-size-bytes",         pa_config_parse_size,     &c->shm_size, NULL },
+        { "auto-connect-localhost", pa_config_parse_bool,     &c->auto_connect_localhost, NULL },
+        { NULL,                     NULL,                     NULL, NULL },
     };
 
-    table[0].data = &c->daemon_binary;
-    table[1].data = &c->extra_arguments;
-    table[2].data = &c->default_sink;
-    table[3].data = &c->default_source;
-    table[4].data = &c->default_server;
-    table[5].data = &c->autospawn;
-    table[6].data = &c->cookie_file;
-    table[7].data = &c->disable_shm;
-    table[8].data = &c->shm_size;
-
     if (filename) {
 
-        if (!(f = fopen(filename, "r"))) {
+        if (!(f = pa_fopen_cloexec(filename, "r"))) {
             pa_log(_("Failed to open configuration file '%s': %s"), fn, pa_cstrerror(errno));
             goto finish;
         }
@@ -160,6 +156,9 @@ int pa_client_conf_env(pa_client_conf *c) {
     if ((e = getenv(ENV_DEFAULT_SERVER))) {
         pa_xfree(c->default_server);
         c->default_server = pa_xstrdup(e);
+
+        /* We disable autospawning automatically if a specific server was set */
+        c->autospawn = FALSE;
     }
 
     if ((e = getenv(ENV_DAEMON_BINARY))) {