From a5224ffa8e8b8a846a28339e7449790b35290bac Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Thu, 15 Jun 2023 09:14:14 -0500 Subject: [PATCH 1/2] Check for SO_PEERCRED in CMake build This sets the CMake variable TS_HAS_PEERCRED appropriately. --- CMakeLists.txt | 2 ++ cmake/CheckSoPeercred.cmake | 44 ++++++++++++++++++++++++++++ include/tscore/ink_config.h.cmake.in | 1 + 3 files changed, 47 insertions(+) create mode 100644 cmake/CheckSoPeercred.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b7b9d230cb5..2c983dea1ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,8 @@ include(Check128BitCas) # Find ccache include(find_ccache) +include(CheckSoPeercred) + # Check for IO faculties check_symbol_exists(IN6_IS_ADDR_UNSPECIFIED "netinet/in.h" TS_HAS_IN6_IS_ADDR_UNSPECIFIED) check_symbol_exists(SO_MARK "sys/socket.h" TS_HAS_SO_MARK) diff --git a/cmake/CheckSoPeercred.cmake b/cmake/CheckSoPeercred.cmake new file mode 100644 index 00000000000..c785a77b90f --- /dev/null +++ b/cmake/CheckSoPeercred.cmake @@ -0,0 +1,44 @@ +####################### +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor license +# agreements. See the NOTICE file distributed with this work for additional information regarding +# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# +####################### + +# CheckSoPeercred.cmake +# +# This will define the following variales +# +# TS_HAS_SO_PEERCRED +# + +set(CHECK_PROGRAM + " + #include + #include + #include + #include + #include + #include + + int + main() + { + setsockopt(0, SOL_SOCKET, SO_PEERCRED, (void*)0, 0); + return 0; + } + " +) + +include(CheckCSourceCompiles) +check_c_source_compiles("${CHECK_PROGRAM}" TS_HAS_SO_PEERCRED) diff --git a/include/tscore/ink_config.h.cmake.in b/include/tscore/ink_config.h.cmake.in index 3f5b8dd3fc6..963e5aae607 100644 --- a/include/tscore/ink_config.h.cmake.in +++ b/include/tscore/ink_config.h.cmake.in @@ -117,6 +117,7 @@ const int DEFAULT_STACKSIZE = @DEFAULT_STACK_SIZE@; #cmakedefine01 TS_HAS_TCMALLOC #cmakedefine01 TS_HAS_PROFILER #cmakedefine01 TS_HAS_SO_MARK +#cmakedefine01 TS_HAS_SO_PEERCRED #cmakedefine01 TS_USE_DIAGS #cmakedefine01 TS_USE_EPOLL #cmakedefine01 TS_USE_FAST_SDK From f4aad70f9c3a969184c4ac0fd4553d9e655d7990 Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Thu, 15 Jun 2023 10:45:13 -0500 Subject: [PATCH 2/2] Use check_symbol_exists instead of compile check --- CMakeLists.txt | 3 +-- cmake/CheckSoPeercred.cmake | 44 ------------------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 cmake/CheckSoPeercred.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c983dea1ce..9f5d387b58a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,11 +157,10 @@ include(Check128BitCas) # Find ccache include(find_ccache) -include(CheckSoPeercred) - # Check for IO faculties check_symbol_exists(IN6_IS_ADDR_UNSPECIFIED "netinet/in.h" TS_HAS_IN6_IS_ADDR_UNSPECIFIED) check_symbol_exists(SO_MARK "sys/socket.h" TS_HAS_SO_MARK) +check_symbol_exists(SO_PEERCRED "sys/socket.h" TS_HAS_SO_PEERCRED) check_symbol_exists(TLS1_3_VERSION "${OPENSSL_INCLUDE_DIR}/openssl/ssl.h" TS_USE_TLS13) check_symbol_exists(OPENSSL_NO_TLS1_3 "${OPENSSL_INCLUDE_DIR}/ssl.h" TS_NO_USE_TLS13) if(TS_NO_USE_TLS13) diff --git a/cmake/CheckSoPeercred.cmake b/cmake/CheckSoPeercred.cmake deleted file mode 100644 index c785a77b90f..00000000000 --- a/cmake/CheckSoPeercred.cmake +++ /dev/null @@ -1,44 +0,0 @@ -####################### -# -# Licensed to the Apache Software Foundation (ASF) under one or more contributor license -# agreements. See the NOTICE file distributed with this work for additional information regarding -# copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# -####################### - -# CheckSoPeercred.cmake -# -# This will define the following variales -# -# TS_HAS_SO_PEERCRED -# - -set(CHECK_PROGRAM - " - #include - #include - #include - #include - #include - #include - - int - main() - { - setsockopt(0, SOL_SOCKET, SO_PEERCRED, (void*)0, 0); - return 0; - } - " -) - -include(CheckCSourceCompiles) -check_c_source_compiles("${CHECK_PROGRAM}" TS_HAS_SO_PEERCRED)