Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTCONDOR-2389 add 3rd party zip_view so we don't have to wait for C++23 #2420

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/cmake/CondorConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ set (FMT_INSTALL false)

add_subdirectory(${CONDOR_SOURCE_DIR}/src/vendor/fmt-10.1.0)

# Remove when we have C++23 everywhere
include_directories(${CONDOR_SOURCE_DIR}/src/vendor/zip-views-1.0)

# But don't try to install the header files anywhere
set_target_properties(fmt PROPERTIES PUBLIC_HEADER "")
install(TARGETS fmt
Expand Down
21 changes: 9 additions & 12 deletions src/condor_io/condor_auth_ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
#include <iomanip>
#include <string.h>

// remove when we have C++ 23 everywhere
#include "zip_view.hpp"

#include "condor_daemon_core.h"

GCC_DIAG_OFF(float-equal)
Expand Down Expand Up @@ -2116,27 +2119,21 @@ Condor_Auth_SSL::should_try_auth()

StringTokenIterator certfile_list(certfile, ",");
StringTokenIterator keyfile_list(keyfile, ",");
keyfile_list.rewind();
const char *cert, *key;

std::string last_error;
while ((cert = certfile_list.next())) {
key = keyfile_list.next();
if (key == nullptr) {
last_error = formatstr(last_error, "No key to match the certificate %s", cert);
break;
}
for (const auto &[cert, key]: c9::zip(certfile_list, keyfile_list)) {
TemporaryPrivSentry sentry(PRIV_ROOT);
int fd = open(cert, O_RDONLY);
int fd = open(cert.c_str(), O_RDONLY);
if (fd < 0) {
formatstr(last_error, "Not trying SSL auth because server certificate"
" (%s) is not readable by HTCondor: %s.\n", cert, strerror(errno));
" (%s) is not readable by HTCondor: %s.\n", cert.c_str(), strerror(errno));
continue;
}
close(fd);
fd = open(key, O_RDONLY);
fd = open(key.c_str(), O_RDONLY);
if (fd < 0) {
formatstr(last_error, "Not trying SSL auth because server key"
" (%s) is not readable by HTCondor: %s.\n", key, strerror(errno));
" (%s) is not readable by HTCondor: %s.\n", key.c_str(), strerror(errno));
continue;
}
close(fd);
Expand Down
14 changes: 14 additions & 0 deletions src/vendor/zip-views-1.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CMake gitignore

CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
build/*
15 changes: 15 additions & 0 deletions src/vendor/zip-views-1.0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.12)
project(ZipViews)

option(ZIP_VIEW_BUILD_TEST "Build test" ON)

add_library(zip-view INTERFACE)
target_include_directories(zip-view INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(zip-view INTERFACE cxx_std_20)

if (ZIP_VIEW_BUILD_TEST)
add_executable(test-zip-view test_zip_view.cpp)
target_link_libraries(test-zip-view zip-view)

add_test(test-zip-view test-zip-view)
endif()
18 changes: 18 additions & 0 deletions src/vendor/zip-views-1.0/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2020 CommitThis Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.