mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
merge main into lib
This commit is contained in:
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -49,6 +49,7 @@ jobs:
|
||||
${{github.workspace}}/build/mscp_${{env.VERSION}}-ubuntu-22.04-x86_64.deb
|
||||
${{github.workspace}}/build/mscp_${{env.VERSION}}-centos-8-x86_64.rpm
|
||||
${{github.workspace}}/build/mscp_${{env.VERSION}}-rocky-8.6-x86_64.rpm
|
||||
${{github.workspace}}/build/mscp_${{env.VERSION}}-apline-3.17-x86_64.static
|
||||
|
||||
source-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
build
|
||||
html
|
||||
compile_commands.json
|
||||
CMakeUserPresets.json
|
||||
.*.swp
|
||||
|
||||
@@ -9,33 +9,50 @@ project(mscp
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
|
||||
# add libssh static library
|
||||
add_subdirectory(libssh EXCLUDE_FROM_ALL)
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND CMAKE_PREFIX_PATH /usr/local) # intel mac homebrew prefix
|
||||
list(APPEND CMAKE_PREFIX_PATH /opt/homebrew) # arm mac homebrew prefix
|
||||
endif() # APPLE
|
||||
|
||||
|
||||
set(MSCP_LINK_LIBS m pthread)
|
||||
set(MSCP_LINK_DIRS "")
|
||||
option(BUILD_CONAN OFF) # Build mscp with conan
|
||||
if(BUILD_CONAN)
|
||||
message(STATUS "Build mscp with conan")
|
||||
endif()
|
||||
|
||||
option(BUILD_STATIC OFF) # Build mscp with -static LD flag
|
||||
if (BUILD_STATIC)
|
||||
message(STATUS "Build mscp with -static LD option")
|
||||
if (NOT BUILD_CONAN)
|
||||
message(WARNING
|
||||
"BUILD_STATIC strongly recommended with BUILD_CONAN option")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# add libssh static library
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
set(WITH_SERVER OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(WITH_EXAMPLES OFF)
|
||||
set(BUILD_STATIC_LIB ON)
|
||||
if(BUILD_CONAN)
|
||||
message(STATUS
|
||||
"Disable libssh GSSAPI support because libkrb5 doesn't exist in conan")
|
||||
set(WITH_GSSAPI OFF)
|
||||
endif()
|
||||
add_subdirectory(libssh EXCLUDE_FROM_ALL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(MSCP_COMPILE_OPTS "")
|
||||
set(MSCP_INCLUDE_DIRS ${mscp_SOURCE_DIR}/src)
|
||||
|
||||
list(APPEND MSCP_COMPILE_OPTS -iquote ${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
|
||||
list(APPEND MSCP_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
|
||||
list(APPEND MSCP_LINK_LIBS ssh-static)
|
||||
|
||||
find_package(GSSAPI)
|
||||
list(APPEND MSCP_LINK_LIBS ${GSSAPI_LIBRARIES})
|
||||
|
||||
find_package(OpenSSL)
|
||||
list(APPEND MSCP_LINK_LIBS ${OPENSSL_LIBRARIES})
|
||||
|
||||
find_package(ZLIB)
|
||||
list(APPEND MSCP_LINK_LIBS ${ZLIB_LIBRARIES})
|
||||
|
||||
|
||||
|
||||
@@ -44,8 +61,6 @@ set(LIBMSCP_SRC src/mscp.c src/ssh.c src/path.c src/platform.c src/message.c)
|
||||
# shared libmscp
|
||||
add_library(mscp-shared SHARED ${LIBMSCP_SRC})
|
||||
target_include_directories(mscp-shared PRIVATE ${MSCP_INCLUDE_DIRS})
|
||||
target_link_directories(mscp-shared PRIVATE ${MSCP_LINK_DIRS})
|
||||
target_link_libraries(mscp-shared PRIVATE ${MSCP_LINK_LIBS})
|
||||
target_compile_options(mscp-shared PRIVATE ${MSCP_COMPILE_OPTS})
|
||||
set_target_properties(mscp-shared
|
||||
PROPERTIES
|
||||
@@ -54,18 +69,35 @@ set_target_properties(mscp-shared
|
||||
# static libmscp
|
||||
add_library(mscp-static STATIC ${LIBMSCP_SRC})
|
||||
target_include_directories(mscp-static PRIVATE ${MSCP_INCLUDE_DIRS})
|
||||
target_link_directories(mscp-static PRIVATE ${MSCP_LINK_DIRS})
|
||||
target_link_libraries(mscp-static PRIVATE ${MSCP_LINK_LIBS})
|
||||
target_compile_options(mscp-static PRIVATE ${MSCP_COMPILE_OPTS})
|
||||
set_target_properties(mscp-static
|
||||
PROPERTIES
|
||||
OUTPUT_NAME mscp)
|
||||
|
||||
|
||||
|
||||
|
||||
set(MSCP_LINK_LIBS m pthread)
|
||||
set(MSCP_LINK_DIRS "")
|
||||
list(APPEND MSCP_LINK_LIBS ssh-static)
|
||||
|
||||
if(BUILD_CONAN)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
list(APPEND MSCP_LINK_LIBS ZLIB::ZLIB)
|
||||
list(APPEND MSCP_LINK_LIBS OpenSSL::Crypto)
|
||||
endif()
|
||||
|
||||
# mscp executable
|
||||
add_executable(mscp src/main.c)
|
||||
target_include_directories(mscp PRIVATE ${MSCP_INCLUDE_DIRS})
|
||||
target_link_directories(mscp PRIVATE ${MSCP_LINK_DIRS})
|
||||
target_link_libraries(mscp mscp-static ${MSCP_LINK_LIBS})
|
||||
if (BUILD_STATIC)
|
||||
target_link_options(mscp PRIVATE -static)
|
||||
endif()
|
||||
target_compile_options(mscp PRIVATE ${MSCP_COMPILE_OPTS})
|
||||
target_compile_definitions(mscp PUBLIC _VERSION="${PROJECT_VERSION}")
|
||||
target_link_libraries(mscp mscp-static)
|
||||
|
||||
|
||||
install(TARGETS mscp RUNTIME DESTINATION bin)
|
||||
@@ -123,9 +155,9 @@ include(CPack)
|
||||
# Custom targets to build and test mscp in docker containers.
|
||||
# foreach(IN ZIP_LISTS) (cmake >= 3.17) can shorten the following lists.
|
||||
# However, ubuntu 20.04 has cmake 3.16.3. So this is a roundabout trick.
|
||||
list(APPEND DIST_NAMES ubuntu ubuntu centos rocky)
|
||||
list(APPEND DIST_VERS 20.04 22.04 8 8.6)
|
||||
list(APPEND DIST_PKGS deb deb rpm rpm)
|
||||
list(APPEND DIST_NAMES ubuntu ubuntu centos rocky alpine)
|
||||
list(APPEND DIST_VERS 20.04 22.04 8 8.6 3.17)
|
||||
list(APPEND DIST_PKGS deb deb rpm rpm static)
|
||||
|
||||
list(LENGTH DIST_NAMES _DIST_LISTLEN)
|
||||
math(EXPR DIST_LISTLEN "${_DIST_LISTLEN} - 1")
|
||||
|
||||
7
conanfile.txt
Normal file
7
conanfile.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
[requires]
|
||||
zlib/1.2.11
|
||||
openssl/1.1.1t
|
||||
|
||||
[generators]
|
||||
CMakeDeps
|
||||
CMakeToolchain
|
||||
35
docker/alpine-3.17.Dockerfile
Normal file
35
docker/alpine-3.17.Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM alpine:3.17
|
||||
|
||||
# Build mscp with conan to create single binary mscp
|
||||
|
||||
ARG mscpdir="/mscp"
|
||||
|
||||
COPY . ${mscpdir}
|
||||
|
||||
RUN apk add --no-cache \
|
||||
gcc make cmake python3 py3-pip perl linux-headers libc-dev \
|
||||
openssh bash python3-dev g++
|
||||
|
||||
RUN pip3 install conan pytest numpy
|
||||
|
||||
# Build mscp as a single binary
|
||||
RUN conan profile detect --force
|
||||
RUN cd ${mscpdir} \
|
||||
&& rm -rf build \
|
||||
&& conan install . --output-folder=build --build=missing \
|
||||
&& cd ${mscpdir}/build \
|
||||
&& cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
|
||||
-DBUILD_STATIC=ON -DBUILD_CONAN=ON \
|
||||
&& make \
|
||||
&& cp mscp /usr/bin/ \
|
||||
&& cp mscp /mscp/build/mscp_0.0.6-alpine-3.17-x86_64.static
|
||||
|
||||
# copy mscp to PKG FILE NAME because this build doesn't use CPACK
|
||||
|
||||
# preparation for sshd
|
||||
RUN ssh-keygen -A
|
||||
RUN mkdir /var/run/sshd \
|
||||
&& ssh-keygen -f /root/.ssh/id_rsa -N "" \
|
||||
&& mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
|
||||
@@ -1,48 +1,3 @@
|
||||
diff --git a/DefineOptions.cmake b/DefineOptions.cmake
|
||||
index 068db988..5fc3c8fc 100644
|
||||
--- a/DefineOptions.cmake
|
||||
+++ b/DefineOptions.cmake
|
||||
@@ -1,7 +1,7 @@
|
||||
option(WITH_GSSAPI "Build with GSSAPI support" ON)
|
||||
option(WITH_ZLIB "Build with ZLIB support" ON)
|
||||
option(WITH_SFTP "Build with SFTP support" ON)
|
||||
-option(WITH_SERVER "Build with SSH server support" ON)
|
||||
+option(WITH_SERVER "Build with SSH server support" OFF)
|
||||
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
|
||||
option(WITH_DEBUG_PACKET "Build with packet debug output" OFF)
|
||||
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
|
||||
@@ -11,13 +11,13 @@ option(WITH_MBEDTLS "Compile against libmbedtls" OFF)
|
||||
option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF)
|
||||
option(WITH_PCAP "Compile with Pcap generation support" ON)
|
||||
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
|
||||
-option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
+option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(WITH_PKCS11_URI "Build with PKCS#11 URI support" OFF)
|
||||
option(UNIT_TESTING "Build with unit tests" OFF)
|
||||
option(CLIENT_TESTING "Build with client tests; requires openssh" OFF)
|
||||
option(SERVER_TESTING "Build with server tests; requires openssh and dropbear" OFF)
|
||||
option(WITH_BENCHMARKS "Build benchmarks tools" OFF)
|
||||
-option(WITH_EXAMPLES "Build examples" ON)
|
||||
+option(WITH_EXAMPLES "Build examples" OFF)
|
||||
option(WITH_NACL "Build with libnacl (curve25519)" ON)
|
||||
option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON)
|
||||
option(WITH_ABI_BREAK "Allow ABI break" OFF)
|
||||
@@ -25,6 +25,7 @@ option(WITH_GEX "Enable DH Group exchange mechanisms" ON)
|
||||
option(WITH_INSECURE_NONE "Enable insecure none cipher and MAC algorithms (not suitable for production!)" OFF)
|
||||
option(FUZZ_TESTING "Build with fuzzer for the server and client (automatically enables none cipher!)" OFF)
|
||||
option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
|
||||
+option(WITH_STATIC_LIB "Build static library" ON)
|
||||
|
||||
if (WITH_ZLIB)
|
||||
set(WITH_LIBZ ON)
|
||||
@@ -60,3 +61,7 @@ endif (NOT GLOBAL_CLIENT_CONFIG)
|
||||
if (FUZZ_TESTING)
|
||||
set(WITH_INSECURE_NONE ON)
|
||||
endif (FUZZ_TESTING)
|
||||
+
|
||||
+if (WITH_STATIC_LIB)
|
||||
+ set(BUILD_STATIC_LIB ON)
|
||||
+endif()
|
||||
diff --git a/include/libssh/buffer.h b/include/libssh/buffer.h
|
||||
index a55a1b40..e34e075c 100644
|
||||
--- a/include/libssh/buffer.h
|
||||
|
||||
Reference in New Issue
Block a user