From f1d2bf84089b1e5b5988a5e5d6d571a507a52337 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Aug 2008 18:54:13 +0200 Subject: add i18n support --- src/daemon/caps.c | 13 ++--- src/daemon/cmdline.c | 29 +++++------ src/daemon/daemon-conf.c | 27 ++++++----- src/daemon/dumpmodules.c | 17 +++---- src/daemon/ltdl-bind-now.c | 32 ++++++++----- src/daemon/main.c | 117 +++++++++++++++++++++++---------------------- src/daemon/polkit.c | 26 +++++----- 7 files changed, 139 insertions(+), 122 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/caps.c b/src/daemon/caps.c index 8a49e373..f7b6658b 100644 --- a/src/daemon/caps.c +++ b/src/daemon/caps.c @@ -28,7 +28,12 @@ #include #include #include + +#include + #include +#include +#include #ifdef HAVE_SYS_CAPABILITY_H #include @@ -37,10 +42,6 @@ #include #endif -#include - -#include - #include "caps.h" /* Glibc <= 2.2 has broken unistd.h */ @@ -58,7 +59,7 @@ void pa_drop_root(void) { if (uid == 0 || geteuid() != 0) return; - pa_log_info("Dropping root priviliges."); + pa_log_info(_("Dropping root priviliges.")); #if defined(HAVE_SETRESUID) pa_assert_se(setresuid(uid, uid, uid) >= 0); @@ -98,7 +99,7 @@ void pa_limit_caps(void) { * that */ pa_drop_caps(); else - pa_log_info("Limited capabilities successfully to CAP_SYS_NICE."); + pa_log_info(_("Limited capabilities successfully to CAP_SYS_NICE.")); pa_assert_se(cap_free(caps) == 0); diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 4b2466ce..3121da60 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -111,7 +112,7 @@ void pa_cmdline_help(const char *argv0) { else e = argv0; - printf("%s [options]\n\n" + printf(_("%s [options]\n\n" "COMMANDS:\n" " -h, --help Show this help\n" " --version Show version\n" @@ -160,7 +161,7 @@ void pa_cmdline_help(const char *argv0) { " -C Open a command line on the running TTY\n" " after startup\n\n" - " -n Don't load default script file\n", e); + " -n Don't load default script file\n"), e); } int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) { @@ -237,14 +238,14 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d case ARG_DAEMONIZE: case 'D': if ((conf->daemonize = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--daemonize expects boolean argument"); + pa_log(_("--daemonize expects boolean argument")); goto fail; } break; case ARG_FAIL: if ((conf->fail = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--fail expects boolean argument"); + pa_log(_("--fail expects boolean argument")); goto fail; } break; @@ -254,7 +255,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d if (optarg) { if (pa_daemon_conf_set_log_level(conf, optarg) < 0) { - pa_log("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."); + pa_log(_("--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error).")); goto fail; } } else { @@ -266,28 +267,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d case ARG_HIGH_PRIORITY: if ((conf->high_priority = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--high-priority expects boolean argument"); + pa_log(_("--high-priority expects boolean argument")); goto fail; } break; case ARG_REALTIME: if ((conf->realtime_scheduling = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--realtime expects boolean argument"); + pa_log(_("--realtime expects boolean argument")); goto fail; } break; case ARG_DISALLOW_MODULE_LOADING: if ((conf->disallow_module_loading = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--disallow-module-loading expects boolean argument"); + pa_log(_("--disallow-module-loading expects boolean argument")); goto fail; } break; case ARG_USE_PID_FILE: if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--use-pid-file expects boolean argument"); + pa_log(_("--use-pid-file expects boolean argument")); goto fail; } break; @@ -304,7 +305,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d case ARG_LOG_TARGET: if (pa_daemon_conf_set_log_target(conf, optarg) < 0) { - pa_log("Invalid log target: use either 'syslog', 'stderr' or 'auto'."); + pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto'.")); goto fail; } break; @@ -323,28 +324,28 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d case ARG_RESAMPLE_METHOD: if (pa_daemon_conf_set_resample_method(conf, optarg) < 0) { - pa_log("Invalid resample method '%s'.", optarg); + pa_log(_("Invalid resample method '%s'."), optarg); goto fail; } break; case ARG_SYSTEM: if ((conf->system_instance = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--system expects boolean argument"); + pa_log(_("--system expects boolean argument")); goto fail; } break; case ARG_NO_CPU_LIMIT: if ((conf->no_cpu_limit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--no-cpu-limit expects boolean argument"); + pa_log(_("--no-cpu-limit expects boolean argument")); goto fail; } break; case ARG_DISABLE_SHM: if ((conf->disable_shm = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { - pa_log("--disable-shm expects boolean argument"); + pa_log(_("--disable-shm expects boolean argument")); goto fail; } break; diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 50b812dc..a6b27c55 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -198,7 +199,7 @@ static int parse_log_target(const char *filename, unsigned line, const char *lva pa_assert(data); if (pa_daemon_conf_set_log_target(c, rvalue) < 0) { - pa_log("[%s:%u] Invalid log target '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid log target '%s'."), filename, line, rvalue); return -1; } @@ -214,7 +215,7 @@ static int parse_log_level(const char *filename, unsigned line, const char *lval pa_assert(data); if (pa_daemon_conf_set_log_level(c, rvalue) < 0) { - pa_log("[%s:%u] Invalid log level '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid log level '%s'."), filename, line, rvalue); return -1; } @@ -230,7 +231,7 @@ static int parse_resample_method(const char *filename, unsigned line, const char pa_assert(data); if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) { - pa_log("[%s:%u] Invalid resample method '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid resample method '%s'."), filename, line, rvalue); return -1; } @@ -253,14 +254,14 @@ static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, } else { int32_t k; if (pa_atoi(rvalue, &k) < 0) { - pa_log("[%s:%u] Invalid rlimit '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid rlimit '%s'."), filename, line, rvalue); return -1; } r->is_set = k >= 0; r->value = k >= 0 ? (rlim_t) k : 0; } #else - pa_log_warn("[%s:%u] rlimit not supported on this platform.", filename, line); + pa_log_warn(_("[%s:%u] rlimit not supported on this platform."), filename, line); #endif return 0; @@ -276,7 +277,7 @@ static int parse_sample_format(const char *filename, unsigned line, const char * pa_assert(data); if ((f = pa_parse_sample_format(rvalue)) < 0) { - pa_log("[%s:%u] Invalid sample format '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid sample format '%s'."), filename, line, rvalue); return -1; } @@ -294,7 +295,7 @@ static int parse_sample_rate(const char *filename, unsigned line, const char *lv pa_assert(data); if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) { - pa_log("[%s:%u] Invalid sample rate '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue); return -1; } @@ -312,7 +313,7 @@ static int parse_sample_channels(const char *filename, unsigned line, const char pa_assert(data); if (pa_atoi(rvalue, &n) < 0 || n > (int32_t) PA_CHANNELS_MAX || n <= 0) { - pa_log("[%s:%u] Invalid sample channels '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid sample channels '%s'."), filename, line, rvalue); return -1; } @@ -330,7 +331,7 @@ static int parse_fragments(const char *filename, unsigned line, const char *lval pa_assert(data); if (pa_atoi(rvalue, &n) < 0 || n < 2) { - pa_log("[%s:%u] Invalid number of fragments '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid number of fragments '%s'."), filename, line, rvalue); return -1; } @@ -348,7 +349,7 @@ static int parse_fragment_size_msec(const char *filename, unsigned line, const c pa_assert(data); if (pa_atoi(rvalue, &n) < 0 || n < 1) { - pa_log("[%s:%u] Invalid fragment size '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid fragment size '%s'."), filename, line, rvalue); return -1; } @@ -366,7 +367,7 @@ static int parse_nice_level(const char *filename, unsigned line, const char *lva pa_assert(data); if (pa_atoi(rvalue, &level) < 0 || level < -20 || level > 19) { - pa_log("[%s:%u] Invalid nice level '%s'.", filename, line, rvalue); + pa_log(_("[%s:%u] Invalid nice level '%s'."), filename, line, rvalue); return -1; } @@ -557,7 +558,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file); if (!f && errno != ENOENT) { - pa_log_warn("Failed to open configuration file: %s", pa_cstrerror(errno)); + pa_log_warn(_("Failed to open configuration file: %s"), pa_cstrerror(errno)); goto finish; } @@ -631,7 +632,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { s = pa_strbuf_new(); if (c->config_file) - pa_strbuf_printf(s, "### Read from configuration file: %s ###\n", c->config_file); + pa_strbuf_printf(s, _("### Read from configuration file: %s ###\n"), c->config_file); pa_assert(c->log_level <= PA_LOG_LEVEL_MAX); diff --git a/src/daemon/dumpmodules.c b/src/daemon/dumpmodules.c index cd6866aa..26fb8eef 100644 --- a/src/daemon/dumpmodules.c +++ b/src/daemon/dumpmodules.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -56,24 +57,24 @@ static void long_info(const char *name, const char *path, pa_modinfo *i) { nl = 1; - printf("Name: %s\n", name); + printf(_("Name: %s\n"), name); if (!i->description && !i->version && !i->author && !i->usage) - printf("No module information available\n"); + printf(_("No module information available\n")); else { if (i->version) - printf("Version: %s\n", i->version); + printf(_("Version: %s\n"), i->version); if (i->description) - printf("Description: %s\n", i->description); + printf(_("Description: %s\n"), i->description); if (i->author) - printf("Author: %s\n", i->author); + printf(_("Author: %s\n"), i->author); if (i->usage) - printf("Usage: %s\n", i->usage); - printf("Load Once: %s\n", pa_yes_no(i->load_once)); + printf(_("Usage: %s\n"), i->usage); + printf(_("Load Once: %s\n"), pa_yes_no(i->load_once)); } if (path) - printf("Path: %s\n", path); + printf(_("Path: %s\n"), path); } static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) { diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c index b1770674..40077248 100644 --- a/src/daemon/ltdl-bind-now.c +++ b/src/daemon/ltdl-bind-now.c @@ -32,13 +32,12 @@ #include #endif -#ifndef HAVE_STRUCT_LT_USER_DLLOADER -/* Only used with ltdl 2.2 */ #include -#endif #include +#include + #include #include #include @@ -54,6 +53,8 @@ #undef PA_BIND_NOW #endif +#ifdef HAVE_LT_DLMUTEX_REGISTER + static pa_mutex *libtool_mutex = NULL; PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls); @@ -74,6 +75,8 @@ static const char *libtool_get_error(void) { return PA_STATIC_TLS_GET(libtool_tls); } +#endif + #ifdef PA_BIND_NOW /* @@ -89,10 +92,11 @@ static const char *libtool_get_error(void) { */ #ifndef HAVE_LT_DLADVISE -static lt_module bind_now_open(lt_user_data d, const char *fname) { +static lt_module bind_now_open(lt_user_data d, const char *fname) #else - static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) { +static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) #endif +{ lt_module m; pa_assert(fname); @@ -150,8 +154,9 @@ void pa_ltdl_init(void) { #endif pa_assert_se(lt_dlinit() == 0); - pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE)); + #ifdef HAVE_LT_DLMUTEX_REGISTER + pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE)); pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0); #endif @@ -163,14 +168,15 @@ void pa_ltdl_init(void) { /* Add our BIND_NOW loader as the default module loader. */ if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0) - pa_log_warn("Failed to add bind-now-loader."); + pa_log_warn(_("Failed to add bind-now-loader.")); # else /* Already initialised */ - if ( dlopen_loader != NULL ) return; + if (dlopen_loader) + return; if (!(dlopen_loader = lt_dlloader_find("dlopen"))) { - pa_log_warn("Failed to find original dlopen loader."); - return; + pa_log_warn(_("Failed to find original dlopen loader.")); + return; } memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader)); @@ -182,14 +188,16 @@ void pa_ltdl_init(void) { /* Add our BIND_NOW loader as the default module loader. */ if (lt_dlloader_add(&bindnow_loader) != 0) - pa_log_warn("Failed to add bind-now-loader."); + pa_log_warn(_("Failed to add bind-now-loader.")); # endif #endif } void pa_ltdl_done(void) { pa_assert_se(lt_dlexit() == 0); + +#ifdef HAVE_LT_DLMUTEX_REGISTER pa_mutex_free(libtool_mutex); libtool_mutex = NULL; +#endif } - diff --git a/src/daemon/main.c b/src/daemon/main.c index 5fc9f01c..2579c182 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -131,7 +132,7 @@ static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const s #endif static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) { - pa_log_info("Got signal %s.", pa_sig2str(sig)); + pa_log_info(_("Got signal %s."), pa_sig2str(sig)); switch (sig) { #ifdef SIGUSR1 @@ -158,7 +159,7 @@ static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, case SIGINT: case SIGTERM: default: - pa_log_info("Exiting."); + pa_log_info(_("Exiting.")); m->quit(m, 1); break; } @@ -176,41 +177,41 @@ static int change_user(void) { * afterwards. */ if (!(pw = getpwnam(PA_SYSTEM_USER))) { - pa_log("Failed to find user '%s'.", PA_SYSTEM_USER); + pa_log(_("Failed to find user '%s'."), PA_SYSTEM_USER); return -1; } if (!(gr = getgrnam(PA_SYSTEM_GROUP))) { - pa_log("Failed to find group '%s'.", PA_SYSTEM_GROUP); + pa_log(_("Failed to find group '%s'."), PA_SYSTEM_GROUP); return -1; } - pa_log_info("Found user '%s' (UID %lu) and group '%s' (GID %lu).", + pa_log_info(_("Found user '%s' (UID %lu) and group '%s' (GID %lu)."), PA_SYSTEM_USER, (unsigned long) pw->pw_uid, PA_SYSTEM_GROUP, (unsigned long) gr->gr_gid); if (pw->pw_gid != gr->gr_gid) { - pa_log("GID of user '%s' and of group '%s' don't match.", PA_SYSTEM_USER, PA_SYSTEM_GROUP); + pa_log(_("GID of user '%s' and of group '%s' don't match."), PA_SYSTEM_USER, PA_SYSTEM_GROUP); return -1; } if (strcmp(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH) != 0) - pa_log_warn("Warning: home directory of user '%s' is not '%s', ignoring.", PA_SYSTEM_USER, 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) { - pa_log("Failed to create '%s': %s", PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno)); + 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) { - pa_log("Failed to create '%s': %s", PA_SYSTEM_STATE_PATH, pa_cstrerror(errno)); + pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno)); return -1; } /* We don't create the config dir here, because we don't need to write to it */ if (initgroups(PA_SYSTEM_USER, gr->gr_gid) != 0) { - pa_log("Failed to change group list: %s", pa_cstrerror(errno)); + pa_log(_("Failed to change group list: %s"), pa_cstrerror(errno)); return -1; } @@ -226,7 +227,7 @@ static int change_user(void) { #endif if (r < 0) { - pa_log("Failed to change GID: %s", pa_cstrerror(errno)); + pa_log(_("Failed to change GID: %s"), pa_cstrerror(errno)); return -1; } @@ -242,7 +243,7 @@ static int change_user(void) { #endif if (r < 0) { - pa_log("Failed to change UID: %s", pa_cstrerror(errno)); + pa_log(_("Failed to change UID: %s"), pa_cstrerror(errno)); return -1; } @@ -256,7 +257,7 @@ static int change_user(void) { pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH); pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH); - pa_log_info("Successfully dropped root privileges."); + pa_log_info(_("Successfully dropped root privileges.")); return 0; } @@ -264,7 +265,7 @@ static int change_user(void) { #else /* HAVE_PWD_H && HAVE_GRP_H */ static int change_user(void) { - pa_log("System wide mode unsupported on this platform."); + pa_log(_("System wide mode unsupported on this platform.")); return -1; } @@ -282,7 +283,7 @@ static int set_one_rlimit(const pa_rlimit *r, int resource, const char *name) { rl.rlim_cur = rl.rlim_max = r->value; if (setrlimit(resource, &rl) < 0) { - pa_log_info("setrlimit(%s, (%u, %u)) failed: %s", name, (unsigned) r->value, (unsigned) r->value, pa_cstrerror(errno)); + pa_log_info(_("setrlimit(%s, (%u, %u)) failed: %s"), name, (unsigned) r->value, (unsigned) r->value, pa_cstrerror(errno)); return -1; } @@ -407,6 +408,8 @@ int main(int argc, char *argv[]) { * still are normal root. */ setlocale(LC_ALL, ""); + pa_init_i18n(); + pa_log_set_maximal_level(PA_LOG_INFO); pa_log_set_ident("pulseaudio"); @@ -419,7 +422,7 @@ int main(int argc, char *argv[]) { goto finish; if (pa_cmdline_parse(conf, argc, argv, &d) < 0) { - pa_log("Failed to parse command line."); + pa_log(_("Failed to parse command line.")); goto finish; } @@ -435,14 +438,14 @@ int main(int argc, char *argv[]) { if (conf->high_priority && !allow_high_priority) { if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) { - pa_log_info("We're in the group '"PA_REALTIME_GROUP"', allowing high-priority scheduling."); + pa_log_info(_("We're in the group '%s', allowing high-priority scheduling."), PA_REALTIME_GROUP); allow_high_priority = TRUE; } } if (conf->realtime_scheduling && !allow_realtime) { if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) { - pa_log_info("We're in the group '"PA_REALTIME_GROUP"', allowing real-time scheduling."); + pa_log_info(_("We're in the group '%s', allowing real-time scheduling."), PA_REALTIME_GROUP); allow_realtime = TRUE; } } @@ -450,18 +453,18 @@ int main(int argc, char *argv[]) { #ifdef HAVE_POLKIT if (conf->high_priority && !allow_high_priority) { if (pa_polkit_check("org.pulseaudio.acquire-high-priority") > 0) { - pa_log_info("PolicyKit grants us acquire-high-priority privilege."); + pa_log_info(_("PolicyKit grants us acquire-high-priority privilege.")); allow_high_priority = TRUE; } else - pa_log_info("PolicyKit refuses acquire-high-priority privilege."); + pa_log_info(_("PolicyKit refuses acquire-high-priority privilege.")); } if (conf->realtime_scheduling && !allow_realtime) { if (pa_polkit_check("org.pulseaudio.acquire-real-time") > 0) { - pa_log_info("PolicyKit grants us acquire-real-time privilege."); + pa_log_info(_("PolicyKit grants us acquire-real-time privilege.")); allow_realtime = TRUE; } else - pa_log_info("PolicyKit refuses acquire-real-time privilege."); + pa_log_info(_("PolicyKit refuses acquire-real-time privilege.")); } #endif @@ -473,9 +476,9 @@ int main(int argc, char *argv[]) { pa_drop_caps(); if (conf->high_priority || conf->realtime_scheduling) - pa_log_notice("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n" - "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n" - "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."); + pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n" + "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n" + "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user.")); } } @@ -491,7 +494,7 @@ int main(int argc, char *argv[]) { #endif if (conf->high_priority && !pa_can_high_priority()) - pa_log_warn("High-priority scheduling enabled in configuration but not allowed by policy."); + pa_log_warn(_("High-priority scheduling enabled in configuration but not allowed by policy.")); if (conf->high_priority && (conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START)) pa_raise_priority(conf->nice_level); @@ -516,24 +519,24 @@ int main(int argc, char *argv[]) { rl.rlim_max = rl.rlim_cur = 9; if (setrlimit(RLIMIT_RTPRIO, &rl) >= 0) { - pa_log_info("Successfully increased RLIMIT_RTPRIO"); + pa_log_info(_("Successfully increased RLIMIT_RTPRIO")); drop = TRUE; } else - pa_log_warn("RLIMIT_RTPRIO failed: %s", pa_cstrerror(errno)); + pa_log_warn(_("RLIMIT_RTPRIO failed: %s"), pa_cstrerror(errno)); } } } #endif if (drop) { - pa_log_info("Giving up CAP_NICE"); + pa_log_info(_("Giving up CAP_NICE")); pa_drop_caps(); suid_root = FALSE; } } if (conf->realtime_scheduling && !pa_can_realtime()) - pa_log_warn("Real-time scheduling enabled in configuration but not allowed by policy."); + pa_log_warn(_("Real-time scheduling enabled in configuration but not allowed by policy.")); pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority())); @@ -591,9 +594,9 @@ int main(int argc, char *argv[]) { pid_t pid; if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) - pa_log_info("Daemon not running"); + pa_log_info(_("Daemon not running")); else { - pa_log_info("Daemon running as PID %u", pid); + pa_log_info(_("Daemon running as PID %u"), pid); retval = 0; } @@ -603,7 +606,7 @@ int main(int argc, char *argv[]) { case PA_CMD_KILL: if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0) - pa_log("Failed to kill daemon."); + pa_log(_("Failed to kill daemon.")); else retval = 0; @@ -621,14 +624,14 @@ int main(int argc, char *argv[]) { } if (real_root && !conf->system_instance) - pa_log_warn("This program is not intended to be run as root (unless --system is specified)."); + pa_log_warn(_("This program is not intended to be run as root (unless --system is specified).")); else if (!real_root && conf->system_instance) { - pa_log("Root priviliges required."); + pa_log(_("Root priviliges required.")); goto finish; } if (conf->cmd == PA_CMD_START && conf->system_instance) { - pa_log("--start not supported for system instances."); + pa_log(_("--start not supported for system instances.")); goto finish; } @@ -646,18 +649,18 @@ int main(int argc, char *argv[]) { int tty_fd; if (pa_stdio_acquire() < 0) { - pa_log("Failed to acquire stdio."); + pa_log(_("Failed to acquire stdio.")); goto finish; } #ifdef HAVE_FORK if (pipe(daemon_pipe) < 0) { - pa_log("pipe failed: %s", pa_cstrerror(errno)); + pa_log(_("pipe failed: %s"), pa_cstrerror(errno)); goto finish; } if ((child = fork()) < 0) { - pa_log("fork() failed: %s", pa_cstrerror(errno)); + pa_log(_("fork() failed: %s"), pa_cstrerror(errno)); goto finish; } @@ -671,15 +674,15 @@ int main(int argc, char *argv[]) { if ((n = pa_loop_read(daemon_pipe[0], &retval, sizeof(retval), NULL)) != sizeof(retval)) { if (n < 0) - pa_log("read() failed: %s", pa_cstrerror(errno)); + pa_log(_("read() failed: %s"), pa_cstrerror(errno)); retval = 1; } if (retval) - pa_log("Daemon startup failed."); + pa_log(_("Daemon startup failed.")); else - pa_log_info("Daemon startup successful."); + pa_log_info(_("Daemon startup successful.")); goto finish; } @@ -746,17 +749,17 @@ int main(int argc, char *argv[]) { pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0"); - pa_log_info("This is PulseAudio " PACKAGE_VERSION); - pa_log_info("Page size is %lu bytes", (unsigned long) PA_PAGE_SIZE); + pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION); + pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE); if (!(s = pa_get_runtime_dir())) goto finish; - pa_log_info("Using runtime directory %s.", s); + pa_log_info(_("Using runtime directory %s."), s); pa_xfree(s); if (!(s = pa_get_state_dir())) - pa_log_info("Using state directory %s.", s); + pa_log_info(_("Using state directory %s."), s); pa_xfree(s); - pa_log_info("Running in system mode: %s", pa_yes_no(pa_in_system_mode())); + pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode())); if (conf->use_pid_file) { int z; @@ -771,7 +774,7 @@ int main(int argc, char *argv[]) { goto finish; } - pa_log("pa_pid_file_create() failed."); + pa_log(_("pa_pid_file_create() failed.")); goto finish; } @@ -783,9 +786,9 @@ int main(int argc, char *argv[]) { #endif if (pa_rtclock_hrtimer()) - pa_log_info("Fresh high-resolution timers available! Bon appetit!"); + pa_log_info(_("Fresh high-resolution timers available! Bon appetit!")); else - pa_log_info("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"); + pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!")); #ifdef SIGRTMIN /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */ @@ -795,7 +798,7 @@ int main(int argc, char *argv[]) { pa_assert_se(mainloop = pa_mainloop_new()); if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) { - pa_log("pa_core_new() failed."); + pa_log(_("pa_core_new() failed.")); goto finish; } @@ -854,17 +857,17 @@ int main(int argc, char *argv[]) { c->disallow_module_loading = !!conf->disallow_module_loading; if (r < 0 && conf->fail) { - pa_log("Failed to initialize daemon."); + pa_log(_("Failed to initialize daemon.")); goto finish; } if (!c->modules || pa_idxset_size(c->modules) == 0) { - pa_log("Daemon startup without any loaded modules, refusing to work."); + pa_log(_("Daemon startup without any loaded modules, refusing to work.")); goto finish; } if (c->default_sink_name && !pa_namereg_get(c, c->default_sink_name, PA_NAMEREG_SINK, TRUE) && conf->fail) { - pa_log_error("Default sink name (%s) does not exist in name register.", c->default_sink_name); + pa_log_error(_("Default sink name (%s) does not exist in name register."), c->default_sink_name); goto finish; } @@ -877,13 +880,13 @@ int main(int argc, char *argv[]) { } #endif - pa_log_info("Daemon startup complete."); + pa_log_info(_("Daemon startup complete.")); retval = 0; if (pa_mainloop_run(mainloop, &retval) < 0) goto finish; - pa_log_info("Daemon shutdown initiated."); + pa_log_info(_("Daemon shutdown initiated.")); finish: @@ -900,7 +903,7 @@ finish: if (c) { pa_core_unref(c); - pa_log_info("Daemon terminated."); + pa_log_info(_("Daemon terminated.")); } if (!conf->no_cpu_limit) diff --git a/src/daemon/polkit.c b/src/daemon/polkit.c index 08155cf2..921e5d1d 100644 --- a/src/daemon/polkit.c +++ b/src/daemon/polkit.c @@ -31,6 +31,8 @@ #include #include +#include + #include #include @@ -50,7 +52,7 @@ int pa_polkit_check(const char *action_id) { 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); + pa_log_error(_("Cannot connect to system bus: %s"), dbus_error.message); goto finish; } @@ -60,7 +62,7 @@ int pa_polkit_check(const char *action_id) { 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); + pa_log_error(_("Cannot get caller from PID: %s"), dbus_error.message); goto finish; } @@ -72,12 +74,12 @@ int pa_polkit_check(const char *action_id) { * -- 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."); + 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."); + pa_log_error(_("Failed to get CK session.")); goto finish; } @@ -85,27 +87,27 @@ int pa_polkit_check(const char *action_id) { * object */ if (!(polkit_session_set_uid(session, getuid()))) { - pa_log_error("Cannot set UID on session object."); + pa_log_error(_("Cannot set UID on session object.")); goto finish; } if (!(action = polkit_action_new())) { - pa_log_error("Cannot allocate PolKitAction."); + pa_log_error(_("Cannot allocate PolKitAction.")); goto finish; } if (!polkit_action_set_action_id(action, action_id)) { - pa_log_error("Cannot set action_id"); + pa_log_error(_("Cannot set action_id")); goto finish; } if (!(context = polkit_context_new())) { - pa_log_error("Cannot allocate PolKitContext."); + 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)); + pa_log_error(_("Cannot initialize PolKitContext: %s"), polkit_error_get_error_message(polkit_error)); goto finish; } @@ -114,7 +116,7 @@ int pa_polkit_check(const char *action_id) { 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)); + pa_log_error(_("Could not determine whether caller is authorized: %s"), polkit_error_get_error_message(polkit_error)); goto finish; } @@ -134,7 +136,7 @@ int pa_polkit_check(const char *action_id) { } if (dbus_error_is_set(&dbus_error)) { - pa_log_error("Cannot obtain auth: %s", dbus_error.message); + pa_log_error(_("Cannot obtain auth: %s"), dbus_error.message); goto finish; } } @@ -143,7 +145,7 @@ int pa_polkit_check(const char *action_id) { } 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)); + pa_log_warn(_("PolicyKit responded with '%s'"), polkit_result_to_string_representation(polkit_result)); ret = polkit_result == POLKIT_RESULT_YES; -- cgit From 756fac8d0433d02819d3910238ebf1b7a33a3046 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Aug 2008 19:39:12 +0200 Subject: add new switch --disallow-exit --- src/daemon/cmdline.c | 13 ++++++++++- src/daemon/daemon-conf.c | 60 ++++++++++++++++++++++++++---------------------- src/daemon/daemon-conf.h | 3 ++- src/daemon/main.c | 1 + 4 files changed, 47 insertions(+), 30 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 3121da60..fbd6dc32 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -50,6 +50,7 @@ enum { ARG_HIGH_PRIORITY, ARG_REALTIME, ARG_DISALLOW_MODULE_LOADING, + ARG_DISALLOW_EXIT, ARG_EXIT_IDLE_TIME, ARG_MODULE_IDLE_TIME, ARG_SCACHE_IDLE_TIME, @@ -82,6 +83,7 @@ static const struct option long_options[] = { {"high-priority", 2, 0, ARG_HIGH_PRIORITY}, {"realtime", 2, 0, ARG_REALTIME}, {"disallow-module-loading", 2, 0, ARG_DISALLOW_MODULE_LOADING}, + {"disallow-exit", 2, 0, ARG_DISALLOW_EXIT}, {"exit-idle-time", 2, 0, ARG_EXIT_IDLE_TIME}, {"module-idle-time", 2, 0, ARG_MODULE_IDLE_TIME}, {"scache-idle-time", 2, 0, ARG_SCACHE_IDLE_TIME}, @@ -134,7 +136,9 @@ void pa_cmdline_help(const char *argv0) { " --realtime[=BOOL] Try to enable realtime scheduling\n" " (only available as root, when SUID or\n" " with elevated RLIMIT_RTPRIO)\n" - " --disallow-module-loading[=BOOL] Disallow module loading after startup\n" + " --disallow-module-loading[=BOOL] Disallow module user requested module\n" + " loading/unloading after startup\n" + " --disallow-exit[=BOOL] Disallow user requested exit\n" " --exit-idle-time=SECS Terminate the daemon when idle and this\n" " time passed\n" " --module-idle-time=SECS Unload autoloaded modules when idle and\n" @@ -286,6 +290,13 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d } break; + case ARG_DISALLOW_EXIT: + if ((conf->disallow_exit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { + pa_log(_("--disallow-exit boolean argument")); + goto fail; + } + break; + case ARG_USE_PID_FILE: if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) { pa_log(_("--use-pid-file expects boolean argument")); diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index a6b27c55..05c86c87 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -63,6 +63,7 @@ static const pa_daemon_conf default_conf = { .realtime_scheduling = FALSE, .realtime_priority = 5, /* Half of JACK's default rtprio */ .disallow_module_loading = FALSE, + .disallow_exit = FALSE, .exit_idle_time = 20, .module_idle_time = 20, .scache_idle_time = 20, @@ -403,6 +404,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { { "high-priority", pa_config_parse_bool, NULL }, { "realtime-scheduling", pa_config_parse_bool, NULL }, { "disallow-module-loading", pa_config_parse_bool, NULL }, + { "disallow-exit", pa_config_parse_bool, NULL }, { "use-pid-file", pa_config_parse_bool, NULL }, { "system-instance", pa_config_parse_bool, NULL }, { "no-cpu-limit", pa_config_parse_bool, NULL }, @@ -466,17 +468,17 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { table[2].data = &c->high_priority; table[3].data = &c->realtime_scheduling; table[4].data = &c->disallow_module_loading; - table[5].data = &c->use_pid_file; - table[6].data = &c->system_instance; - table[7].data = &c->no_cpu_limit; - table[8].data = &c->disable_shm; - table[9].data = &c->exit_idle_time; - table[10].data = &c->module_idle_time; - table[11].data = &c->scache_idle_time; - table[12].data = c; - table[13].data = &c->dl_search_path; - table[14].data = &c->default_script_file; - table[15].data = c; + table[5].data = &c->disallow_exit; + table[6].data = &c->use_pid_file; + table[7].data = &c->system_instance; + table[8].data = &c->no_cpu_limit; + table[9].data = &c->disable_shm; + table[10].data = &c->exit_idle_time; + table[11].data = &c->module_idle_time; + table[12].data = &c->scache_idle_time; + table[13].data = c; + table[14].data = &c->dl_search_path; + table[15].data = &c->default_script_file; table[16].data = c; table[17].data = c; table[18].data = c; @@ -486,67 +488,68 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { table[22].data = c; table[23].data = c; table[24].data = c; - table[25].data = &c->disable_remixing; - table[26].data = &c->load_default_script_file; + table[25].data = c; + table[26].data = &c->disable_remixing; + table[27].data = &c->load_default_script_file; #ifdef HAVE_SYS_RESOURCE_H - table[27].data = &c->rlimit_fsize; - table[28].data = &c->rlimit_data; - table[29].data = &c->rlimit_stack; - table[30].data = &c->rlimit_as; - table[31].data = &c->rlimit_core; - table[32].data = &c->rlimit_nofile; - table[33].data = &c->rlimit_as; + table[28].data = &c->rlimit_fsize; + table[29].data = &c->rlimit_data; + table[30].data = &c->rlimit_stack; + table[31].data = &c->rlimit_as; + table[32].data = &c->rlimit_core; + table[33].data = &c->rlimit_nofile; + table[34].data = &c->rlimit_as; #ifdef RLIMIT_NPROC - table[34].data = &c->rlimit_nproc; + table[35].data = &c->rlimit_nproc; #endif #ifdef RLIMIT_MEMLOCK #ifndef RLIMIT_NPROC #error "Houston, we have a numbering problem!" #endif - table[35].data = &c->rlimit_memlock; + table[36].data = &c->rlimit_memlock; #endif #ifdef RLIMIT_LOCKS #ifndef RLIMIT_MEMLOCK #error "Houston, we have a numbering problem!" #endif - table[36].data = &c->rlimit_locks; + table[37].data = &c->rlimit_locks; #endif #ifdef RLIMIT_SIGPENDING #ifndef RLIMIT_LOCKS #error "Houston, we have a numbering problem!" #endif - table[37].data = &c->rlimit_sigpending; + table[38].data = &c->rlimit_sigpending; #endif #ifdef RLIMIT_MSGQUEUE #ifndef RLIMIT_SIGPENDING #error "Houston, we have a numbering problem!" #endif - table[38].data = &c->rlimit_msgqueue; + table[39].data = &c->rlimit_msgqueue; #endif #ifdef RLIMIT_NICE #ifndef RLIMIT_MSGQUEUE #error "Houston, we have a numbering problem!" #endif - table[39].data = &c->rlimit_nice; + table[40].data = &c->rlimit_nice; #endif #ifdef RLIMIT_RTPRIO #ifndef RLIMIT_NICE #error "Houston, we have a numbering problem!" #endif - table[40].data = &c->rlimit_rtprio; + table[41].data = &c->rlimit_rtprio; #endif #ifdef RLIMIT_RTTIME #ifndef RLIMIT_RTTIME #error "Houston, we have a numbering problem!" #endif - table[41].data = &c->rlimit_rttime; + table[42].data = &c->rlimit_rttime; #endif #endif @@ -643,6 +646,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { pa_strbuf_printf(s, "realtime-scheduling = %s\n", pa_yes_no(c->realtime_scheduling)); pa_strbuf_printf(s, "realtime-priority = %i\n", c->realtime_priority); pa_strbuf_printf(s, "disallow-module-loading = %s\n", pa_yes_no(c->disallow_module_loading)); + pa_strbuf_printf(s, "disallow-exit = %s\n", pa_yes_no(c->disallow_exit)); pa_strbuf_printf(s, "use-pid-file = %s\n", pa_yes_no(c->use_pid_file)); pa_strbuf_printf(s, "system-instance = %s\n", pa_yes_no(c->system_instance)); pa_strbuf_printf(s, "no-cpu-limit = %s\n", pa_yes_no(c->no_cpu_limit)); diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h index be2fe1ab..c42984f9 100644 --- a/src/daemon/daemon-conf.h +++ b/src/daemon/daemon-conf.h @@ -66,7 +66,8 @@ typedef struct pa_daemon_conf { no_cpu_limit, disable_shm, disable_remixing, - load_default_script_file; + load_default_script_file, + disallow_exit; int exit_idle_time, module_idle_time, scache_idle_time, diff --git a/src/daemon/main.c b/src/daemon/main.c index 2579c182..048af1e6 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -813,6 +813,7 @@ int main(int argc, char *argv[]) { c->realtime_scheduling = !!conf->realtime_scheduling; c->disable_remixing = !!conf->disable_remixing; c->running_as_daemon = !!conf->daemonize; + c->disallow_exit = conf->disallow_exit; pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0); pa_signal_new(SIGINT, signal_callback, c); -- cgit From a4762ab4b17715fdc7fd95aae7948507ea20ddf2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Aug 2008 19:55:50 +0200 Subject: add disallow-exit to default configuration file --- src/daemon/daemon.conf.in | 1 + 1 file changed, 1 insertion(+) (limited to 'src/daemon') diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in index 41c26e2a..33b1d61d 100644 --- a/src/daemon/daemon.conf.in +++ b/src/daemon/daemon.conf.in @@ -22,6 +22,7 @@ ; daemonize = no ; fail = yes ; disallow-module-loading = no +; disallow-exit = no ; use-pid-file = yes ; system-instance = no ; disable-shm = no -- cgit From ff6bb7acdada86635cb09530d4ba3f4147b008da Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Aug 2008 19:56:15 +0200 Subject: add a few configuration sanity checks for system mode --- src/daemon/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index 048af1e6..00469c7a 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -635,6 +635,22 @@ int main(int argc, char *argv[]) { goto finish; } + if (conf->system_instance && !conf->disallow_exit) + pa_log_warn(_("Running in system mode, but --disallow-exit not set!")); + + if (conf->system_instance && !conf->disallow_module_loading) + pa_log_warn(_("Running in system mode, but --disallow-module-loading not set!")); + + if (conf->system_instance && !conf->disable_shm) { + pa_log_notice(_("Running in system mode, forcibly disabling SHM mode!")); + conf->disable_shm = TRUE; + } + + if (conf->system_instance && conf->exit_idle_time > 0) { + pa_log_notice(_("Running in system mode, forcibly disabling exit idle time!")); + conf->exit_idle_time = 0; + } + if (conf->cmd == PA_CMD_START) { /* If we shall start PA only when it is not running yet, we * first take the autospawn lock to make things -- cgit From 0075649f135a52d434f6e351c5cc34c75726dbc2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Aug 2008 02:23:45 +0200 Subject: print machine id during startup --- src/daemon/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index 00469c7a..ab438320 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -767,12 +767,22 @@ int main(int argc, char *argv[]) { pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION); pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE); + + if (!(s = pa_machine_id())) { + pa_log(_("Failed to get machine ID")); + goto finish; + } + pa_log_info(_("Machine ID is %s."), s); + pa_xfree(s); + if (!(s = pa_get_runtime_dir())) goto finish; pa_log_info(_("Using runtime directory %s."), s); pa_xfree(s); + if (!(s = pa_get_state_dir())) - pa_log_info(_("Using state directory %s."), s); + goto finish; + pa_log_info(_("Using state directory %s."), s); pa_xfree(s); pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode())); -- cgit From 8a3d666da390b1356f5545649e23bda7ccb6d710 Mon Sep 17 00:00:00 2001 From: Diego 'Flameeyes' Pettenò Date: Fri, 8 Aug 2008 12:39:04 +0200 Subject: Fix building again libtool/ltdl 2.2.4. On changeset f1d2bf84089b1e5b5988a5e5d6d571a507a52337 support for libtool 2.2 was broken as libtool_set_error was not defined anymore on that version. Fix this by also putting under #ifdef the calls to that function. --- src/daemon/ltdl-bind-now.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/daemon') diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c index 40077248..1215d125 100644 --- a/src/daemon/ltdl-bind-now.c +++ b/src/daemon/ltdl-bind-now.c @@ -102,7 +102,9 @@ static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise ad pa_assert(fname); if (!(m = dlopen(fname, PA_BIND_NOW))) { +#ifdef HAVE_LT_DLMUTEX_REGISTER libtool_set_error(dlerror()); +#endif return NULL; } @@ -114,7 +116,9 @@ static int bind_now_close(lt_user_data d, lt_module m) { pa_assert(m); if (dlclose(m) != 0){ +#ifdef HAVE_LT_DLMUTEX_REGISTER libtool_set_error(dlerror()); +#endif return 1; } @@ -128,7 +132,9 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol) pa_assert(symbol); if (!(ptr = dlsym(m, symbol))) { +#ifdef HAVE_LT_DLMUTEX_REGISTER libtool_set_error(dlerror()); +#endif return NULL; } -- cgit From b4a566918cc6fbf2d5e66ae354275d36fbe8d13a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 9 Aug 2008 03:47:59 +0200 Subject: print reason when we fail to kill a running daemon --- src/daemon/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index ab438320..9cdcb6cd 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -606,7 +606,7 @@ int main(int argc, char *argv[]) { case PA_CMD_KILL: if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0) - pa_log(_("Failed to kill daemon.")); + pa_log(_("Failed to kill daemon: %s"), pa_cstrerror(errno)); else retval = 0; -- cgit From 15cebbacebf27703848afb18883fad7984349f04 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 9 Aug 2008 03:49:42 +0200 Subject: rework autospawning code to survive multiple pa_contexts in a single process --- src/daemon/main.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/main.c b/src/daemon/main.c index 9cdcb6cd..c6fb3c69 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -95,8 +96,6 @@ #include "ltdl-bind-now.h" #include "polkit.h" -#define AUTOSPAWN_LOCK "autospawn.lock" - #ifdef HAVE_LIBWRAP /* Only one instance of these variables */ int allow_severity = LOG_INFO; @@ -346,7 +345,8 @@ int main(int argc, char *argv[]) { struct timeval win32_tv; #endif char *lf = NULL; - int autospawn_lock_fd = -1; + int autospawn_fd = -1; + pa_bool_t autospawn_locked = FALSE; #if defined(__linux__) && defined(__OPTIMIZE__) /* @@ -656,8 +656,17 @@ int main(int argc, char *argv[]) { * first take the autospawn lock to make things * synchronous. */ - lf = pa_runtime_path(AUTOSPAWN_LOCK); - autospawn_lock_fd = pa_lock_lockfile(lf); + if ((autospawn_fd = pa_autospawn_lock_init()) < 0) { + pa_log("Failed to initialize autospawn lock"); + goto finish; + } + + if ((pa_autospawn_lock_acquire(TRUE) < 0)) { + pa_log("Failed to acquire autospawn lock"); + goto finish; + } + + autospawn_locked = TRUE; } if (conf->daemonize) { @@ -703,12 +712,15 @@ int main(int argc, char *argv[]) { goto finish; } - if (autospawn_lock_fd >= 0) { + if (autospawn_fd >= 0) { /* The lock file is unlocked from the parent, so we need * to close it in the child */ - pa_close(autospawn_lock_fd); - autospawn_lock_fd = -1; + pa_autospawn_lock_release(); + pa_autospawn_lock_done(TRUE); + + autospawn_locked = FALSE; + autospawn_fd = -1; } pa_assert_se(pa_close(daemon_pipe[0]) == 0); @@ -917,8 +929,12 @@ int main(int argc, char *argv[]) { finish: - if (autospawn_lock_fd >= 0) - pa_unlock_lockfile(lf, autospawn_lock_fd); + if (autospawn_fd >= 0) { + if (autospawn_locked) + pa_autospawn_lock_release(); + + pa_autospawn_lock_done(FALSE); + } if (lf) pa_xfree(lf); -- cgit From 432b4e5f7d9ea722d13bbe4c117a4f9b78091e4f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 9 Aug 2008 16:20:29 +0200 Subject: don't use PA_GCC_UNUSED anymore --- src/daemon/cpulimit.c | 2 +- src/daemon/daemon-conf.c | 22 +++++++++++----------- src/daemon/dumpmodules.c | 2 +- src/daemon/main.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c index 42a71f7e..b5ed71e0 100644 --- a/src/daemon/cpulimit.c +++ b/src/daemon/cpulimit.c @@ -235,7 +235,7 @@ void pa_cpu_limit_done(void) { #else /* HAVE_SIGXCPU */ -int pa_cpu_limit_init(PA_GCC_UNUSED pa_mainloop_api *m) { +int pa_cpu_limit_init(pa_mainloop_api *m) { return 0; } diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 05c86c87..4f7470ba 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -191,7 +191,7 @@ int pa_daemon_conf_set_resample_method(pa_daemon_conf *c, const char *string) { return 0; } -static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; pa_assert(filename); @@ -207,7 +207,7 @@ static int parse_log_target(const char *filename, unsigned line, const char *lva return 0; } -static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_log_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; pa_assert(filename); @@ -223,7 +223,7 @@ static int parse_log_level(const char *filename, unsigned line, const char *lval return 0; } -static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; pa_assert(filename); @@ -239,7 +239,7 @@ static int parse_resample_method(const char *filename, unsigned line, const char return 0; } -static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { #ifdef HAVE_SYS_RESOURCE_H struct pa_rlimit *r = data; @@ -268,7 +268,7 @@ static int parse_rlimit(const char *filename, unsigned line, const char *lvalue, return 0; } -static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_sample_format(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; pa_sample_format_t f; @@ -286,7 +286,7 @@ static int parse_sample_format(const char *filename, unsigned line, const char * return 0; } -static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t r; @@ -304,7 +304,7 @@ static int parse_sample_rate(const char *filename, unsigned line, const char *lv return 0; } -static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_sample_channels(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t n; @@ -322,7 +322,7 @@ static int parse_sample_channels(const char *filename, unsigned line, const char return 0; } -static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_fragments(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t n; @@ -340,7 +340,7 @@ static int parse_fragments(const char *filename, unsigned line, const char *lval return 0; } -static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_fragment_size_msec(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t n; @@ -358,7 +358,7 @@ static int parse_fragment_size_msec(const char *filename, unsigned line, const c return 0; } -static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_nice_level(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t level; @@ -376,7 +376,7 @@ static int parse_nice_level(const char *filename, unsigned line, const char *lva return 0; } -static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, PA_GCC_UNUSED void *userdata) { +static int parse_rtprio(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; int32_t rtprio; diff --git a/src/daemon/dumpmodules.c b/src/daemon/dumpmodules.c index 26fb8eef..9c9f1c81 100644 --- a/src/daemon/dumpmodules.c +++ b/src/daemon/dumpmodules.c @@ -40,7 +40,7 @@ #define PREFIX "module-" -static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) { +static void short_info(const char *name, const char *path, pa_modinfo *i) { pa_assert(name); pa_assert(i); diff --git a/src/daemon/main.c b/src/daemon/main.c index c6fb3c69..b57a74a2 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -111,7 +111,7 @@ int __padsp_disabled__ = 7; #ifdef OS_IS_WIN32 -static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) { +static void message_cb(pa_mainloop_api*a, pa_time_event*e, const struct timeval *tv, void *userdata) { MSG msg; struct timeval tvnext; @@ -130,7 +130,7 @@ static void message_cb(pa_mainloop_api*a, pa_time_event*e, PA_GCC_UNUSED const s #endif -static void signal_callback(pa_mainloop_api*m, PA_GCC_UNUSED pa_signal_event *e, int sig, void *userdata) { +static void signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { pa_log_info(_("Got signal %s."), pa_sig2str(sig)); switch (sig) { -- cgit From 5a0e01404a7647c4776c91ac52a4e99f1ab24d03 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 15 Aug 2008 14:32:33 +0200 Subject: disable hotplug sounds by default --- src/daemon/default.pa.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/daemon') diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in index cdaa8bbd..5f35e3ec 100755 --- a/src/daemon/default.pa.in +++ b/src/daemon/default.pa.in @@ -23,7 +23,7 @@ ### Load something into the sample cache #load-sample-lazy x11-bell /usr/share/sounds/gtk-events/activate.wav -load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav +#load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav #load-sample-lazy pulse-coldplug /usr/share/sounds/startup3.wav #load-sample-lazy pulse-access /usr/share/sounds/generic.wav -- cgit From 74719c24f561cd04ba430a69a8885e7b4a05edb6 Mon Sep 17 00:00:00 2001 From: Russ Dill Date: Sun, 17 Aug 2008 12:53:43 -0700 Subject: Fix up overzealous HAVE_LT_DLMUTEX_REGISTER block This fixes a built problem on systems without the lt_dlmutex_register function. The overzealousness causes libtool_set_error and libtool_get_error to be undefined. This fixes a build problem on Ubuntu Intrepid. Signed-off-by: Russ Dill Signed-off-by: Lennart Poettering --- src/daemon/ltdl-bind-now.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c index 40077248..bb5a196e 100644 --- a/src/daemon/ltdl-bind-now.c +++ b/src/daemon/ltdl-bind-now.c @@ -57,8 +57,6 @@ static pa_mutex *libtool_mutex = NULL; -PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls); - static void libtool_lock(void) { pa_mutex_lock(libtool_mutex); } @@ -67,6 +65,10 @@ static void libtool_unlock(void) { pa_mutex_unlock(libtool_mutex); } +#endif + +PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls); + static void libtool_set_error(const char *error) { PA_STATIC_TLS_SET(libtool_tls, (char*) error); } @@ -75,8 +77,6 @@ static const char *libtool_get_error(void) { return PA_STATIC_TLS_GET(libtool_tls); } -#endif - #ifdef PA_BIND_NOW /* -- cgit From b7026bf248948a6a30386ddbcc137f48f369a51e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Aug 2008 22:39:54 +0200 Subject: add a few more gcc warning flags and fix quite a few problems found by doing so --- src/daemon/cpulimit.c | 4 ++-- src/daemon/daemon-conf.c | 4 ++-- src/daemon/ltdl-bind-now.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c index b5ed71e0..c6e13d83 100644 --- a/src/daemon/cpulimit.c +++ b/src/daemon/cpulimit.c @@ -100,7 +100,7 @@ static void reset_cpu_time(int t) { n = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec + t; pa_assert_se(getrlimit(RLIMIT_CPU, &rl) >= 0); - rl.rlim_cur = n; + rl.rlim_cur = (rlim_t) n; pa_assert_se(setrlimit(RLIMIT_CPU, &rl) >= 0); } @@ -130,7 +130,7 @@ static void signal_handler(int sig) { write_err(t); #endif - if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) { + if ((double) CPUTIME_INTERVAL_SOFT >= ((double) (now-last_time)*(double)CPUTIME_PERCENT/100)) { static const char c = 'X'; write_err("Soft CPU time limit exhausted, terminating.\n"); diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 4f7470ba..40e0a170 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -288,14 +288,14 @@ static int parse_sample_format(const char *filename, unsigned line, const char * static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; - int32_t r; + uint32_t r; pa_assert(filename); pa_assert(lvalue); pa_assert(rvalue); pa_assert(data); - if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) { + if (pa_atou(rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0) { pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue); return -1; } diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c index 42c3b231..92e5d40d 100644 --- a/src/daemon/ltdl-bind-now.c +++ b/src/daemon/ltdl-bind-now.c @@ -24,11 +24,11 @@ #include #endif -#if HAVE_DLFCN_H +#ifdef HAVE_DLFCN_H #include #endif -#if HAVE_SYS_DL_H +#ifdef HAVE_SYS_DL_H #include #endif -- cgit From 8e7178755193949d42bfe5a6c487e7fcdd0c51bd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Aug 2008 23:03:37 +0200 Subject: rework cpu limit logic to use monotonic instead of wall clock time --- src/daemon/cpulimit.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c index c6e13d83..59552828 100644 --- a/src/daemon/cpulimit.c +++ b/src/daemon/cpulimit.c @@ -24,11 +24,13 @@ #endif #include +#include #include #include #include #include +#include #include "cpulimit.h" @@ -67,7 +69,7 @@ #define CPUTIME_INTERVAL_HARD (5) /* Time of the last CPU load check */ -static time_t last_time = 0; +static pa_usec_t last_time = 0; /* Pipe for communicating with the main loop */ static int the_pipe[2] = {-1, -1}; @@ -117,20 +119,21 @@ static void signal_handler(int sig) { pa_assert(sig == SIGXCPU); if (phase == PHASE_IDLE) { - time_t now; + pa_usec_t now, elapsed; #ifdef PRINT_CPU_LOAD char t[256]; #endif - time(&now); + now = pa_rtclock_usec(); + elapsed = now - last_time; #ifdef PRINT_CPU_LOAD - pa_snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", (double)CPUTIME_INTERVAL_SOFT/(now-last_time)*100); + pa_snprintf(t, sizeof(t), "Using %0.1f%% CPU\n", ((double) CPUTIME_INTERVAL_SOFT * (double) PA_USEC_PER_SEC) / (double) elapsed * 100.0); write_err(t); #endif - if ((double) CPUTIME_INTERVAL_SOFT >= ((double) (now-last_time)*(double)CPUTIME_PERCENT/100)) { + if (((double) CPUTIME_INTERVAL_SOFT * (double) PA_USEC_PER_SEC) >= ((double) elapsed * (double) CPUTIME_PERCENT / 100.0)) { static const char c = 'X'; write_err("Soft CPU time limit exhausted, terminating.\n"); @@ -179,7 +182,7 @@ int pa_cpu_limit_init(pa_mainloop_api *m) { pa_assert(the_pipe[1] == -1); pa_assert(!installed); - time(&last_time); + last_time = pa_rtclock_usec(); /* Prepare the main loop pipe */ if (pipe(the_pipe) < 0) { -- cgit