From 27cee2ef52274fe0cb98eded2c7394a5069c3ce8 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 2 May 2006 09:50:37 +0000 Subject: We need to read the cookie in binary mode for things to work correctly. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@825 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/polypcore/authkey.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/polypcore') diff --git a/src/polypcore/authkey.c b/src/polypcore/authkey.c index 80480c16..6eafb672 100644 --- a/src/polypcore/authkey.c +++ b/src/polypcore/authkey.c @@ -59,6 +59,10 @@ static int generate(int fd, void *ret_data, size_t length) { return 0; } +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /* Load an euthorization cookie from file fn and store it in data. If * the cookie file doesn't exist, create it */ static int load(const char *fn, void *data, size_t length) { @@ -68,8 +72,8 @@ static int load(const char *fn, void *data, size_t length) { ssize_t r; assert(fn && data && length); - if ((fd = open(fn, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR)) < 0) { - if (errno != EACCES || (fd = open(fn, O_RDONLY)) < 0) { + if ((fd = open(fn, O_RDWR|O_CREAT|O_BINARY, S_IRUSR|S_IWUSR)) < 0) { + if (errno != EACCES || (fd = open(fn, O_RDONLY|O_BINARY)) < 0) { pa_log(__FILE__": failed to open cookie file '%s': %s", fn, strerror(errno)); goto finish; } else @@ -84,6 +88,7 @@ static int load(const char *fn, void *data, size_t length) { } if ((size_t) r != length) { + pa_log_debug(__FILE__": got %d bytes from cookie file '%s', expected %d", (int)r, fn, (int)length); if (!writable) { pa_log(__FILE__": unable to write cookie to read only file"); -- cgit