add i18n support

This commit is contained in:
Lennart Poettering 2008-08-06 18:54:13 +02:00
parent c4a953dc96
commit f1d2bf8408
35 changed files with 816 additions and 414 deletions

View file

@ -28,7 +28,12 @@
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#ifdef HAVE_SYS_CAPABILITY_H
#include <sys/capability.h>
@ -37,10 +42,6 @@
#include <sys/prctl.h>
#endif
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
#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);

View file

@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/core-util.h>
#include <pulsecore/strbuf.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <pulse/xmalloc.h>
#include <pulse/timeval.h>
#include <pulse/i18n.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core-util.h>
@ -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);

View file

@ -30,6 +30,7 @@
#include <ltdl.h>
#include <pulse/util.h>
#include <pulse/i18n.h>
#include <pulsecore/modinfo.h>
#include <pulsecore/core-util.h>
@ -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)) {

View file

@ -32,13 +32,12 @@
#include <sys/dl.h>
#endif
#ifndef HAVE_STRUCT_LT_USER_DLLOADER
/* Only used with ltdl 2.2 */
#include <string.h>
#endif
#include <ltdl.h>
#include <pulse/i18n.h>
#include <pulsecore/macro.h>
#include <pulsecore/mutex.h>
#include <pulsecore/thread.h>
@ -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
}

View file

@ -64,6 +64,7 @@
#include <pulse/mainloop-signal.h>
#include <pulse/timeval.h>
#include <pulse/xmalloc.h>
#include <pulse/i18n.h>
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h>
@ -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)

View file

@ -31,6 +31,8 @@
#include <dbus/dbus.h>
#include <polkit-dbus/polkit-dbus.h>
#include <pulse/i18n.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
@ -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;