summaryrefslogtreecommitdiffstats
path: root/src/polypcore
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-05-02 09:50:37 +0000
committerPierre Ossman <ossman@cendio.se>2006-05-02 09:50:37 +0000
commit27cee2ef52274fe0cb98eded2c7394a5069c3ce8 (patch)
treebe3ee4bd12ae0ef7ce1635ee0f1a6cd36dc7593a /src/polypcore
parent1438bd49dc9bd5b7e57f9a75c6760ae769ee37bf (diff)
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
Diffstat (limited to 'src/polypcore')
-rw-r--r--src/polypcore/authkey.c9
1 files changed, 7 insertions, 2 deletions
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");