Skip to content

Commit

Permalink
# Conflicts:
Browse files Browse the repository at this point in the history
#	source/structures/accessors.h
#	source/structures/struct.h
  • Loading branch information
jholloc committed Nov 27, 2023
1 parent f604bb3 commit bb1332c
Show file tree
Hide file tree
Showing 40 changed files with 321 additions and 228 deletions.
103 changes: 83 additions & 20 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
release: [Release]
ssl: [ON, OFF]
client-only: [OFF]
Expand All @@ -31,9 +31,19 @@ jobs:

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v3

- uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install linux dependencies
if: matrix.os == 'ubuntu-latest'
run: >
Expand Down Expand Up @@ -68,10 +78,33 @@ jobs:
ninja
capnp
# - name: Cache windows packages
# id: cache-vcpkg
# uses: actions/cache@v3
# env:
# cache-name: cache-vcpkg-packages
# with:
# path: C:/vcpkg
# key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Install windows dependencies
if: matrix.os == 'windows-latest'
run: >
vcpkg install --triplet x64-mingw-static --binarysource="clear;x-gha,readwrite"
libxml2
capnproto
boost-program-options
boost-format
boost-algorithm
boost-multi-array
openssl
dlfcn-win32
spdlog
- name: Configure CMake (linux)
if: matrix.os == 'ubuntu-latest'
run: >
cmake -G Ninja -B ${{github.workspace}}/build
cmake -G Ninja -B build
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=${{ matrix.release }}
-DSSLAUTHENTICATION=${{ matrix.ssl }}
Expand All @@ -81,37 +114,67 @@ jobs:
- name: Configure CMake (macos)
if: matrix.os == 'macos-latest'
run: >
cmake -G Ninja -B ${{github.workspace}}/build
cmake -G Ninja -B build
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=${{ matrix.release }}
-DSSLAUTHENTICATION=${{ matrix.ssl }}
-DCLIENT_ONLY=${{ matrix.client-only }}
-DENABLE_CAPNP=${{ matrix.capnp }}
-DOPENSSL_ROOT_DIR="$(brew --prefix openssl@3)"
- name: Configure portable XDR
if: matrix.os == 'windows-latest'
run: >
cd extlib
&& cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -B build -G "MinGW Makefiles" .
- name: Build portable XDR
if: matrix.os == 'windows-latest'
run: cd extlib && cmake --build build

- name: Install portable XDR
if: matrix.os == 'windows-latest'
run: cd extlib && cmake --install build --prefix install

- name: Configure CMake (windows)
if: matrix.os == 'windows-latest'
run: >
XDR_ROOT=extlib/install cmake -G "MinGW Makefiles" -B build
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=${{ matrix.release }}
-DSSLAUTHENTICATION=${{ matrix.ssl }}
-DCLIENT_ONLY=${{ matrix.client-only }}
-DENABLE_CAPNP=${{ matrix.capnp }}
-DOPENSSL_ROOT_DIR="$(brew --prefix openssl@1.1)"
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{ matrix.release }}
run: cmake --build build --config ${{ matrix.release }}

- name: Install
run: sudo cmake --install ${{github.workspace}}/build --config ${{ matrix.release }}
if: matrix.os != 'windows-latest'
run: sudo cmake --install build --config ${{ matrix.release }}

- name: Install pyuda
if: matrix.os == 'ubuntu-latest'
run: >
cp -r /usr/local/python_installer ${{github.workspace}}/python_installer &&
python3 -m venv ${{github.workspace}}/venv &&
source ${{github.workspace}}/venv/bin/activate &&
pip3 install Cython numpy six &&
pip3 install ${{github.workspace}}/python_installer
- name: Install
if: matrix.os == 'windows-latest'
run: cmake --install build --config ${{ matrix.release }}

- name: Test pyuda import
if: matrix.os == 'ubuntu-latest'
run: >
source ${{github.workspace}}/venv/bin/activate &&
python3 -c 'import pyuda; client=pyuda.Client()'
# - name: Install pyuda
# if: matrix.os == 'ubuntu-latest'
# run: >
# cp -r /usr/local/python_installer ${{github.workspace}}/python_installer &&
# python3 -m venv ${{github.workspace}}/venv &&
# source ${{github.workspace}}/venv/bin/activate &&
# pip3 install Cython numpy six &&
# pip3 install ${{github.workspace}}/python_installer

# - name: Test pyuda import
# if: matrix.os == 'ubuntu-latest'
# run: >
# source ${{github.workspace}}/venv/bin/activate &&
# python3 -c 'import pyuda; client=pyuda.Client()'

# - name: Test
# working-directory: ${{github.workspace}}/build
# working-directory: build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{ matrix.release }}
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ set( CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake/Modules
${CMAKE_SOURCE_DIR}/cmake/Config
)
set( CMAKE_PREFIX_PATH ${_VCPKG_INSTALLED_DIR}/x64-mingw-static )

