diff --git a/CMakeLists.txt b/CMakeLists.txt index 36587c5a..f31ddf08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,9 +60,11 @@ add_subdirectory(libssh) include_directories(${CMAKE_SOURCE_DIR}/include) if (UNIX AND NOT WIN32) - add_executable(samplessh sample.c) - add_executable(samplesshd samplesshd.c) + if (WITH_SFTP AND WITH_SERVER) + add_executable(samplessh sample.c) + add_executable(samplesshd samplesshd.c) - target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY}) - target_link_libraries(samplesshd ${LIBSSH_SHARED_LIBRARY}) + target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY}) + target_link_libraries(samplesshd ${LIBSSH_SHARED_LIBRARY}) + endif (WITH_SFTP AND WITH_SERVER) endif (UNIX AND NOT WIN32) diff --git a/DefineOptions.cmake b/DefineOptions.cmake index cec5d6bc..d482e199 100644 --- a/DefineOptions.cmake +++ b/DefineOptions.cmake @@ -1,5 +1,6 @@ option(WITH_LIBZ "Build with ZLIB support" ON) option(WITH_SSH1 "Build with SSH1 support" OFF) +option(WITH_SFTP "Build with SFTP support" ON) option(WITH_SERVER "Build with SSH server support" ON) option(WITH_STATIC_LIB "Build with a static library" OFF) option(WITH_DEBUG_CRYPTO "Build with cryto debut output" OFF) diff --git a/config.h.cmake b/config.h.cmake index 2ff415e9..e941d109 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -62,6 +62,9 @@ /* Define to 1 if you want to enable ZLIB */ #cmakedefine WITH_LIBZ 1 +/* Define to 1 if you want to enable SSH1 */ +#cmakedefine WITH_SFTP 1 + /* Define to 1 if you want to enable SSH1 */ #cmakedefine WITH_SSH1 1 diff --git a/include/libssh/CMakeLists.txt b/include/libssh/CMakeLists.txt index af7b2ebb..2b9fac6f 100644 --- a/include/libssh/CMakeLists.txt +++ b/include/libssh/CMakeLists.txt @@ -3,11 +3,23 @@ project(libssh-headers C) set(libssh_HDRS libssh.h crypto.h - sftp.h - ssh1.h ssh2.h ) +if (WITH_SFTP) + set(libssh_HDRS + ${libssh_HDRS} + sftp.h + ) +endif (WITH_SFTP) + +if (WITH_SSH1) + set(libssh_HDRS + ${libssh_HDRS} + ssh1.h + ) +endif (WITH_SSH1) + if (WITH_SERVER) set(libssh_HDRS ${libssh_HDRS} diff --git a/libssh/CMakeLists.txt b/libssh/CMakeLists.txt index e3ee26b7..260d743c 100644 --- a/libssh/CMakeLists.txt +++ b/libssh/CMakeLists.txt @@ -85,13 +85,25 @@ set(libssh_SRCS options.c packet.c session.c - sftp.c - sftpserver.c socket.c string.c wrapper.c ) +if (WITH_SFTP) + set(libssh_SRCS + ${libssh_SRCS} + sftp.c + ) + + if (WITH_SERVER) + set(libssh_SRCS + ${libssh_SRCS} + sftpserver.c + ) + endif (WITH_SERVER) +endif (WITH_SFTP) + if (WITH_SSH1) set(libssh_SRCS ${libssh_SRCS} diff --git a/libssh/sftp.c b/libssh/sftp.c index a32b1cc4..55dd93fc 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -36,7 +36,8 @@ #include "libssh/priv.h" #include "libssh/ssh2.h" #include "libssh/sftp.h" -#ifndef NO_SFTP + +#ifdef WITH_SFTP #define sftp_enter_function() _enter_function(sftp->channel->session) #define sftp_leave_function() _leave_function(sftp->channel->session) @@ -2387,5 +2388,5 @@ SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file) { return NULL; } -#endif /* NO_SFTP */ +#endif /* WITH_SFTP */ diff --git a/sample.c b/sample.c index c5e1113f..13f4e921 100644 --- a/sample.c +++ b/sample.c @@ -273,7 +273,8 @@ static void batch_shell(SSH_SESSION *session){ } select_loop(session,channel); } - + +#ifdef WITH_SFTP /* it's just a proof of concept code for sftp, till i write a real documentation about it */ void do_sftp(SSH_SESSION *session){ SFTP_SESSION *sftp_session=sftp_new(session); @@ -362,6 +363,7 @@ void do_sftp(SSH_SESSION *session){ sftp_free(sftp_session); printf("session sftp termin�\n"); } +#endif static int auth_kbdint(SSH_SESSION *session){ int err=ssh_userauth_kbdint(session,NULL,NULL);