diff options
Diffstat (limited to 'src/daemon/main.c')
| -rw-r--r-- | src/daemon/main.c | 66 | 
1 files changed, 56 insertions, 10 deletions
| diff --git a/src/daemon/main.c b/src/daemon/main.c index 0f6fc907..af59adef 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -39,8 +39,6 @@  #include <sys/types.h>  #include <sys/stat.h> -#include <liboil/liboil.h> -  #ifdef HAVE_SYS_MMAN_H  #include <sys/mman.h>  #endif @@ -95,6 +93,8 @@  #ifdef HAVE_DBUS  #include <pulsecore/dbus-shared.h>  #endif +#include <pulsecore/cpu-arm.h> +#include <pulsecore/cpu-x86.h>  #include "cmdline.h"  #include "cpulimit.h" @@ -109,7 +109,7 @@ int allow_severity = LOG_INFO;  int deny_severity = LOG_WARNING;  #endif -#ifdef HAVE_OSS +#ifdef HAVE_OSS_WRAPPER  /* padsp looks for this symbol in the running process and disables   * itself if it finds it and it is set to 7 (which is actually a bit   * mask). For details see padsp. */ @@ -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.")); @@ -401,6 +406,36 @@ int main(int argc, char *argv[]) {      pa_log_set_level(PA_LOG_NOTICE);      pa_log_set_flags(PA_LOG_COLORS|PA_LOG_PRINT_FILE|PA_LOG_PRINT_LEVEL, PA_LOG_RESET); +#if defined(__linux__) && defined(__OPTIMIZE__) +    /* +       Disable lazy relocations to make usage of external libraries +       more deterministic for our RT threads. We abuse __OPTIMIZE__ as +       a check whether we are a debug build or not. This all is +       admittedly a bit snake-oilish. +    */ + +    if (!getenv("LD_BIND_NOW")) { +        char *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"); + +        if ((rp = pa_readlink("/proc/self/exe"))) { + +            if (pa_streq(rp, PA_BINARY)) +                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_xfree(rp); + +        } else +            pa_log_warn("Couldn't read /proc/self/exe, cannot self execute. Running in a chroot()?"); +    } +#endif +      if ((e = getenv("PULSE_PASSED_FD"))) {          passed_fd = atoi(e); @@ -411,10 +446,13 @@ int main(int argc, char *argv[]) {      /* We might be autospawned, in which case have no idea in which       * context we have been started. Let's cleanup our execution       * context as good as possible */ + +    pa_reset_personality();      pa_drop_root();      pa_close_all(passed_fd, -1);      pa_reset_sigs(-1);      pa_unblock_sigs(-1); +    pa_reset_priority();      setlocale(LC_ALL, "");      pa_init_i18n(); @@ -668,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); @@ -683,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); @@ -741,6 +779,8 @@ int main(int argc, char *argv[]) {      pa_log_info(_("Using state directory %s."), s);      pa_xfree(s); +    pa_log_info(_("Using modules directory %s."), conf->dl_search_path); +      pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode()));      if (pa_in_system_mode()) @@ -788,6 +828,11 @@ int main(int argc, char *argv[]) {      pa_memtrap_install(); +    if (!getenv("PULSE_NO_SIMD")) { +        pa_cpu_init_x86(); +        pa_cpu_init_arm(); +    } +      pa_assert_se(mainloop = pa_mainloop_new());      if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm, conf->shm_size))) { @@ -827,8 +872,6 @@ int main(int argc, char *argv[]) {      win32_timer = pa_mainloop_get_api(mainloop)->rtclock_time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&win32_tv), message_cb, NULL);  #endif -    oil_init(); -      if (!conf->no_cpu_limit)          pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0); @@ -927,6 +970,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 | 