include( ColourMessages )
#include( ColourMessages )
include_directories( /opt/local/include )

set( Boost_USE_MULTITHREADED OFF )
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibMemcached.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ find_library( LIBMEMCACHED_LIB NAMES memcached
PATH_SUFFIXES lib lib64 )

set( LIBMEMCACHED_LIBRARIES ${LIBMEMCACHED_LIB} ${CMAKE_THREAD_LIBS_INIT} )
get_filename_component( LIBMEMCACHED_LIB_DIR ${LIBMEMCACHED_LIB} PATH CACHE )
get_filename_component( LIBMEMCACHED_LIB_DIR "${LIBMEMCACHED_LIB}" PATH CACHE )

include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( LibMemcached DEFAULT_MSG LIBMEMCACHED_LIBRARIES LIBMEMCACHED_INCLUDES )
Expand Down
8 changes: 3 additions & 5 deletions cmake/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ macro( uda_plugin )
find_package( OpenSSL REQUIRED )
if( WIN32 OR MINGW )
find_package( XDR REQUIRED )
if( NOT MINGW )
find_package( dlfcn-win32 CONFIG REQUIRED )
endif()
find_package( dlfcn-win32 CONFIG REQUIRED )
endif()

include( CMakeParseArguments )
Expand Down Expand Up @@ -90,9 +88,9 @@ macro( uda_plugin )
endif()
if( WIN32 OR MINGW )
if( MINGW )
set( LIBRARIES ${LIBRARIES} ${XDR_LIBRARIES} dl stdc++ )
set( LIBRARIES ${LIBRARIES} ${XDR_LIBRARIES} dlfcn-win32::dl stdc++ )
else()
set( LIBRARIES ${LIBRARIES} ${XDR_LIBRARIES} dlfcn-win32::dl )
set( LIBRARIES ${LIBRARIES} ${XDR_LIBRARIES} dlfcn-win32::dl )
endif()
elseif(TIRPC_FOUND)
set( LINK_LIB ${LINK_LIB} ${TIRPC_LIBRARIES})
Expand Down
6 changes: 4 additions & 2 deletions extlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cmake_minimum_required( VERSION 2.8.11 )
cmake_minimum_required( VERSION 3.14 )

add_subdirectory( portablexdr-4.9.1 )
project( extlibs )

add_subdirectory( portablexdr-4.9.1 )
15 changes: 12 additions & 3 deletions extlib/portablexdr-4.9.1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required( VERSION 2.8.11 )
cmake_minimum_required( VERSION 3.14 )

cmake_policy( SET CMP0048 NEW )

Expand All @@ -24,11 +24,20 @@ endif()
set( SOURCES xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr.c xdr_intXX_t.c xdr_rec.c xdr_stdio.c )

configure_file(
config.h.in
${CMAKE_BINARY_DIR}/config.h
config.h.in
${CMAKE_BINARY_DIR}/config.h
)

include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )

add_library( ${PROJECT_NAME} SHARED ${SOURCES} )

install(
FILES rpc/rpc.h rpc/types.h rpc/xdr.h ${CMAKE_BINARY_DIR}/config.h
DESTINATION include/rpc
)

install(
TARGETS ${PROJECT_NAME}
DESTINATION lib
)
17 changes: 13 additions & 4 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if( NOT CLIENT_ONLY )
include( LibXml2StrPrintfConfig )
endif()
set( CMAKE_PREFIX_PATH ${_VCPKG_INSTALLED_DIR}/x64-mingw-static )
find_package( Boost 1.60 REQUIRED )
include_directories( SYSTEM ${Boost_INCLUDE_DIR} )

Expand All @@ -19,7 +20,10 @@ if( WIN32 AND NOT MINGW )
else()
add_definitions( -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers )
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 5.0 )
add_definitions( -Wno-format-truncation -Wno-format-overflow -Wno-use-after-free )
add_definitions( -Wno-format-truncation -Wno-format-overflow )
if( NOT MINGW )
add_definitions( -Wno-use-after-free )
endif()
endif()
endif()

Expand All @@ -38,7 +42,7 @@ add_subdirectory( authentication )
add_subdirectory( structures )
add_subdirectory( clientserver )
add_subdirectory( client )
add_subdirectory( client2 )
#add_subdirectory( client2 )
if( ENABLE_CAPNP )
add_compile_definitions( CAPNP_ENABLED=1 )
add_subdirectory( serialisation )
Expand All @@ -50,7 +54,7 @@ endif()

if( NOT CLIENT_ONLY )
add_subdirectory( server )
add_subdirectory( server2 )
# add_subdirectory( server2 )
add_subdirectory( plugins )
endif()

Expand Down Expand Up @@ -96,11 +100,16 @@ set( PKGCONFIG_FILES
uda-plugins.pc
)

