CMake: Rename ENABLE_SANDBOX to XZ_SANDBOX

This commit is contained in:
Lasse Collin 2024-06-15 18:07:04 +03:00
parent 0fdcd0c582
commit 4250d4de32
1 changed files with 11 additions and 12 deletions

View File

@ -992,20 +992,19 @@ endif()
# landlock Require Landlock (Linux >= 5.13) and fail if not found. # landlock Require Landlock (Linux >= 5.13) and fail if not found.
set(SUPPORTED_SANDBOX_METHODS ON OFF capsicum pledge landlock) set(SUPPORTED_SANDBOX_METHODS ON OFF capsicum pledge landlock)
set(ENABLE_SANDBOX ON CACHE STRING set(XZ_SANDBOX ON CACHE STRING
"Sandboxing method to use in 'xz', 'xzdec', and 'lzmadec'") "Sandboxing method to use in 'xz', 'xzdec', and 'lzmadec'")
set_property(CACHE ENABLE_SANDBOX set_property(CACHE XZ_SANDBOX PROPERTY STRINGS "${SUPPORTED_SANDBOX_METHODS}")
PROPERTY STRINGS "${SUPPORTED_SANDBOX_METHODS}")
if(NOT ENABLE_SANDBOX IN_LIST SUPPORTED_SANDBOX_METHODS) if(NOT XZ_SANDBOX IN_LIST SUPPORTED_SANDBOX_METHODS)
message(FATAL_ERROR "'${ENABLE_SANDBOX}' is not a supported " message(FATAL_ERROR "'${XZ_SANDBOX}' is not a supported "
"sandboxing method") "sandboxing method")
endif() endif()
# When autodetecting, the search order is fixed and we must not find # When autodetecting, the search order is fixed and we must not find
# more than one method. # more than one method.
if(ENABLE_SANDBOX STREQUAL "OFF") if(XZ_SANDBOX STREQUAL "OFF")
set(SANDBOX_FOUND ON) set(SANDBOX_FOUND ON)
else() else()
set(SANDBOX_FOUND OFF) set(SANDBOX_FOUND OFF)
@ -1016,7 +1015,7 @@ endif()
set(SANDBOX_COMPILE_DEFINITION OFF) set(SANDBOX_COMPILE_DEFINITION OFF)
# Sandboxing: Capsicum # Sandboxing: Capsicum
if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^capsicum$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^capsicum$")
check_symbol_exists(cap_rights_limit sys/capsicum.h check_symbol_exists(cap_rights_limit sys/capsicum.h
HAVE_CAP_RIGHTS_LIMIT) HAVE_CAP_RIGHTS_LIMIT)
if(HAVE_CAP_RIGHTS_LIMIT) if(HAVE_CAP_RIGHTS_LIMIT)
@ -1026,7 +1025,7 @@ if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^capsicum$")
endif() endif()
# Sandboxing: pledge(2) # Sandboxing: pledge(2)
if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^pledge$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^pledge$")
check_symbol_exists(pledge unistd.h HAVE_PLEDGE) check_symbol_exists(pledge unistd.h HAVE_PLEDGE)
if(HAVE_PLEDGE) if(HAVE_PLEDGE)
set(SANDBOX_COMPILE_DEFINITION "HAVE_PLEDGE") set(SANDBOX_COMPILE_DEFINITION "HAVE_PLEDGE")
@ -1035,7 +1034,7 @@ if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^pledge$")
endif() endif()
# Sandboxing: Landlock # Sandboxing: Landlock
if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^landlock$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^landlock$")
# A compile check is done here because some systems have # A compile check is done here because some systems have
# linux/landlock.h, but do not have the syscalls defined # linux/landlock.h, but do not have the syscalls defined
# in order to actually use Linux Landlock. # in order to actually use Linux Landlock.
@ -1077,14 +1076,14 @@ if(NOT SANDBOX_FOUND AND ENABLE_SANDBOX MATCHES "^ON$|^landlock$")
message(SEND_ERROR message(SEND_ERROR
"CMAKE_C_FLAGS or the environment variable CFLAGS " "CMAKE_C_FLAGS or the environment variable CFLAGS "
"contains '-fsanitize=' which is incompatible " "contains '-fsanitize=' which is incompatible "
"with Landlock sandboxing. Use -DENABLE_SANDBOX=OFF " "with Landlock sandboxing. Use -DXZ_SANDBOX=OFF "
"as an argument to 'cmake' when using '-fsanitize'.") "as an argument to 'cmake' when using '-fsanitize'.")
endif() endif()
endif() endif()
endif() endif()
if(NOT SANDBOX_FOUND AND NOT ENABLE_SANDBOX MATCHES "^ON$|^OFF$") if(NOT SANDBOX_FOUND AND NOT XZ_SANDBOX MATCHES "^ON$|^OFF$")
message(SEND_ERROR "ENABLE_SANDBOX=${ENABLE_SANDBOX} was used but " message(SEND_ERROR "XZ_SANDBOX=${XZ_SANDBOX} was used but "
"support for the sandboxing method wasn't found.") "support for the sandboxing method wasn't found.")
endif() endif()