Created
August 25, 2020 21:42
-
-
Save val-ms/68ff66eaa9656f9b6ea1dc5fdb638a4e to your computer and use it in GitHub Desktop.
clamonacc - Loosen curl requirements (0.102.4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/clamonacc/clamonacc.c b/clamonacc/clamonacc.c | |
index e3eee8df2..43f478f76 100644 | |
--- a/clamonacc/clamonacc.c | |
+++ b/clamonacc/clamonacc.c | |
@@ -40,6 +40,8 @@ | |
#include <fcntl.h> | |
#endif | |
+#include <curl/curl.h> | |
+ | |
#include "libclamav/clamav.h" | |
#include "libclamav/others.h" | |
#include "shared/output.h" | |
@@ -330,6 +332,14 @@ static int startup_checks(struct onas_context *ctx) | |
} | |
#endif | |
+#if ((LIBCURL_VERSION_MAJOR < 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR < 40)) | |
+ if (optget(ctx->opts, "fdpass")->enabled || !optget(ctx->clamdopts, "TCPSocket")->enabled || !optget(ctx->clamdopts, "TCPAddr")->enabled) { | |
+ logg("!Clamonacc: Version of curl is too low to use fdpassing. Please use tcp socket streaming instead\n."); | |
+ ret = 2; | |
+ goto done; | |
+ } | |
+#endif | |
+ | |
if (curl_global_init(CURL_GLOBAL_NOTHING)) { | |
ret = 2; | |
goto done; | |
@@ -350,6 +360,7 @@ static int startup_checks(struct onas_context *ctx) | |
goto done; | |
} | |
} | |
+ | |
done: | |
return ret; | |
} | |
diff --git a/clamonacc/client/client.c b/clamonacc/client/client.c | |
index 699210d0f..00788b8fd 100644 | |
--- a/clamonacc/client/client.c | |
+++ b/clamonacc/client/client.c | |
@@ -177,8 +177,10 @@ CURLcode onas_curl_init(CURL **curl, const char *ipaddr, int64_t port, int64_t t | |
if (!port) { | |
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 40)) | |
/* "ipaddr" is actually our unix socket path here */ | |
curlcode = curl_easy_setopt(*curl, CURLOPT_UNIX_SOCKET_PATH, ipaddr); | |
+#endif | |
if (CURLE_OK != curlcode) { | |
logg("!ClamClient: could not setup curl with local unix socket, %s\n", curl_easy_strerror(curlcode)); | |
curl_easy_cleanup(*curl); | |
diff --git a/clamonacc/client/communication.c b/clamonacc/client/communication.c | |
index bd2e52293..faccd54cc 100644 | |
--- a/clamonacc/client/communication.c | |
+++ b/clamonacc/client/communication.c | |
@@ -81,7 +81,13 @@ int onas_sendln(CURL *curl, const void *line, size_t len, int64_t timeout) | |
CURLcode curlcode; | |
curl_socket_t sockfd; | |
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 45)) | |
+ /* Use new CURLINFO_ACTIVESOCKET option */ | |
curlcode = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd); | |
+#else | |
+ /* Use deprecated CURLINFO_LASTSOCKET option */ | |
+ curlcode = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd); | |
+#endif | |
if (CURLE_OK != curlcode) { | |
logg("!ClamCom: could not get curl active socket info %s\n", curl_easy_strerror(curlcode)); | |
@@ -139,7 +145,13 @@ int onas_recvln(struct RCVLN *rcv_data, char **ret_bol, char **ret_eol, int64_t | |
int ret = 0; | |
curl_socket_t sockfd; | |
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 45)) | |
+ /* Use new CURLINFO_ACTIVESOCKET option */ | |
rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_ACTIVESOCKET, &sockfd); | |
+#else | |
+ /* Use deprecated CURLINFO_LASTSOCKET option */ | |
+ rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_LASTSOCKET, &sockfd); | |
+#endif | |
if (CURLE_OK != rcv_data->curlcode) { | |
logg("!ClamCom: could not get curl active socket info %s\n", curl_easy_strerror(rcv_data->curlcode)); | |
diff --git a/configure.ac b/configure.ac | |
index 85f34a548..2451e5ac3 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -387,3 +387,11 @@ if test "X$have_json" = "Xyes" && test "x$json_linking" = "xdynamic"; then | |
****** providing a json-c library that was compiled with CFLAGS="-fPIC". | |
]) | |
fi | |
+ | |
+if test "x$clamonacc-curl" = "xdeprecated"; then | |
+ AC_MSG_WARN([m4_normalize([ | |
+****** your libcurl (e.g. libcurl-devel) is older than the recommended version. Installing ClamAV with clamonacc requires libcurl 7.40 or higher to use fdpassing. | |
+****** fdpassing with clamonacc will be disabled on your system. | |
+****** for more information on ClamAV's on-access scanner, please read our documentation: https://www.clamav.net/documents/on-access-scanning#on-access-scanning | |
+ ])]) | |
+fi | |
\ No newline at end of file | |
diff --git a/m4/reorganization/libs/curl.m4 b/m4/reorganization/libs/curl.m4 | |
index a5e34a0e2..4293f2c9e 100644 | |
--- a/m4/reorganization/libs/curl.m4 | |
+++ b/m4/reorganization/libs/curl.m4 | |
@@ -62,17 +62,14 @@ if test "X$have_curl" = "Xyes"; then | |
dnl end of section | |
AM_COND_IF([BUILD_CLAMONACC], | |
- dnl if version greater than (7.45) | |
- [if test $curl_version -ge 470272 ; then | |
- $enable_clamonacc="yes" | |
- else | |
- AC_MSG_ERROR([m4_normalize([ | |
- Your libcurl (e.g. libcurl-devel) is too old. Installing ClamAV with clamonacc requires libcurl 7.45 or higher. | |
- For a quick fix, run ./configure again with --disable-clamonacc if you do not wish to use on-access scanning features. | |
- For more information on ClamAV's on-access scanner, please read our documentation: https://www.clamav.net/documents/on-access-scanning#on-access-scanning | |
- ])]) | |
- fi] | |
- ) | |
+ $enable_clamonacc="yes" | |
+ | |
+ clamonacc_curl = "current" | |
+ dnl if version less than to (7.40 0x072800) | |
+ [if test $curl_version -lt 468992; then | |
+ clamonacc_curl = "deprecated" | |
+ fi] | |
+ ) | |
AC_CHECK_LIB( | |
[curl], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment