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/main.c') 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/main.c') 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 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/main.c') 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 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/main.c') 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