diff --git a/CMakeLists.txt b/CMakeLists.txt index e2bdbc13..87c1123a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,6 @@ if(NOT ESP_PLATFORM) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE}") set(PACKAGE_URL "https://github.com/sahlberg/libsmb2") - elseif(PICO_BOARD) project(libsmb2 C CXX ASM) else() @@ -41,8 +40,7 @@ if(NOT ESP_PLATFORM) set(PACKAGE_TARNAME "${PACKAGE}") set(PACKAGE_URL "https://github.com/sahlberg/libsmb2") endif() - configure_file(libsmb2.pc.in libsmb2.pc @ONLY) - + configure_file(libsmb2.pc.in libsmb2.pc @ONLY) endif() @@ -64,12 +62,10 @@ endif() list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) endif() - if(IOS) - find_package(GSSAPI) - - if(GSSAPI_FOUND) - add_definitions(-DHAVE_LIBKRB5) - endif() + if(CMAKE_SYSTEM_NAME MATCHES Linux) + find_package(LibKrb5) + elseif(IOS) + find_package(GSSAPI) endif() if(NOT PICO_BOARD OR NOT ESP_PLATFORM) @@ -99,8 +95,10 @@ endif() ) endif() - if(IOS) - set(core_DEPENDS ${GSSAPI_LIBRARIES} CACHE STRING "" FORCE) + if(CMAKE_SYSTEM_NAME MATCHES Linux) + set(core_DEPENDS ${LIBKRB5_LIBRARY} CACHE STRING "" FORCE) + elseif(IOS) + set(core_DEPENDS ${GSSAPI_LIBRARIES} CACHE STRING "" FORCE) endif() if(MSVC AND BUILD_SHARED_LIBS) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index a0b0a7ea..a28846ad 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -7,6 +7,7 @@ check_include_file("arpa/inet.h" HAVE_ARPA_INET_H) check_include_file("dlfcn.h" HAVE_DLFCN_H) check_include_file("fcntl.h" HAVE_FCNTL_H) check_include_file("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) +check_include_file("krb5/krb5.h" HAVE_LIBKRB5) check_include_file("inttypes.h" HAVE_INTTYPES_H) check_include_file("netdb.h" HAVE_NETDB_H) check_include_file("netinet/in.h" HAVE_NETINET_IN_H) diff --git a/cmake/Modules/FindLibKrb5.cmake b/cmake/Modules/FindLibKrb5.cmake new file mode 100644 index 00000000..3c8c6ca6 --- /dev/null +++ b/cmake/Modules/FindLibKrb5.cmake @@ -0,0 +1,44 @@ +# - Try to find Krb5 headers and libraries +# +# Usage of this module as follows: +# +# find_package(LibKrb5) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# LibKrb5_ROOT_DIR Set this variable to the root installation of +# libKrb5 if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# LibKrb5_FOUND System has Krb5 libraries and headers +# LibKrb5_LIBRARY The Krb5 library +# LibKrb5_INCLUDE_DIR The location of Krb5 headers + +find_path(LibKrb5_ROOT_DIR + NAMES include/krb5.h +) + +find_library(LibKrb5_LIBRARY + NAMES krb5 + HINTS ${LibKrb5_ROOT_DIR}/lib +) + +find_path(LibKrb5_INCLUDE_DIR + NAMES krb5.h + HINTS ${LibKrb5_ROOT_DIR}/include +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibKrb5 DEFAULT_MSG + LibKrb5_LIBRARY + LibKrb5_INCLUDE_DIR +) + +mark_as_advanced( + LibKrb5_ROOT_DIR + LibKrb5_LIBRARY + LibKrb5_INCLUDE_DIR +) \ No newline at end of file diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 0b1c8203..f3ba0c77 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -15,6 +15,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GSSAPI_GSSAPI_H "@HAVE_GSSAPI_GSSAPI_H@" +/* Whether we use gssapi_krb5 or not */ +#cmakedefine HAVE_LIBKRB5 "@HAVE_LIBKRB5@" + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@" diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3b7b51ac..e4b8518d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,104 +1,57 @@ -if(PICO_BOARD) - add_library(libsmb2 STATIC - lib/aes.c - lib/aes128ccm.c - lib/alloc.c - lib/compat.c - lib/dcerpc.c - lib/dcerpc-lsa.c - lib/dcerpc-srvsvc.c - lib/errors.c - lib/hmac.c - lib/hmac-md5.c - lib/init.c - lib/krb5-wrapper.c - lib/libsmb2.c - lib/md4c.c - lib/md5.c - lib/ntlmssp.c - lib/pdu.c - lib/sha1.c - lib/sha224-256.c - lib/sha384-512.c - lib/smb2-cmd-close.c - lib/smb2-cmd-create.c - lib/smb2-cmd-echo.c - lib/smb2-cmd-error.c - lib/smb2-cmd-flush.c - lib/smb2-cmd-ioctl.c - lib/smb2-cmd-logoff.c - lib/smb2-cmd-negotiate.c - lib/smb2-cmd-query-directory.c - lib/smb2-cmd-query-info.c - lib/smb2-cmd-read.c - lib/smb2-cmd-session-setup.c - lib/smb2-cmd-set-info.c - lib/smb2-cmd-tree-connect.c - lib/smb2-cmd-tree-disconnect.c - lib/smb2-cmd-write.c - lib/smb2-data-file-info.c - lib/smb2-data-filesystem-info.c - lib/smb2-data-security-descriptor.c - lib/smb2-data-reparse-point.c - lib/smb2-share-enum.c - lib/smb3-seal.c - lib/smb2-signing.c - lib/socket.c - lib/sync.c - lib/timestamps.c - lib/unicode.c - lib/usha.c - ) -elseif(ESP_PLATFORM) +if(GSSAPI_FOUND OR LIBKRB5_FOUND) + set(KRB5_SOURCE krb5-wrapper.c) +endif() + +if(ESP_PLATFORM) set(COMPONENT_SRCS - lib/aes.c - lib/aes128ccm.c - lib/alloc.c - lib/compat.c - lib/dcerpc.c - lib/dcerpc-lsa.c - lib/dcerpc-srvsvc.c - lib/errors.c - lib/init.c - lib/hmac.c - lib/hmac-md5.c - lib/krb5-wrapper.c - lib/libsmb2.c - lib/md4c.c - lib/md5.c - lib/ntlmssp.c - lib/pdu.c - lib/sha1.c - lib/sha224-256.c - lib/sha384-512.c - lib/smb2-cmd-close.c - lib/smb2-cmd-create.c - lib/smb2-cmd-echo.c - lib/smb2-cmd-error.c - lib/smb2-cmd-flush.c - lib/smb2-cmd-ioctl.c - lib/smb2-cmd-logoff.c - lib/smb2-cmd-negotiate.c - lib/smb2-cmd-query-directory.c - lib/smb2-cmd-query-info.c - lib/smb2-cmd-read.c - lib/smb2-cmd-session-setup.c - lib/smb2-cmd-set-info.c - lib/smb2-cmd-tree-connect.c - lib/smb2-cmd-tree-disconnect.c - lib/smb2-cmd-write.c - lib/smb2-data-file-info.c - lib/smb2-data-filesystem-info.c - lib/smb2-data-security-descriptor.c - lib/smb2-data-reparse-point.c - lib/smb2-share-enum.c - lib/smb3-seal.c - lib/smb2-signing.c - lib/socket.c - lib/sync.c - lib/timestamps.c - lib/unicode.c - lib/usha.c + aes.c + aes128ccm.c + alloc.c + compat.c + dcerpc.c + dcerpc-lsa.c + dcerpc-srvsvc.c + errors.c + init.c + hmac.c + hmac-md5.c + ${KRB5_SOURCE} + libsmb2.c + md4c.c + md5.c + ntlmssp.c + pdu.c + sha1.c + sha224-256.c + sha384-512.c + smb2-cmd-close.c + smb2-cmd-create.c + smb2-cmd-echo.c + smb2-cmd-error.c + smb2-cmd-flush.c + smb2-cmd-ioctl.c + smb2-cmd-logoff.c + smb2-cmd-negotiate.c + smb2-cmd-query-directory.c + smb2-cmd-query-info.c + smb2-cmd-read.c + smb2-cmd-session-setup.c + smb2-cmd-set-info.c + smb2-cmd-tree-connect.c + smb2-cmd-tree-disconnect.c + smb2-cmd-write.c + smb2-data-file-info.c + smb2-data-filesystem-info.c + smb2-data-security-descriptor.c + smb2-data-reparse-point.c + smb2-share-enum.c + smb3-seal.c + smb2-signing.c + socket.c + sync.c + timestamps.c + unicode.c + usha.c ) set(COMPONENT_NAME ".") @@ -121,7 +74,7 @@ elseif(IOP AND BUILD_IRX) hmac.c hmac-md5.c init.c - krb5-wrapper.c + ${KRB5_SOURCE} libsmb2.c md4c.c md5.c @@ -158,6 +111,7 @@ elseif(IOP AND BUILD_IRX) timestamps.c unicode.c usha.c) + BUILD_IOP_IMPORTS(${CMAKE_CURRENT_SOURCE_DIR}/ps2/imports.c ${CMAKE_CURRENT_SOURCE_DIR}/ps2/imports.lst) else() @@ -172,7 +126,7 @@ else() hmac.c hmac-md5.c init.c - krb5-wrapper.c + ${KRB5_SOURCE} libsmb2.c md4c.c md5.c @@ -211,7 +165,7 @@ else() usha.c) endif() -if(NOT PICO_BOARD OR NOT ESP_PLATFORM) +if(NOT ESP_PLATFORM) set(INCLUDE_PATH ../include) set(SMB2_INCLUDE "${INCLUDE_PATH}/smb2") set(HEADERS @@ -251,7 +205,9 @@ target_link_libraries(smb2man.irx PRIVATE gcc) -add_custom_command(TARGET smb2man.irx POST_BUILD COMMAND md5sum ARGS smb2man.irx) +add_custom_command(TARGET smb2man.irx POST_BUILD COMMAND md5sum ARGS smb2man.irx) +elseif(PICO_BOARD) +add_library(libsmb2 STATIC ${SOURCES}) else() add_library(smb2 ${SOURCES} ${HEADERS}) target_link_libraries(smb2 PUBLIC ${core_DEPENDS} ${CORE_LIBRARIES}) diff --git a/lib/Makefile.AMIGA b/lib/Makefile.AMIGA index d3e78f42..db1ed14e 100644 --- a/lib/Makefile.AMIGA +++ b/lib/Makefile.AMIGA @@ -14,7 +14,7 @@ CFLAGS = $(OPTIMIZE) $(DEBUG) $(WARNINGS) $(INCLUDES) $(DEFINES) STRIPFLAGS = -R.comment --strip-unneeded-rel-relocs SRCS = aes.c aes128ccm.c alloc.c dcerpc.c dcerpc-lsa.c dcerpc-srvsvc.c \ - errors.c init.c hmac.c hmac-md5.c krb5-wrapper.c libsmb2.c md4c.c \ + errors.c init.c hmac.c hmac-md5.c libsmb2.c md4c.c \ md5.c ntlmssp.c pdu.c sha1.c sha224-256.c sha384-512.c \ smb2-cmd-close.c smb2-cmd-create.c smb2-cmd-echo.c smb2-cmd-error.c \ smb2-cmd-flush.c smb2-cmd-ioctl.c smb2-cmd-logoff.c \ diff --git a/lib/Makefile.AMIGA_AROS b/lib/Makefile.AMIGA_AROS index 1496fabf..33e6f8a0 100644 --- a/lib/Makefile.AMIGA_AROS +++ b/lib/Makefile.AMIGA_AROS @@ -27,7 +27,7 @@ ifneq (,$(SYSROOT)) endif SRCS = aes.c aes128ccm.c alloc.c dcerpc.c dcerpc-lsa.c dcerpc-srvsvc.c \ - errors.c init.c hmac.c hmac-md5.c krb5-wrapper.c libsmb2.c md4c.c \ + errors.c init.c hmac.c hmac-md5.c libsmb2.c md4c.c \ md5.c ntlmssp.c pdu.c sha1.c sha224-256.c sha384-512.c \ smb2-cmd-close.c smb2-cmd-create.c smb2-cmd-echo.c smb2-cmd-error.c \ smb2-cmd-flush.c smb2-cmd-ioctl.c smb2-cmd-logoff.c \ diff --git a/lib/Makefile.AMIGA_OS3 b/lib/Makefile.AMIGA_OS3 index 4eb23b8e..77aaa5de 100644 --- a/lib/Makefile.AMIGA_OS3 +++ b/lib/Makefile.AMIGA_OS3 @@ -14,7 +14,7 @@ CFLAGS = $(OPTIMIZE) $(DEBUG) $(WARNINGS) $(INCLUDES) $(DEFINES) STRIPFLAGS = -R.comment SRCS = aes.c aes128ccm.c alloc.c dcerpc.c dcerpc-lsa.c dcerpc-srvsvc.c \ - errors.c init.c hmac.c hmac-md5.c krb5-wrapper.c libsmb2.c md4c.c \ + errors.c init.c hmac.c hmac-md5.c libsmb2.c md4c.c \ md5.c ntlmssp.c pdu.c sha1.c sha224-256.c sha384-512.c \ smb2-cmd-close.c smb2-cmd-create.c smb2-cmd-echo.c smb2-cmd-error.c \ smb2-cmd-flush.c smb2-cmd-ioctl.c smb2-cmd-logoff.c \ diff --git a/lib/Makefile.am b/lib/Makefile.am deleted file mode 100644 index 390b9c47..00000000 --- a/lib/Makefile.am +++ /dev/null @@ -1,78 +0,0 @@ -AM_CFLAGS=$(WARN_CFLAGS) - -lib_LTLIBRARIES = libsmb2.la - -libsmb2_la_CPPFLAGS = -I$(abs_top_srcdir)/include \ - -I$(abs_top_srcdir)/include/smb2 \ - "-D_U_=__attribute__((unused))" - -libsmb2_la_SOURCES = \ - aes.h \ - aes.c \ - aes128ccm.h \ - aes128ccm.c \ - alloc.c \ - compat.c \ - compat.h \ - dcerpc.c \ - dcerpc-lsa.c \ - dcerpc-srvsvc.c \ - errors.c \ - init.c \ - hmac.c \ - hmac-md5.h \ - hmac-md5.c \ - krb5-wrapper.h \ - krb5-wrapper.c \ - libsmb2.c \ - md4.h \ - md4c.c \ - md5.h \ - md5.c \ - ntlmssp.h \ - ntlmssp.c \ - pdu.c \ - sha.h \ - sha-private.h \ - sha1.c \ - sha224-256.c \ - sha384-512.c \ - smb2-cmd-close.c \ - smb2-cmd-create.c \ - smb2-cmd-echo.c \ - smb2-cmd-error.c \ - smb2-cmd-flush.c \ - smb2-cmd-ioctl.c \ - smb2-cmd-logoff.c \ - smb2-cmd-negotiate.c \ - smb2-cmd-query-directory.c \ - smb2-cmd-query-info.c \ - smb2-cmd-read.c \ - smb2-cmd-session-setup.c \ - smb2-cmd-set-info.c \ - smb2-cmd-tree-connect.c \ - smb2-cmd-tree-disconnect.c \ - smb2-cmd-write.c \ - smb2-data-file-info.c \ - smb2-data-filesystem-info.c \ - smb2-data-reparse-point.c \ - smb2-data-security-descriptor.c \ - smb2-share-enum.c \ - smb3-seal.h \ - smb3-seal.c \ - smb2-signing.h \ - smb2-signing.c \ - socket.c \ - sync.c \ - timestamps.c \ - unicode.c \ - usha.c - -SOCURRENT=4 -SOREVISION=0 -SOAGE=0 -libsmb2_la_LDFLAGS = \ - -version-info $(SOCURRENT):$(SOREVISION):$(SOAGE) -bindir $(bindir) \ - -no-undefined -export-symbols ${srcdir}/libsmb2.syms $(MAYBE_LIBKRB5) - -dist_noinst_DATA = libsmb2.syms diff --git a/lib/init.c b/lib/init.c index 13ae90a5..f248eead 100644 --- a/lib/init.c +++ b/lib/init.c @@ -76,8 +76,6 @@ #define MAX_URL_SIZE 1024 -#include "compat.h" - static int smb2_parse_args(struct smb2_context *smb2, const char *args) { diff --git a/lib/krb5-wrapper.c b/lib/krb5-wrapper.c index 0a30121e..f0109e1e 100644 --- a/lib/krb5-wrapper.c +++ b/lib/krb5-wrapper.c @@ -417,4 +417,4 @@ krb5_get_output_token_buffer(struct private_auth_data *auth_data) return auth_data->output_token.value; } -#endif /* HAVE_LIBKRB5 */ +#endif /* HAVE_LIBKRB5 */ \ No newline at end of file