X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/8fb63dd6e42456108a4db97bfab67b7d48711770..0a583fe0c330d167f52784585afffdd8065a92cd:/src/daemon/main.c diff --git a/src/daemon/main.c b/src/daemon/main.c index a67bf063..02a8ea64 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -202,12 +202,12 @@ static int change_user(void) { if (!pa_streq(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH)) pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH); - if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid) < 0) { + if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid, true) < 0) { pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno)); return -1; } - if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid) < 0) { + if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid, true) < 0) { pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno)); return -1; } @@ -251,6 +251,8 @@ static int change_user(void) { return -1; } + pa_drop_caps(); + pa_set_env("USER", PA_SYSTEM_USER); pa_set_env("USERNAME", PA_SYSTEM_USER); pa_set_env("LOGNAME", PA_SYSTEM_USER); @@ -266,7 +268,7 @@ static int change_user(void) { if (!getenv("PULSE_STATE_PATH")) pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH); - pa_log_info(_("Successfully dropped root privileges.")); + pa_log_info(_("Successfully changed user to \"" PA_SYSTEM_USER "\".")); return 0; } @@ -344,9 +346,9 @@ static char *check_configured_address(void) { char *default_server = NULL; pa_client_conf *c = pa_client_conf_new(); - pa_client_conf_load(c, NULL); + pa_client_conf_load(c); #ifdef HAVE_X11 - pa_client_conf_from_x11(c, NULL); + pa_client_conf_from_x11(c); #endif pa_client_conf_env(c); @@ -400,8 +402,8 @@ int main(int argc, char *argv[]) { char *s; char *configured_address; int r = 0, retval = 1, d = 0; - pa_bool_t valid_pid_file = FALSE; - pa_bool_t ltdl_init = FALSE; + bool valid_pid_file = false; + bool ltdl_init = false; int passed_fd = -1; const char *e; #ifdef HAVE_FORK @@ -413,12 +415,12 @@ int main(int argc, char *argv[]) { struct timeval win32_tv; #endif int autospawn_fd = -1; - pa_bool_t autospawn_locked = FALSE; + bool autospawn_locked = false; #ifdef HAVE_DBUS pa_dbusobj_server_lookup *server_lookup = NULL; /* /org/pulseaudio/server_lookup */ pa_dbus_connection *lookup_service_bus = NULL; /* Always the user bus. */ pa_dbus_connection *server_bus = NULL; /* The bus where we reserve org.pulseaudio.Server, either the user or the system bus. */ - pa_bool_t start_server; + bool start_server; #endif pa_log_set_ident("pulseaudio"); @@ -497,8 +499,14 @@ int main(int argc, char *argv[]) { goto finish; } + if (conf->log_target) + pa_log_set_target(conf->log_target); + else { + pa_log_target target = { .type = PA_LOG_STDERR, .file = NULL }; + pa_log_set_target(&target); + } + pa_log_set_level(conf->log_level); - pa_log_set_target(conf->auto_log_target ? PA_LOG_STDERR : conf->log_target); if (conf->log_meta) pa_log_set_flags(PA_LOG_PRINT_META, PA_LOG_SET); if (conf->log_time) @@ -514,10 +522,10 @@ int main(int argc, char *argv[]) { break; case PA_SERVER_TYPE_USER: case PA_SERVER_TYPE_NONE: - conf->system_instance = FALSE; + conf->system_instance = false; break; case PA_SERVER_TYPE_SYSTEM: - conf->system_instance = TRUE; + conf->system_instance = true; break; default: pa_assert_not_reached(); @@ -527,13 +535,13 @@ int main(int argc, char *argv[]) { if (!start_server && conf->local_server_type == PA_SERVER_TYPE_SYSTEM) { pa_log_notice(_("System mode refused for non-root user. Only starting the D-Bus server lookup service.")); - conf->system_instance = FALSE; + conf->system_instance = false; } #endif LTDL_SET_PRELOADED_SYMBOLS(); pa_ltdl_init(); - ltdl_init = TRUE; + ltdl_init = true; if (conf->dl_search_path) lt_dlsetsearchpath(conf->dl_search_path); @@ -677,7 +685,7 @@ int main(int argc, char *argv[]) { * recover (i.e. autospawn) from a crash. */ char *ufn; - pa_bool_t start_anyway = FALSE; + bool start_anyway = false; if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) { char *id; @@ -722,7 +730,7 @@ int main(int argc, char *argv[]) { if (conf->system_instance && !conf->disable_shm) { pa_log_notice(_("Running in system mode, forcibly disabling SHM mode!")); - conf->disable_shm = TRUE; + conf->disable_shm = true; } if (conf->system_instance && conf->exit_idle_time >= 0) { @@ -740,12 +748,12 @@ int main(int argc, char *argv[]) { goto finish; } - if ((pa_autospawn_lock_acquire(TRUE) < 0)) { + if ((pa_autospawn_lock_acquire(true) < 0)) { pa_log("Failed to acquire autospawn lock"); goto finish; } - autospawn_locked = TRUE; + autospawn_locked = true; } if (conf->daemonize) { @@ -798,9 +806,9 @@ int main(int argc, char *argv[]) { * to close it in the child */ pa_autospawn_lock_release(); - pa_autospawn_lock_done(TRUE); + pa_autospawn_lock_done(true); - autospawn_locked = FALSE; + autospawn_locked = false; autospawn_fd = -1; } @@ -808,8 +816,14 @@ int main(int argc, char *argv[]) { daemon_pipe[0] = -1; #endif - if (conf->auto_log_target) - pa_log_set_target(PA_LOG_SYSLOG); + if (!conf->log_target) { +#ifdef HAVE_JOURNAL + pa_log_target target = { .type = PA_LOG_JOURNAL, .file = NULL }; +#else + pa_log_target target = { .type = PA_LOG_SYSLOG, .file = NULL }; +#endif + pa_log_set_target(&target); + } #ifdef HAVE_SETSID if (setsid() < 0) { @@ -890,7 +904,8 @@ int main(int argc, char *argv[]) { #endif pa_rtclock_hrtimer_enable(); - pa_raise_priority(conf->nice_level); + if (conf->high_priority) + pa_raise_priority(conf->nice_level); if (conf->system_instance) if (change_user() < 0) @@ -982,7 +997,7 @@ int main(int argc, char *argv[]) { goto finish; } - valid_pid_file = TRUE; + valid_pid_file = true; } pa_disable_sigpipe(); @@ -993,7 +1008,7 @@ int main(int argc, char *argv[]) { pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!")); if (conf->lock_memory) { -#ifdef HAVE_SYS_MMAN_H +#if defined(HAVE_SYS_MMAN_H) && !defined(__ANDROID__) if (mlockall(MCL_FUTURE) < 0) pa_log_warn("mlockall() failed: %s", pa_cstrerror(errno)); else @@ -1040,7 +1055,7 @@ int main(int argc, char *argv[]) { c->cpu_info.cpu_type = PA_CPU_X86; if (pa_cpu_init_arm(&(c->cpu_info.flags.arm))) c->cpu_info.cpu_type = PA_CPU_ARM; - pa_cpu_init_orc(c->cpu_info); + pa_cpu_init_orc(c->cpu_info); } pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0); @@ -1100,7 +1115,7 @@ int main(int argc, char *argv[]) { * any modules to be loaded. We haven't loaded any so far, so one might * think there's no way to contact the server, but receiving certain * signals could still cause modules to load. */ - conf->disallow_module_loading = TRUE; + conf->disallow_module_loading = true; } #endif @@ -1151,7 +1166,7 @@ finish: if (autospawn_locked) pa_autospawn_lock_release(); - pa_autospawn_lock_done(FALSE); + pa_autospawn_lock_done(false); } #ifdef OS_IS_WIN32