diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 3fbd757a..8b4293ad 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -1329,6 +1329,7 @@ int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int a { size_t len = 0; int ret = 0; + struct stat statbuf; if(dir) { char *check_path; @@ -1337,8 +1338,14 @@ int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int a CALLOC(check_path, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1)); snprintf(check_path, len, "%s%s", dir, file); - ret = access(check_path, amode); - free(check_path); + lstat(file, &statbuf); + if S_ISLNK(statbuf.st_mode) { + ret = access(dirname(file), amode); + } + else { + ret = access(check_path, amode); + free(check_path); + } } else { dir = ""; ret = access(file, amode);