Skip to content

Commit be0756f

Browse files
committed
CMake: adds a new build option to gate wordexp usage and detection
1 parent 71a2cb4 commit be0756f

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Features:
2020
* `display.key.type: "both-N"` where N is `0-4`
2121
* Useful for non-monospaced Nerd Fonts
2222
* Adds detection support for modern Samsung Exynos SoCs (CPU, Android)
23+
* Adds a new CMake option `-DENABLE_WORDEXP=<ON|OFF>` to enable or disable using `wordexp(3)` for acquiring logo file paths (`logo.source`)
24+
* Enabled by default for compatibility
25+
* Disabling this option reverts to using `glob(3)`, which is less functional but more secure
2326

2427
Bugfixes:
2528
* Avoids integer overflow when calculating swap size (#1988, Swap, Windows)

CMakeLists.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions
106106
option(INSTALL_LICENSE "Install license into /usr/share/licenses" ON)
107107
option(ENABLE_EMBEDDED_PCIIDS "Embed pci.ids into fastfetch, requires `python`" OFF)
108108
option(ENABLE_EMBEDDED_AMDGPUIDS "Embed amdgpu.ids into fastfetch, requires `python`" OFF)
109+
option(ENABLE_WORDEXP "Enable using of wordexp(3) if available, instead of glob(3)" ON)
109110

110111
set(BINARY_LINK_TYPE_OPTIONS dlopen dynamic static)
111112
set(BINARY_LINK_TYPE dlopen CACHE STRING "How to link fastfetch")
@@ -1743,18 +1744,20 @@ elseif(ANDROID)
17431744
target_link_libraries(libfastfetch
17441745
PRIVATE "m"
17451746
)
1746-
# https://github.com/termux/termux-packages/pull/7056
1747-
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
1748-
if(HAVE_LIBANDROID_WORDEXP_STATIC)
1749-
target_link_libraries(libfastfetch
1750-
PRIVATE -l:libandroid-wordexp.a
1751-
)
1752-
else()
1753-
CHECK_LIBRARY_EXISTS(android-wordexp wordexp "" HAVE_LIBANDROID_WORDEXP)
1754-
if(HAVE_LIBANDROID_WORDEXP)
1747+
if(ENABLE_WORDEXP)
1748+
# https://github.com/termux/termux-packages/pull/7056
1749+
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
1750+
if(HAVE_LIBANDROID_WORDEXP_STATIC)
17551751
target_link_libraries(libfastfetch
1756-
PRIVATE android-wordexp
1752+
PRIVATE -l:libandroid-wordexp.a
17571753
)
1754+
else()
1755+
CHECK_LIBRARY_EXISTS(android-wordexp wordexp "" HAVE_LIBANDROID_WORDEXP)
1756+
if(HAVE_LIBANDROID_WORDEXP)
1757+
target_link_libraries(libfastfetch
1758+
PRIVATE android-wordexp
1759+
)
1760+
endif()
17581761
endif()
17591762
endif()
17601763
elseif(Haiku)
@@ -1816,9 +1819,11 @@ if(NOT WIN32)
18161819
if(HAVE_UTMPX)
18171820
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX=1)
18181821
endif()
1819-
CHECK_INCLUDE_FILE("wordexp.h" HAVE_WORDEXP)
1820-
if(HAVE_WORDEXP)
1821-
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
1822+
if(ENABLE_WORDEXP)
1823+
CHECK_INCLUDE_FILE("wordexp.h" HAVE_WORDEXP)
1824+
if(HAVE_WORDEXP)
1825+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
1826+
endif()
18221827
endif()
18231828
if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT)
18241829
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)

0 commit comments

Comments
 (0)