Skip to content

Commit

Permalink
clamonacc - Loosen curl requirements
Browse files Browse the repository at this point in the history
Allow users to install clamonacc with any version of curl
Using fdpassing still requires curl version >7.40
  • Loading branch information
Mickey Sola authored and Mickey Sola (micksola) committed Jul 27, 2020
1 parent 82e1c2a commit 29389cb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
11 changes: 11 additions & 0 deletions clamonacc/clamonacc.c
Expand Up @@ -40,6 +40,8 @@
#include <fcntl.h>
#endif

#include <curl/curl.h>

#include "libclamav/clamav.h"
#include "libclamav/others.h"
#include "shared/output.h"
Expand Down Expand Up @@ -326,6 +328,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;
Expand Down Expand Up @@ -368,6 +378,7 @@ static int startup_checks(struct onas_context *ctx)
goto done;
}
}

done:
return ret;
}
Expand Down
2 changes: 2 additions & 0 deletions clamonacc/client/client.c
Expand Up @@ -293,8 +293,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);
Expand Down
12 changes: 12 additions & 0 deletions clamonacc/client/communication.c
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Expand Up @@ -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
19 changes: 8 additions & 11 deletions m4/reorganization/libs/curl.m4
Expand Up @@ -64,17 +64,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],
Expand Down

0 comments on commit 29389cb

Please sign in to comment.