From dfe3f90b377a9cb2b158088c529a691086490afa Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 1 Sep 2009 00:53:49 +0200 Subject: daemon: don't override path env vars if they are already set --- src/daemon/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index b1d1109a..e44892da 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -259,9 +259,14 @@ static int change_user(void) { pa_set_env("HOME", PA_SYSTEM_RUNTIME_PATH); /* Relevant for pa_runtime_path() */ - pa_set_env("PULSE_RUNTIME_PATH", PA_SYSTEM_RUNTIME_PATH); - pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH); - pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH); + if (!getenv("PULSE_RUNTIME_PATH")) + pa_set_env("PULSE_RUNTIME_PATH", PA_SYSTEM_RUNTIME_PATH); + + if (!getenv("PULSE_CONFIG_PATH")) + pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH); + + if (!getenv("PULSE_STATE_PATH")) + pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH); pa_log_info(_("Successfully dropped root privileges.")); -- cgit From a8c0f65faecd7058de3bd704ed90985ae2c842f0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 00:42:54 +0200 Subject: daemon: clean up environment when forking off children --- src/daemon/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index e44892da..e22e465a 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -706,7 +706,7 @@ int main(int argc, char *argv[]) { #endif } - pa_set_env("PULSE_INTERNAL", "1"); + pa_set_env_and_record("PULSE_INTERNAL", "1"); pa_assert_se(chdir("/") == 0); umask(0022); @@ -721,7 +721,7 @@ int main(int argc, char *argv[]) { if (change_user() < 0) goto finish; - pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0"); + pa_set_env_and_record("PULSE_SYSTEM", conf->system_instance ? "1" : "0"); pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION); pa_log_debug(_("Compilation host: %s"), CANONICAL_HOST); @@ -968,6 +968,9 @@ finish: if (valid_pid_file) pa_pid_file_remove(); + /* This has no real purpose except making things valgrind-clean */ + pa_unset_env_recorded(); + #ifdef OS_IS_WIN32 WSACleanup(); #endif -- cgit From 39e4652a78850c3ece3ada2e3cdb2266668dba45 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 04:05:41 +0200 Subject: daemon: drop polkit code from git repo we weren't using anymore --- src/daemon/polkit.c | 172 ---------------------------------------------------- src/daemon/polkit.h | 27 --------- 2 files changed, 199 deletions(-) delete mode 100644 src/daemon/polkit.c delete mode 100644 src/daemon/polkit.h (limited to 'src/daemon') diff --git a/src/daemon/polkit.c b/src/daemon/polkit.c deleted file mode 100644 index 9799e094..00000000 --- a/src/daemon/polkit.c +++ /dev/null @@ -1,172 +0,0 @@ -/*** - This file is part of PulseAudio. - - Copyright 2004-2006 Lennart Poettering - Copyright 2006 Pierre Ossman for Cendio AB - - 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.1 of the License, - or (at your option) any later version. - - PulseAudio is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with PulseAudio; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include "polkit.h" - -int pa_polkit_check(const char *action_id) { - int ret = -1; - DBusError dbus_error; - DBusConnection *bus = NULL; - PolKitCaller *caller = NULL; - PolKitAction *action = NULL; - PolKitContext *context = NULL; - PolKitError *polkit_error = NULL; - PolKitSession *session = NULL; - PolKitResult polkit_result; - - dbus_error_init(&dbus_error); - - if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error))) { - pa_log_error(_("Cannot connect to system bus: %s"), dbus_error.message); - goto finish; - } - - /* There seems to be a bug in some versions of D-Bus that causes - * dbus_shutdown() to call exit() when a connection without this - * flag disabled was created during runtime.*/ - dbus_connection_set_exit_on_disconnect(bus, FALSE); - - if (!(caller = polkit_caller_new_from_pid(bus, getpid(), &dbus_error))) { - pa_log_error(_("Cannot get caller from PID: %s"), dbus_error.message); - goto finish; - } - - /* This function is called when PulseAudio is called SUID root. We - * want to authenticate the real user that called us and not the - * effective user we gained through being SUID root. Hence we - * overwrite the UID caller data here explicitly, just for - * paranoia. In fact PolicyKit should fill in the UID here anyway - * -- an not the EUID or any other user id. */ - - if (!(polkit_caller_set_uid(caller, getuid()))) { - pa_log_error(_("Cannot set UID on caller object.")); - goto finish; - } - - if (!(polkit_caller_get_ck_session(caller, &session))) { - pa_log_error(_("Failed to get CK session.")); - goto finish; - } - - /* We need to overwrite the UID in both the caller and the session - * object */ - - if (!(polkit_session_set_uid(session, getuid()))) { - pa_log_error(_("Cannot set UID on session object.")); - goto finish; - } - - if (!(action = polkit_action_new())) { - pa_log_error(_("Cannot allocate PolKitAction.")); - goto finish; - } - - if (!polkit_action_set_action_id(action, action_id)) { - pa_log_error(_("Cannot set action_id")); - goto finish; - } - - if (!(context = polkit_context_new())) { - pa_log_error(_("Cannot allocate PolKitContext.")); - goto finish; - } - - if (!polkit_context_init(context, &polkit_error)) { - pa_log_error(_("Cannot initialize PolKitContext: %s"), polkit_error_get_error_message(polkit_error)); - goto finish; - } - - for (;;) { - - polkit_result = polkit_context_is_caller_authorized(context, action, caller, TRUE, &polkit_error); - - if (polkit_error_is_set(polkit_error)) { - pa_log_error(_("Could not determine whether caller is authorized: %s"), polkit_error_get_error_message(polkit_error)); - goto finish; - } - - if (polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH || - polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION || - polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS || - polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT || - polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH || - polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION || - polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS || - polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT - ) { - - if (polkit_auth_obtain(action_id, 0, getpid(), &dbus_error)) { - polkit_result = POLKIT_RESULT_YES; - break; - } - - if (dbus_error_is_set(&dbus_error)) { - pa_log_error(_("Cannot obtain auth: %s"), dbus_error.message); - goto finish; - } - } - - break; - } - - if (polkit_result != POLKIT_RESULT_YES && polkit_result != POLKIT_RESULT_NO) - pa_log_warn(_("PolicyKit responded with '%s'"), polkit_result_to_string_representation(polkit_result)); - - ret = polkit_result == POLKIT_RESULT_YES; - -finish: - - if (caller) - polkit_caller_unref(caller); - - if (action) - polkit_action_unref(action); - - if (context) - polkit_context_unref(context); - - if (bus) - dbus_connection_unref(bus); - - dbus_error_free(&dbus_error); - - if (polkit_error) - polkit_error_free(polkit_error); - - return ret; -} diff --git a/src/daemon/polkit.h b/src/daemon/polkit.h deleted file mode 100644 index 018f6ef1..00000000 --- a/src/daemon/polkit.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef foopolkithfoo -#define foopolkithfoo - -/*** - This file is part of PulseAudio. - - Copyright 2007 Lennart Poettering - - 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.1 of the License, - or (at your option) any later version. - - PulseAudio is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with PulseAudio; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -int pa_polkit_check(const char *action); - -#endif -- cgit From d088c8f05abfae70379d720871f59962a2b3b16b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Sep 2009 00:19:03 +0200 Subject: daemon: make use of SIMD optional via config variable to ease debugging --- src/daemon/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index e22e465a..af59adef 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -828,8 +828,10 @@ int main(int argc, char *argv[]) { pa_memtrap_install(); - pa_cpu_init_x86(); - pa_cpu_init_arm(); + if (!getenv("PULSE_NO_SIMD")) { + pa_cpu_init_x86(); + pa_cpu_init_arm(); + } pa_assert_se(mainloop = pa_mainloop_new()); -- cgit From 812be327836c93492ad389333bcc037566141eb8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 4 Sep 2009 02:47:48 +0200 Subject: daemon: disable CPU load limiter by default RLIMIT_RTTIME and rtki can do this job much better, so let's disable this by default. --- src/daemon/daemon-conf.c | 2 +- src/daemon/daemon.conf.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index ec1ec5ce..6e7926f8 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -83,7 +83,7 @@ static const pa_daemon_conf default_conf = { .config_file = NULL, .use_pid_file = TRUE, .system_instance = FALSE, - .no_cpu_limit = FALSE, + .no_cpu_limit = TRUE, .disable_shm = FALSE, .lock_memory = FALSE, .default_n_fragments = 4, diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in index d8b58d8a..db2059e1 100644 --- a/src/daemon/daemon.conf.in +++ b/src/daemon/daemon.conf.in @@ -28,7 +28,7 @@ ; enable-shm = yes ; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB ; lock-memory = no -; cpu-limit = yes +; cpu-limit = no ; high-priority = yes ; nice-level = -11 -- cgit From 8f299687882a33093cad32936672ba649306739b Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 18 Sep 2009 16:10:13 +0100 Subject: conf: Fix typo in daemon.conf: rlimit-rtttime - too many t's Spotted by peol on IRC --- src/daemon/daemon.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon') diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in index db2059e1..3af68b0a 100644 --- a/src/daemon/daemon.conf.in +++ b/src/daemon/daemon.conf.in @@ -70,7 +70,7 @@ ; rlimit-msgqueue = -1 ; rlimit-nice = 31 ; rlimit-rtprio = 9 -; rlimit-rtttime = 1000000 +; rlimit-rttime = 1000000 ; default-sample-format = s16le ; default-sample-rate = 44100 -- cgit From eac566226ed9026347cdb415a93ad9b15fbd8b45 Mon Sep 17 00:00:00 2001 From: Nix Date: Sat, 26 Sep 2009 20:18:00 +0100 Subject: Don't refuse to start on systems using GNU stow, graft, STORE et al There are multiple package management systems out there which implement packages using symlinks. The recent (otherwise useful) check to ensure that a re-executed pulseaudio is actually reexecuting itself unfortunately breaks in the presence of all these packaging systems, because PA_BINARY refers to its installed location (e.g. /usr/local/bin/pulseaudio), which is a symlink to the binary (e.g. /usr/local/stow/pulseaudio-0.9.18/bin/pulseaudio), because /proc/self/exe always contains the canonical path of the executable, with all symlinks resolved. (At least one distribution uses a symlink-based packaging system, so will be forced to apply this locally in any case.) The fix is simple: canonicalize PA_BINARY before equality-testing. (This should be completely safe, because the OS does just that when PA_BINARY is executed.) The patch is against 0.9.18, but applies without fuzz to current master. --- src/daemon/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index af59adef..2e16c187 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -416,23 +416,28 @@ int main(int argc, char *argv[]) { if (!getenv("LD_BIND_NOW")) { char *rp; + char *canonical_rp; /* We have to execute ourselves, because the libc caches the * value of $LD_BIND_NOW on initialization. */ pa_set_env("LD_BIND_NOW", "1"); + canonical_rp = pa_realpath(PA_BINARY); + if ((rp = pa_readlink("/proc/self/exe"))) { - if (pa_streq(rp, PA_BINARY)) + if (pa_streq(rp, canonical_rp)) pa_assert_se(execv(rp, argv) == 0); else - pa_log_warn("/proc/self/exe does not point to " PA_BINARY ", cannot self execute. Are you playing games?"); + pa_log_warn("/proc/self/exe does not point to %s, cannot self execute. Are you playing games?", canonical_rp); pa_xfree(rp); } else pa_log_warn("Couldn't read /proc/self/exe, cannot self execute. Running in a chroot()?"); + + pa_xfree(canonical_rp); } #endif -- cgit From b8de3bd214775acd6d24291ad65a03a8204a9ec6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 29 Sep 2009 23:47:49 +0200 Subject: polkit: drop left-over polkit policy file from git tree --- src/daemon/org.pulseaudio.policy.in | 50 ------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/daemon/org.pulseaudio.policy.in (limited to 'src/daemon') diff --git a/src/daemon/org.pulseaudio.policy.in b/src/daemon/org.pulseaudio.policy.in deleted file mode 100644 index 1d0b6a7d..00000000 --- a/src/daemon/org.pulseaudio.policy.in +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - The PulseAudio Project - http://pulseaudio.org/ - audio-card - - - <_description>Real-time scheduling for the PulseAudio daemon - <_message>System policy prevents PulseAudio from acquiring real-time scheduling. - - no - no - no - - - - - <_description>High-priority scheduling (negative Unix nice level) for the PulseAudio daemon - <_message>System policy prevents PulseAudio from acquiring high-priority scheduling. - - no - no - no - - - - -- cgit