get_filename_component( LIBXML_LIB_DIR ${LIBXML2_LIBRARIES} DIRECTORY )
get_filename_component( LIBXML_LIB_DIR "${LIBXML2_LIBRARIES}" DIRECTORY )
set( PKGCONFIG_LIBRARIES "-L${LIBXML_LIB_DIR} -lxml2" )
set( PKGCONFIG_INCLUDES "-I${LIBXML2_INCLUDE_DIR}" )
set( PKGCONFIG_REQUIRES fmt )

find_package( TIRPC QUIET )
if( TIRPC_FOUND )
set( PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES} libtirpc" )
endif()

if( ENABLE_CAPNP )
set( PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES} capnp" )
set( PKGCONFIG_LIBRARIES "${PKGCONFIG_LIBRARIES} -luda_serialisation" )
Expand Down
2 changes: 2 additions & 0 deletions source/authentication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ elseif( TIRPC_FOUND )
endif()

add_library( authentication-client-objects OBJECT udaClientSSL.cpp udaClientSSL.h udaServerSSL.h )
target_link_libraries( authentication-client-objects OpenSSL::SSL LibXml2::LibXml2 )

if( NOT CLIENT_ONLY )
add_library( authentication-server-objects OBJECT udaServerSSL.cpp udaClientSSL.h )
target_compile_definitions( authentication-server-objects PRIVATE -DSERVERBUILD )
target_link_libraries( authentication-server-objects OpenSSL::SSL LibXml2::LibXml2 )
endif()
2 changes: 1 addition & 1 deletion source/authentication/udaClientSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdio>
#include <fcntl.h>
#include <time.h>
#include <openssl/ssl.h>

#include <client/updateSelectParms.h>
#include <clientserver/errorLog.h>
Expand Down Expand Up @@ -392,7 +393,6 @@ int startUdaClientSSL()
}

// Get the Server certificate and verify

X509* peer = SSL_get_peer_certificate(g_ssl);

if (peer != nullptr) {
Expand Down
9 changes: 9 additions & 0 deletions source/authentication/udaServerSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/asn1.h>
#include <fcntl.h>

#include <clientserver/errorLog.h>
#include <logging/logging.h>
Expand Down Expand Up @@ -426,12 +427,14 @@ int writeUdaServerSSL(void* iohandle, const char* buf, int count)
return -1;
}

#ifndef _WIN32
int fopts = 0;
if (fcntl(g_sslSocket, F_GETFL, &fopts) < 0 || errno == EBADF) {
// Is the socket closed? Check status flags
UDA_LOG(UDA_LOG_DEBUG, "Client Socket is closed! Closing server down.\n");
return -1;
}
#endif

*io_data->server_tot_block_time += tv.tv_usec / 1000;

Expand Down Expand Up @@ -461,11 +464,13 @@ int writeUdaServerSSL(void* iohandle, const char* buf, int count)
reportServerSSLErrorCode(rc);
UDA_LOG(UDA_LOG_DEBUG, "Write to socket failed!\n");
UDA_ADD_ERROR(999, "Write to socket failed!");
#ifndef _WIN32
int fopts = 0;
if (fcntl(g_sslSocket, F_GETFL, &fopts) < 0 || errno == EBADF) {
// Is the socket closed? Check status flags
UDA_LOG(UDA_LOG_DEBUG, "Client Socket is closed! Closing server down.\n");
}
#endif
return -1;
}

Expand Down Expand Up @@ -508,12 +513,14 @@ int readUdaServerSSL(void* iohandle, char* buf, int count)
return -1;
}

#ifndef _WIN32
int fopts = 0;
if (fcntl(g_sslSocket, F_GETFL, &fopts) < 0 || errno == EBADF) {
// Is the socket closed? Check status flags
UDA_LOG(UDA_LOG_DEBUG, "Client Socket is closed! Closing server down.\n");
return -1;
}
#endif

updateSelectParms(g_sslSocket, &rfds, &tv, *io_data->server_tot_block_time); // Keep blocking and wait for data
tvc = tv;
Expand Down Expand Up @@ -556,11 +563,13 @@ int readUdaServerSSL(void* iohandle, char* buf, int count)
reportServerSSLErrorCode(rc);
UDA_LOG(UDA_LOG_DEBUG, "Read from socket failed!\n");
UDA_ADD_ERROR(999, "Read from socket failed!");
#ifndef _WIN32
int fopts = 0;
if ((rc = fcntl(g_sslSocket, F_GETFL, &fopts)) < 0 ||
errno == EBADF) { // Is the socket closed? Check status flags
UDA_LOG(UDA_LOG_DEBUG, "writeUdaServerSSL: Client Socket is closed! Closing server down.\n");
}
#endif
return -1;
}

Expand Down
Loading

0 comments on commit bb1332c

Please sign in to comment.