Browse code

clamonacc - Loosen curl requirements

Allow users to install clamonacc with any version of curl
Using fdpassing still requires curl version >7.40

Mickey Sola authored on 2020/07/28 02:23:52
Showing 5 changed files
... ...
@@ -40,6 +40,8 @@
40 40
 #include <fcntl.h>
41 41
 #endif
42 42
 
43
+#include <curl/curl.h>
44
+
43 45
 #include "libclamav/clamav.h"
44 46
 #include "libclamav/others.h"
45 47
 #include "shared/output.h"
... ...
@@ -326,6 +328,14 @@ static int startup_checks(struct onas_context *ctx)
326 326
     }
327 327
 #endif
328 328
 
329
+#if ((LIBCURL_VERSION_MAJOR < 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR < 40))
330
+    if (optget(ctx->opts, "fdpass")->enabled || !optget(ctx->clamdopts, "TCPSocket")->enabled || !optget(ctx->clamdopts, "TCPAddr")->enabled) {
331
+	    logg("!Clamonacc: Version of curl is too low to use fdpassing. Please use tcp socket streaming instead\n.");
332
+	    ret = 2;
333
+	    goto done;
334
+    }
335
+#endif
336
+
329 337
     if (curl_global_init(CURL_GLOBAL_NOTHING)) {
330 338
         ret = 2;
331 339
         goto done;
... ...
@@ -368,6 +378,7 @@ static int startup_checks(struct onas_context *ctx)
368 368
             goto done;
369 369
         }
370 370
     }
371
+
371 372
 done:
372 373
     return ret;
373 374
 }
... ...
@@ -293,8 +293,10 @@ CURLcode onas_curl_init(CURL **curl, const char *ipaddr, int64_t port, int64_t t
293 293
 
294 294
     if (!port) {
295 295
 
296
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 40))
296 297
         /* "ipaddr" is actually our unix socket path here */
297 298
         curlcode = curl_easy_setopt(*curl, CURLOPT_UNIX_SOCKET_PATH, ipaddr);
299
+#endif
298 300
         if (CURLE_OK != curlcode) {
299 301
             logg("!ClamClient: could not setup curl with local unix socket, %s\n", curl_easy_strerror(curlcode));
300 302
             curl_easy_cleanup(*curl);
... ...
@@ -81,7 +81,13 @@ int onas_sendln(CURL *curl, const void *line, size_t len, int64_t timeout)
81 81
     CURLcode curlcode;
82 82
     curl_socket_t sockfd;
83 83
 
84
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 45))
85
+    /* Use new CURLINFO_ACTIVESOCKET option */
84 86
     curlcode = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);
87
+#else
88
+    /* Use deprecated CURLINFO_LASTSOCKET option */
89
+    curlcode = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
90
+#endif
85 91
 
86 92
     if (CURLE_OK != curlcode) {
87 93
         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
139 139
     int ret = 0;
140 140
     curl_socket_t sockfd;
141 141
 
142
+#if ((LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 45))
143
+    /* Use new CURLINFO_ACTIVESOCKET option */
142 144
     rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_ACTIVESOCKET, &sockfd);
145
+#else
146
+    /* Use deprecated CURLINFO_LASTSOCKET option */
147
+    rcv_data->curlcode = curl_easy_getinfo(rcv_data->curl, CURLINFO_LASTSOCKET, &sockfd);
148
+#endif
143 149
 
144 150
     if (CURLE_OK != rcv_data->curlcode) {
145 151
         logg("!ClamCom: could not get curl active socket info %s\n", curl_easy_strerror(rcv_data->curlcode));
... ...
@@ -387,3 +387,11 @@ if test "X$have_json" = "Xyes" && test "x$json_linking" = "xdynamic"; then
387 387
 ****** providing a json-c library that was compiled with CFLAGS="-fPIC".
388 388
     ])
389 389
 fi
390
+
391
+if test "x$clamonacc-curl" = "xdeprecated"; then
392
+    AC_MSG_WARN([m4_normalize([
393
+****** 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.
394
+****** fdpassing with clamonacc will be disabled on your system.
395
+****** for more information on ClamAV's on-access scanner, please read our documentation: https://www.clamav.net/documents/on-access-scanning#on-access-scanning
396
+    ])])
397
+fi
390 398
\ No newline at end of file
... ...
@@ -64,17 +64,14 @@ if test "X$have_curl" = "Xyes"; then
64 64
     dnl end of section
65 65
 
66 66
     AM_COND_IF([BUILD_CLAMONACC],
67
-                    dnl if version greater than (7.45)
68
-                    [if test $curl_version -ge 470272 ; then
69
-                        $enable_clamonacc="yes"
70
-                    else
71
-                        AC_MSG_ERROR([m4_normalize([
72
-                                Your libcurl (e.g. libcurl-devel) is too old. Installing ClamAV with clamonacc requires libcurl 7.45 or higher.
73
-                                For a quick fix, run ./configure again with --disable-clamonacc if you do not wish to use on-access scanning features.
74
-                                For more information on ClamAV's on-access scanner, please read our documentation: https://www.clamav.net/documents/on-access-scanning#on-access-scanning
75
-                        ])])
76
-                    fi]
77
-                )
67
+        $enable_clamonacc="yes"
68
+
69
+        clamonacc_curl = "current"
70
+        dnl if version less than to (7.40 0x072800)
71
+        [if test $curl_version -lt 468992; then
72
+          clamonacc_curl = "deprecated" 
73
+        fi]
74
+    )
78 75
 
79 76
     AC_CHECK_LIB(
80 77
         [curl],