mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
Merge branch 'master' of git://0pointer.de/pulseaudio into dbus-work
Conflicts: src/Makefile.am src/daemon/daemon-conf.c src/daemon/daemon.conf.in src/modules/module-stream-restore.c src/pulse/client-conf.c src/pulsecore/namereg.c
This commit is contained in:
commit
bcaba0b1b4
134 changed files with 15076 additions and 12812 deletions
|
|
@ -101,6 +101,10 @@
|
|||
#include "rtkit.h"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/personality.h>
|
||||
#endif
|
||||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/util.h>
|
||||
#include <pulse/utf8.h>
|
||||
|
|
@ -552,12 +556,20 @@ char *pa_vsprintf_malloc(const char *format, va_list ap) {
|
|||
|
||||
/* Similar to OpenBSD's strlcpy() function */
|
||||
char *pa_strlcpy(char *b, const char *s, size_t l) {
|
||||
size_t k;
|
||||
|
||||
pa_assert(b);
|
||||
pa_assert(s);
|
||||
pa_assert(l > 0);
|
||||
|
||||
strncpy(b, s, l);
|
||||
b[l-1] = 0;
|
||||
k = strlen(s);
|
||||
|
||||
if (k > l-1)
|
||||
k = l-1;
|
||||
|
||||
memcpy(b, s, k);
|
||||
b[k] = 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
|
@ -1328,26 +1340,32 @@ int pa_unlock_lockfile(const char *fn, int fd) {
|
|||
}
|
||||
|
||||
static char *get_pulse_home(void) {
|
||||
char h[PATH_MAX];
|
||||
char *h;
|
||||
struct stat st;
|
||||
char *ret = NULL;
|
||||
|
||||
if (!pa_get_home_dir(h, sizeof(h))) {
|
||||
if (!(h = pa_get_home_dir_malloc())) {
|
||||
pa_log_error("Failed to get home directory.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat(h, &st) < 0) {
|
||||
pa_log_error("Failed to stat home directory %s: %s", h, pa_cstrerror(errno));
|
||||
return NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (st.st_uid != getuid()) {
|
||||
pa_log_error("Home directory %s not ours.", h);
|
||||
errno = EACCES;
|
||||
return NULL;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
return pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
||||
ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
||||
|
||||
finish:
|
||||
pa_xfree(h);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *pa_get_state_dir(void) {
|
||||
|
|
@ -1372,6 +1390,50 @@ char *pa_get_state_dir(void) {
|
|||
return d;
|
||||
}
|
||||
|
||||
char *pa_get_home_dir_malloc(void) {
|
||||
char *homedir;
|
||||
size_t allocated = 128;
|
||||
|
||||
for (;;) {
|
||||
homedir = pa_xmalloc(allocated);
|
||||
|
||||
if (!pa_get_home_dir(homedir, allocated)) {
|
||||
pa_xfree(homedir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strlen(homedir) < allocated - 1)
|
||||
break;
|
||||
|
||||
pa_xfree(homedir);
|
||||
allocated *= 2;
|
||||
}
|
||||
|
||||
return homedir;
|
||||
}
|
||||
|
||||
char *pa_get_binary_name_malloc(void) {
|
||||
char *t;
|
||||
size_t allocated = 128;
|
||||
|
||||
for (;;) {
|
||||
t = pa_xmalloc(allocated);
|
||||
|
||||
if (!pa_get_binary_name(t, allocated)) {
|
||||
pa_xfree(t);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strlen(t) < allocated - 1)
|
||||
break;
|
||||
|
||||
pa_xfree(t);
|
||||
allocated *= 2;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static char* make_random_dir(mode_t m) {
|
||||
static const char table[] =
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
|
|
@ -1481,7 +1543,7 @@ char *pa_get_runtime_dir(void) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
k = pa_sprintf_malloc("%s" PA_PATH_SEP "%s:runtime", d, mid);
|
||||
k = pa_sprintf_malloc("%s" PA_PATH_SEP "%s-runtime", d, mid);
|
||||
pa_xfree(d);
|
||||
pa_xfree(mid);
|
||||
|
||||
|
|
@ -1626,14 +1688,15 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
|
|||
if (local) {
|
||||
const char *e;
|
||||
char *lfn;
|
||||
char h[PATH_MAX];
|
||||
char *h;
|
||||
FILE *f;
|
||||
|
||||
if ((e = getenv("PULSE_CONFIG_PATH")))
|
||||
fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local);
|
||||
else if (pa_get_home_dir(h, sizeof(h)))
|
||||
else if ((h = pa_get_home_dir_malloc())) {
|
||||
fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local);
|
||||
else
|
||||
pa_xfree(h);
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
#ifdef OS_IS_WIN32
|
||||
|
|
@ -1713,13 +1776,14 @@ char *pa_find_config_file(const char *global, const char *local, const char *env
|
|||
if (local) {
|
||||
const char *e;
|
||||
char *lfn;
|
||||
char h[PATH_MAX];
|
||||
char *h;
|
||||
|
||||
if ((e = getenv("PULSE_CONFIG_PATH")))
|
||||
fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", e, local);
|
||||
else if (pa_get_home_dir(h, sizeof(h)))
|
||||
else if ((h = pa_get_home_dir_malloc())) {
|
||||
fn = lfn = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse" PA_PATH_SEP "%s", h, local);
|
||||
else
|
||||
pa_xfree(h);
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
#ifdef OS_IS_WIN32
|
||||
|
|
@ -1904,7 +1968,7 @@ static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s:%s", rtp, mid, fn);
|
||||
r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s-%s", rtp, mid, fn);
|
||||
pa_xfree(mid);
|
||||
} else
|
||||
r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn);
|
||||
|
|
@ -2801,3 +2865,28 @@ char* pa_maybe_prefix_path(const char *path, const char *prefix) {
|
|||
|
||||
return pa_sprintf_malloc("%s" PA_PATH_SEP "%s", prefix, path);
|
||||
}
|
||||
|
||||
size_t pa_pipe_buf(int fd) {
|
||||
|
||||
#ifdef _PC_PIPE_BUF
|
||||
long n;
|
||||
|
||||
if ((n = fpathconf(fd, _PC_PIPE_BUF)) >= 0)
|
||||
return (size_t) n;
|
||||
#endif
|
||||
|
||||
#ifdef PIPE_BUF
|
||||
return PIPE_BUF;
|
||||
#else
|
||||
return 4096;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pa_reset_personality(void) {
|
||||
|
||||
#ifdef __linux__
|
||||
if (personality(PER_LINUX) < 0)
|
||||
pa_log_warn("Uh, personality() failed: %s", pa_cstrerror(errno));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue