diff options
| author | Pierre Ossman <ossman@cendio.se> | 2006-06-13 13:21:14 +0000 | 
|---|---|---|
| committer | Pierre Ossman <ossman@cendio.se> | 2006-06-13 13:21:14 +0000 | 
| commit | 0f13c43797dd291b02a6b0fa1c9933a35da95c01 (patch) | |
| tree | 65a909c8f9b9ecf8e6fd3b9d411a4c1e45bf2524 | |
| parent | b5a8815ec96708426f3a2c81629355660cea376a (diff) | |
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
| -rw-r--r-- | src/utils/padsp.c | 28 | 
1 files changed, 28 insertions, 0 deletions
diff --git a/src/utils/padsp.c b/src/utils/padsp.c index 8bad126b..da8f6786 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;  | 
