History

libbpf: Do not require executable permission for shared libraries

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.

Hengqi Chen committed 4 years ago

Commit 9e320841 parent 0c9a7a71 file · +5 −3Browse files

Unified · Split

tools/lib/bpf/libbpf.c+5−3
@@ -10664,15 +10664,17 @@ static const char *arch_specific_lib_paths(void) · 10663 unmodified lines
10664static int resolve_full_path(const char *file, char *result, size_t result_sz)10664static int resolve_full_path(const char *file, char *result, size_t result_sz)
10665{10665{
10666 const char *search_paths[3] = {};10666 const char *search_paths[3] = {};
10667 int i;10667 int i, perm;
10668 10668
10669 if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {10669 if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {
10670 search_paths[0] = getenv("LD_LIBRARY_PATH");10670 search_paths[0] = getenv("LD_LIBRARY_PATH");
10671 search_paths[1] = "/usr/lib64:/usr/lib";10671 search_paths[1] = "/usr/lib64:/usr/lib";
10672 search_paths[2] = arch_specific_lib_paths();10672 search_paths[2] = arch_specific_lib_paths();
10673 perm = R_OK;
10673 } else {10674 } else {
10674 search_paths[0] = getenv("PATH");10675 search_paths[0] = getenv("PATH");
10675 search_paths[1] = "/usr/bin:/usr/sbin";10676 search_paths[1] = "/usr/bin:/usr/sbin";
10677 perm = R_OK | X_OK;
10676 }10678 }
10677 10679
10678 for (i = 0; i < ARRAY_SIZE(search_paths); i++) {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 if (!seg_len)10693 if (!seg_len)
10692 continue;10694 continue;
10693 snprintf(result, result_sz, "%.*s/%s", seg_len, s, file);10695 snprintf(result, result_sz, "%.*s/%s", seg_len, s, file);
10694 /* ensure it is an executable file/link */10696 /* ensure it has required permissions */
10695 if (access(result, R_OK | X_OK) < 0)10697 if (access(result, perm) < 0)
10696 continue;10698 continue;
10697 pr_debug("resolved '%s' to '%s'\n", file, result);10699 pr_debug("resolved '%s' to '%s'\n", file, result);
10698 return 0;10700 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t