From: Pierre Ossman Date: Tue, 13 Jun 2006 13:21:14 +0000 (+0000) Subject: Catch the access() system call as some applications do this to test if they X-Git-Tag: 1.0_branch~3506 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f13c43797dd291b02a6b0fa1c9933a35da95c01;p=profile%2Fivi%2Fpulseaudio.git Catch the access() system call as some applications do this to test if they can open /dev/dsp. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1016 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/src/utils/padsp.c b/src/utils/padsp.c index 8bad126..da8f678 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -101,6 +101,7 @@ static FILE* (*_fopen)(const char *path, const char *mode) = NULL; static int (*_open64)(const char *, int, mode_t) = NULL; static FILE* (*_fopen64)(const char *path, const char *mode) = NULL; static int (*_fclose)(FILE *f) = NULL; +static int (*_access)(const char *, int) = NULL; /* dlsym() violates ISO C, so confide the breakage into this function to * avoid warnings. */ @@ -141,6 +142,14 @@ do { \ pthread_mutex_unlock(&func_mutex); \ } while(0) +#define LOAD_ACCESS_FUNC() \ +do { \ + pthread_mutex_lock(&func_mutex); \ + if (!_access) \ + _access = (int (*)(const char*, int)) dlsym_fn(RTLD_NEXT, "access"); \ + pthread_mutex_unlock(&func_mutex); \ +} while(0) + #define LOAD_FOPEN_FUNC() \ do { \ pthread_mutex_lock(&func_mutex); \ @@ -1725,6 +1734,25 @@ int close(int fd) { return 0; } +int access(const char *pathname, int mode) { + debug(__FILE__": access()\n"); + + if (strcmp(pathname, "/dev/dsp") != 0 && + strcmp(pathname, "/dev/adsp") != 0 && + strcmp(pathname, "/dev/sndstat") != 0 && + strcmp(pathname, "/dev/mixer") != 0) { + LOAD_ACCESS_FUNC(); + return _access(pathname, mode); + } + + if (mode & (W_OK | X_OK)) { + errno = EACCES; + return -1; + } + + return 0; +} + int open64(const char *filename, int flags, ...) { va_list args; mode_t mode = 0;