default_library_paths_ = library_paths;
}
+ const std::vector<std::string>& get_permitted_paths() const {
+ return permitted_paths_;
+ }
void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
permitted_paths_ = permitted_paths;
}
}
} else {
// do not load libraries if they are not accessible for the specified namespace.
- DL_ERR("library \"%s\" is not accessible for the namespace \"%s\"",
- name, ns->get_name());
+ const char* needed_or_dlopened_by = task->get_needed_by() == nullptr ?
+ "(unknown)" :
+ task->get_needed_by()->get_realpath();
+
+ DL_ERR("library \"%s\" needed or dlopened by \"%s\" is not accessible for the namespace \"%s\"",
+ name, needed_or_dlopened_by, ns->get_name());
+
+ PRINT("library \"%s\" (\"%s\") needed or dlopened by \"%s\" is not accessible for the"
+ " namespace: [name=\"%s\", ld_library_paths=\"%s\", default_library_paths=\"%s\","
+ " permitted_paths=\"%s\"]",
+ name, realpath.c_str(),
+ needed_or_dlopened_by,
+ ns->get_name(),
+ android::base::Join(ns->get_ld_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_default_library_paths(), ':').c_str(),
+ android::base::Join(ns->get_permitted_paths(), ':').c_str());
return false;
}
}
// Check dlopen by absolute path
handle2 = android_dlopen_ext(lib_private_external_path.c_str(), RTLD_NOW, &extinfo);
ASSERT_TRUE(handle2 == nullptr);
- ASSERT_EQ("dlopen failed: library \"" + lib_private_external_path + "\" is not accessible for the namespace \"private_isolated1\"", dlerror());
+ ASSERT_EQ("dlopen failed: library \"" + lib_private_external_path + "\" needed"
+ " or dlopened by \"" + get_executable_name() + "\" is not accessible"
+ " for the namespace \"private_isolated1\"", dlerror());
extinfo.library_namespace = ns_isolated2;
// Check dlopen by absolute path
handle2 = android_dlopen_ext(lib_private_external_path.c_str(), RTLD_NOW, &extinfo);
ASSERT_TRUE(handle2 == nullptr);
- ASSERT_EQ("dlopen failed: library \"" + lib_private_external_path + "\" is not accessible for the namespace \"private_isolated_shared\"", dlerror());
+ ASSERT_EQ("dlopen failed: library \"" + lib_private_external_path + "\" needed"
+ " or dlopened by \"" + get_executable_name() + "\" is not accessible"
+ " for the namespace \"private_isolated_shared\"", dlerror());
// load libnstest_root.so to shared namespace in order to check that everything is different
// except shared libnstest_dlopened.so
#endif
+static std::string g_executable_name;
+
+const std::string& get_executable_name() {
+ return g_executable_name;
+}
+
namespace testing {
namespace internal {
}
int main(int argc, char** argv) {
+ g_executable_name = argv[0];
std::vector<char*> arg_list;
for (int i = 0; i < argc; ++i) {
arg_list.push_back(argv[i]);
ASSERT_EQ(expected_exit_status, WEXITSTATUS(status));
}
+const std::string& get_executable_name();
+
#endif