Skip to content

Commit

Permalink
Improve GSSAPI and libkrb5 detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf3s committed Jul 23, 2024
1 parent a039c02 commit c52db76
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 199 deletions.
20 changes: 9 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()


Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
44 changes: 44 additions & 0 deletions cmake/Modules/FindLibKrb5.cmake
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 3 additions & 0 deletions cmake/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
/* Define to 1 if you have the <gssapi/gssapi.h> 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 <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@"

Expand Down
164 changes: 60 additions & 104 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 ".")
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -172,7 +126,7 @@ else()
hmac.c
hmac-md5.c
init.c
krb5-wrapper.c
${KRB5_SOURCE}
libsmb2.c
md4c.c
md5.c
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.AMIGA
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.AMIGA_AROS
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.AMIGA_OS3
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Loading

0 comments on commit c52db76

Please sign in to comment.