|
| 1 | +commit a59b141559a8c1813da438b97e5f79eeb6cc7642 |
| 2 | +Author: Benjamin Saunders <ben.e.saunders@gmail.com> |
| 3 | +Date: Sun Feb 19 11:14:24 2017 -0800 |
| 4 | + |
| 5 | + loader: Configurable fallback search paths |
| 6 | + |
| 7 | + This makes it easier for non-FHS distributions to behave well when the loader |
| 8 | + is used by a SUID process or in an otherwise unusual environment. |
| 9 | + |
| 10 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 11 | +index a43d264..d28b3f5 100644 |
| 12 | +--- a/CMakeLists.txt |
| 13 | ++++ b/CMakeLists.txt |
| 14 | +@@ -16,6 +16,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
| 15 | + find_package(PythonInterp 3 REQUIRED) |
| 16 | + |
| 17 | + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 18 | ++ set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING |
| 19 | ++ "Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.") |
| 20 | ++ set(FALLBACK_DATA_DIRS "/usr/local/share:/usr/share" CACHE STRING |
| 21 | ++ "Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.") |
| 22 | ++ |
| 23 | + include(FindPkgConfig) |
| 24 | + option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON) |
| 25 | + option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON) |
| 26 | +@@ -285,7 +290,10 @@ run_vk_xml_generate(dispatch_table_generator.py vk_dispatch_table_helper.h) |
| 27 | + if(NOT WIN32) |
| 28 | + include(GNUInstallDirs) |
| 29 | + |
| 30 | ++ add_definitions(-DFALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}") |
| 31 | ++ add_definitions(-DFALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}") |
| 32 | + add_definitions(-DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") |
| 33 | ++ |
| 34 | + # Make sure /etc is searched by the loader |
| 35 | + if(NOT (CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc")) |
| 36 | + add_definitions(-DEXTRASYSCONFDIR="/etc") |
| 37 | +diff --git a/loader/loader.c b/loader/loader.c |
| 38 | +index 81c37c4..83378eb 100644 |
| 39 | +--- a/loader/loader.c |
| 40 | ++++ b/loader/loader.c |
| 41 | +@@ -2644,9 +2644,9 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co |
| 42 | + const char *xdgconfdirs = secure_getenv("XDG_CONFIG_DIRS"); |
| 43 | + const char *xdgdatadirs = secure_getenv("XDG_DATA_DIRS"); |
| 44 | + if (xdgconfdirs == NULL || xdgconfdirs[0] == '\0') |
| 45 | +- xdgconfdirs = "/etc/xdg"; |
| 46 | ++ xdgconfdirs = FALLBACK_CONFIG_DIRS; |
| 47 | + if (xdgdatadirs == NULL || xdgdatadirs[0] == '\0') |
| 48 | +- xdgdatadirs = "/usr/local/share:/usr/share"; |
| 49 | ++ xdgdatadirs = FALLBACK_DATA_DIRS; |
| 50 | + const size_t rel_size = strlen(relative_location); |
| 51 | + // Leave space for trailing separators |
| 52 | + loc_size += strlen(xdgconfdirs) + strlen(xdgdatadirs) + 2*rel_size + 2; |
0 commit comments