diff --git a/CMakeLists.txt b/CMakeLists.txt index d07d010..3324855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,25 @@ IF(WITH_ZLIB) SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${ZLIB_LIBRARY}) ENDIF(WITH_ZLIB) IF(WITH_CURL) + FIND_PROGRAM(CURL_CONFIG curl-config + DOC "The curl-config executable path, used to determine SFTP support.") + # If we can find the config script, we will run it and attempt to parse out the + # availability of SFTP support. Otherwise, we will assume the library was built + # without it. + IF(CURL_CONFIG) + EXECUTE_PROCESS( + COMMAND ${CURL_CONFIG} --protocols + COMMAND grep SFTP + COMMAND wc -l + OUTPUT_VARIABLE CURL_CONFIG_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(CURL_CONFIG_OUTPUT STREQUAL "1") + ADD_DEFINITIONS(-DCURLSFTPAVAILABLE) + MESSAGE(STATUS "cURL SFTP Support: Yes") + ELSE(CURL_CONFIG_OUTPUT STREQUAL "1") + MESSAGE(STATUS "cURL SFTP Support: No") + ENDIF(CURL_CONFIG_OUTPUT STREQUAL "1") + ENDIF(CURL_CONFIG) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) SET(SWORD_LINK_LIBRARIES ${SWORD_LINK_LIBRARIES} ${CURL_LIBRARY}) ENDIF(WITH_CURL) diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp index c1ddd1b..1d31ffe 100644 --- a/src/mgr/installmgr.cpp +++ b/src/mgr/installmgr.cpp @@ -159,6 +159,20 @@ void InstallMgr::readInstallConf() { is->localShadow = (SWBuf)privatePath + "/" + is->uid; sourceBegin++; } + +#ifdef CURLSFTPAVAILABLE + sourceBegin = confSection->second.lower_bound("SFTPSource"); + sourceEnd = confSection->second.upper_bound("SFTPSource"); + + while (sourceBegin != sourceEnd) { + InstallSource *is = new InstallSource("SFTP", sourceBegin->second.c_str()); + sources[is->caption] = is; + SWBuf parent = (SWBuf)privatePath + "/" + is->uid + "/file"; + FileMgr::createParent(parent.c_str()); + is->localShadow = (SWBuf)privatePath + "/" + is->uid; + sourceBegin++; + } +#endif // CURLSFTPAVAILABLE sourceBegin = confSection->second.lower_bound("HTTPSource"); sourceEnd = confSection->second.upper_bound("HTTPSource"); @@ -291,7 +305,11 @@ SWLog::getSystemLog()->logDebug("netCopy: %s, %s, %s, %c, %s", (is?is->source.c_ int retVal = 0; FTPTransport *trans = 0; - if (is->type == "FTP") { + if (is->type == "FTP" +#ifdef CURLSFTPAVAILABLE + || is->type == "SFTP" +#endif + ) { trans = createFTPTransport(is->source, statusReporter); trans->setPassive(passive); } @@ -315,6 +333,11 @@ SWLog::getSystemLog()->logDebug("netCopy: %s, %s, %s, %c, %s", (is?is->source.c_ else if (is->type == "HTTPS") { urlPrefix = (SWBuf) "https://"; } +#ifdef CURLSFTPAVAILABLE + else if (is->type == "SFTP") { + urlPrefix = (SWBuf) "sftp://"; + } +#endif else { urlPrefix = (SWBuf) "ftp://"; }