Currently, resolve_full_path() requires executable permission for both programs and shared libraries. This causes failures on distos like Debian since the shared libraries are not installed executable and Linux is not requiring shared libraries to have executable permissions. Let's remove executable permission check for shared libraries.
Unified · Split
| @@ -10664,15 +10664,17 @@ static const char *arch_specific_lib_paths(void) · 10663 unmodified lines | ||
| 10664 | 10664 | static int resolve_full_path(const char *file, char *result, size_t result_sz) |
| 10665 | 10665 | { |
| 10666 | 10666 | const char *search_paths[3] = {}; |
| 10667 | − int i; | |
| 10667 | + int i, perm; | |
| 10668 | 10668 | |
| 10669 | 10669 | if (str_has_sfx(file, ".so") || strstr(file, ".so.")) { |
| 10670 | 10670 | search_paths[0] = getenv("LD_LIBRARY_PATH"); |
| 10671 | 10671 | search_paths[1] = "/usr/lib64:/usr/lib"; |
| 10672 | 10672 | search_paths[2] = arch_specific_lib_paths(); |
| 10673 | + perm = R_OK; | |
| 10673 | 10674 | } else { |
| 10674 | 10675 | search_paths[0] = getenv("PATH"); |
| 10675 | 10676 | search_paths[1] = "/usr/bin:/usr/sbin"; |
| 10677 | + perm = R_OK | X_OK; | |
| 10676 | 10678 | } |
| 10677 | 10679 | |
| 10678 | 10680 | for (i = 0; i < ARRAY_SIZE(search_paths); i++) { |
| @@ -10691,8 +10693,8 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz) · 12 unmodified lines | ||
| 10691 | 10693 | if (!seg_len) |
| 10692 | 10694 | continue; |
| 10693 | 10695 | snprintf(result, result_sz, "%.*s/%s", seg_len, s, file); |
| 10694 | − /* ensure it is an executable file/link */ | |
| 10695 | − if (access(result, R_OK | X_OK) < 0) | |
| 10696 | + /* ensure it has required permissions */ | |
| 10697 | + if (access(result, perm) < 0) | |
| 10696 | 10698 | continue; |
| 10697 | 10699 | pr_debug("resolved '%s' to '%s'\n", file, result); |
| 10698 | 10700 | return 0; |