mirror of
https://gitee.com/openharmony/third_party_vulkan-loader
synced 2024-11-23 07:10:23 +00:00
make secure_getenv discovery project wide
Since the tests need to know if secure_getenv exists or not, the detection and setup logic is now in the top level CMakeLists.txt.
This commit is contained in:
parent
7e55b0d86e
commit
eac5f00928
@ -327,6 +327,23 @@ endif()
|
||||
# Add git branch and tag info in debug mode
|
||||
target_compile_definitions(loader_common_options INTERFACE $<$<CONFIG:DEBUG>:DEBUG;GIT_BRANCH_NAME=${GIT_BRANCH_NAME};GIT_TAG_INFO=${GIT_TAG_INFO}>)
|
||||
|
||||
# Check for the existance of the secure_getenv or __secure_getenv commands
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
check_function_exists(secure_getenv HAVE_SECURE_GETENV)
|
||||
check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
|
||||
|
||||
if (HAVE_SECURE_GETENV)
|
||||
target_compile_definitions(loader_common_options INTERFACE HAVE_SECURE_GETENV)
|
||||
endif()
|
||||
if (HAVE___SECURE_GETENV)
|
||||
target_compile_definitions(loader_common_options INTERFACE HAVE___SECURE_GETENV)
|
||||
endif()
|
||||
if(NOT MSVC AND NOT (HAVE_SECURE_GETENV OR HAVE___SECURE_GETENV))
|
||||
message(WARNING "Using non-secure environmental lookups. This loader will not properly disable environent variables when run with elevated permissions.")
|
||||
endif()
|
||||
|
||||
# Optional codegen target
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_target(VulkanLoader_generated_source
|
||||
|
@ -24,23 +24,6 @@ add_library(loader_specific_options INTERFACE)
|
||||
target_link_libraries(loader_specific_options INTERFACE loader_common_options Vulkan::Headers)
|
||||
target_include_directories(loader_specific_options INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/generated ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Check for the existance of the secure_getenv or __secure_getenv commands
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
check_function_exists(secure_getenv HAVE_SECURE_GETENV)
|
||||
check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
|
||||
|
||||
if (HAVE_SECURE_GETENV)
|
||||
target_compile_definitions(loader_specific_options INTERFACE HAVE_SECURE_GETENV)
|
||||
endif()
|
||||
if (HAVE___SECURE_GETENV)
|
||||
target_compile_definitions(loader_specific_options INTERFACE HAVE___SECURE_GETENV)
|
||||
endif()
|
||||
if(NOT MSVC AND NOT (HAVE_SECURE_GETENV OR HAVE___SECURE_GETENV))
|
||||
message(WARNING "Using non-secure environmental lookups. This loader will not properly disable environent variables when run with elevated permissions.")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
# Use static MSVCRT libraries
|
||||
|
@ -25,10 +25,6 @@
|
||||
* Author: Charles Giessen <charles@lunarg.com>
|
||||
*/
|
||||
|
||||
#if !defined(VULKAN_NON_CMAKE_BUILD)
|
||||
#include "loader_cmake_config.h"
|
||||
#endif // !defined(VULKAN_NON_CMAKE_BUILD)
|
||||
|
||||
#include "shim.h"
|
||||
|
||||
static PlatformShim platform_shim;
|
||||
@ -165,7 +161,7 @@ FRAMEWORK_EXPORT gid_t GETEGID_FUNC_NAME(void) {
|
||||
}
|
||||
|
||||
#if defined(HAVE_SECURE_GETENV)
|
||||
FRAMEWORK_EXPORT char* SECURE_GETENV_FUNC_NAME(const char *name) {
|
||||
FRAMEWORK_EXPORT char* SECURE_GETENV_FUNC_NAME(const char* name) {
|
||||
if (!real_secure_getenv) real_secure_getenv = (PFN_SEC_GETENV)dlsym(RTLD_NEXT, "secure_getenv");
|
||||
|
||||
if (platform_shim.use_fake_elevation) {
|
||||
@ -176,7 +172,7 @@ FRAMEWORK_EXPORT char* SECURE_GETENV_FUNC_NAME(const char *name) {
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE___SECURE_GETENV)
|
||||
FRAMEWORK_EXPORT char* __SECURE_GETENV_FUNC_NAME(const char *name) {
|
||||
FRAMEWORK_EXPORT char* __SECURE_GETENV_FUNC_NAME(const char* name) {
|
||||
if (!real__secure_getenv) real__secure_getenv = (PFN_SEC_GETENV)dlsym(RTLD_NEXT, "__secure_getenv");
|
||||
|
||||
if (platform_shim.use_fake_elevation) {
|
||||
@ -206,10 +202,12 @@ __attribute__((used)) static Interposer _interpose_fopen MACOS_ATTRIB = {VOIDP_C
|
||||
__attribute__((used)) static Interposer _interpose_euid MACOS_ATTRIB = {VOIDP_CAST(my_geteuid), VOIDP_CAST(geteuid)};
|
||||
__attribute__((used)) static Interposer _interpose_egid MACOS_ATTRIB = {VOIDP_CAST(my_getegid), VOIDP_CAST(getegid)};
|
||||
#if defined(HAVE_SECURE_GETENV)
|
||||
__attribute__((used)) static Interposer _interpose_secure_getenv MACOS_ATTRIB = {VOIDP_CAST(my_secure_getenv), VOIDP_CAST(secure_getenv)};
|
||||
__attribute__((used)) static Interposer _interpose_secure_getenv MACOS_ATTRIB = {VOIDP_CAST(my_secure_getenv),
|
||||
VOIDP_CAST(secure_getenv)};
|
||||
#endif
|
||||
#if defined(HAVE___SECURE_GETENV)
|
||||
__attribute__((used)) static Interposer _interpose__secure_getenv MACOS_ATTRIB = {VOIDP_CAST(my__secure_getenv), VOIDP_CAST(__secure_getenv)};
|
||||
__attribute__((used)) static Interposer _interpose__secure_getenv MACOS_ATTRIB = {VOIDP_CAST(my__secure_getenv),
|
||||
VOIDP_CAST(__secure_getenv)};
|
||||
#endif
|
||||
#endif
|
||||
} // extern "C"
|
||||
|
Loading…
Reference in New Issue
Block a user