diff options
author | Lennart Poettering <lennart@poettering.net> | 2004-09-28 22:47:48 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2004-09-28 22:47:48 +0000 |
commit | 6f59ae1763ee48f27448a7de9d635f61886052e1 (patch) | |
tree | e83ab47226b6c716c200e9fa40f44668997eb642 /polyp/authkey.c | |
parent | 450ad85b35bd600ed020f7ec119d51e7e7bc01a4 (diff) |
Add module-tunnel
add proper locking when autospawning a daemon
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@245 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/authkey.c')
-rw-r--r-- | polyp/authkey.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/polyp/authkey.c b/polyp/authkey.c index 1e2edb07..c8d8576b 100644 --- a/polyp/authkey.c +++ b/polyp/authkey.c @@ -97,7 +97,7 @@ static int load(const char *fn, void *data, size_t length) { writable = 0; } - unlock = pa_lock_file(fd, 1) >= 0; + unlock = pa_lock_fd(fd, 1) >= 0; if ((r = pa_loop_read(fd, data, length)) < 0) { pa_log(__FILE__": failed to read cookie file '%s'\n", fn); @@ -122,7 +122,7 @@ finish: if (fd >= 0) { if (unlock) - pa_lock_file(fd, 0); + pa_lock_fd(fd, 0); close(fd); } @@ -147,15 +147,19 @@ int pa_authkey_load(const char *path, void *data, size_t length) { int pa_authkey_load_from_home(const char *fn, void *data, size_t length) { char *home; char path[PATH_MAX]; + char *p; assert(fn && data && length); - - if (!(home = getenv("HOME"))) - return -2; - - snprintf(path, sizeof(path), "%s/%s", home, fn); - return pa_authkey_load(path, data, length); + if (fn[0] != '/') { + if (!(home = getenv("HOME"))) + return -2; + + snprintf(p = path, sizeof(path), "%s/%s", home, fn); + } else + p = fn; + + return pa_authkey_load(p, data, length); } int pa_authkey_load_auto(const char *fn, void *data, size_t length) { |