2018-12-03 13:17:07 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015-2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
|
|
|
* Copyright (C) 2009 Sourcefire, Inc.
|
|
|
|
*
|
|
|
|
* Authors: Tomasz Kojm, aCaB, Mickey Sola
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include "clamav-config.h"
|
|
|
|
#endif
|
|
|
|
|
2019-05-30 13:29:02 -04:00
|
|
|
//#define ONAS_DEBUG
|
2019-05-07 18:00:47 -04:00
|
|
|
|
2018-12-03 13:17:07 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2019-04-25 16:11:39 -04:00
|
|
|
#include <curl/curl.h>
|
2018-12-03 13:17:07 -05:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_SYS_LIMITS_H
|
|
|
|
#include <sys/limits.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <utime.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_UIO_H
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "libclamav/clamav.h"
|
|
|
|
#include "shared/optparser.h"
|
|
|
|
#include "shared/output.h"
|
|
|
|
#include "shared/misc.h"
|
|
|
|
#include "shared/actions.h"
|
|
|
|
|
|
|
|
#include "libclamav/str.h"
|
|
|
|
#include "libclamav/others.h"
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
|
|
|
|
#include "onaccess_com.h"
|
2018-12-03 13:17:07 -05:00
|
|
|
#include "onaccess_client.h"
|
2018-12-17 11:47:18 -05:00
|
|
|
#include "onaccess_proto.h"
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
#include "../clamonacc.h"
|
|
|
|
|
2018-12-03 13:17:07 -05:00
|
|
|
struct sockaddr_un nixsock;
|
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
static void print_server_version(struct onas_context **ctx)
|
|
|
|
{
|
|
|
|
if(onas_get_clamd_version(ctx)) {
|
|
|
|
/* can't get version from server, fallback */
|
|
|
|
printf("ClamAV %s\n", get_version());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-03 13:17:07 -05:00
|
|
|
/* Inits the communication layer
|
|
|
|
* Returns 0 if clamd is local, non zero if clamd is remote */
|
2019-04-25 16:11:39 -04:00
|
|
|
int onas_check_remote(struct onas_context **ctx, cl_error_t *err) {
|
|
|
|
int s, ret;
|
|
|
|
const struct optstruct *opt;
|
|
|
|
CURL *curl;
|
|
|
|
CURLcode curlcode;
|
|
|
|
char *ipaddr = NULL;
|
|
|
|
struct addrinfo hints, *info, *p;
|
|
|
|
int res;
|
2019-05-07 18:00:47 -04:00
|
|
|
int64_t timeout;
|
|
|
|
|
|
|
|
timeout = optget((*ctx)->clamdopts, "OnAccessCurlTimeout")->numarg;
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
|
|
|
|
*err = CL_SUCCESS;
|
2018-12-03 13:17:07 -05:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
2019-04-25 16:11:39 -04:00
|
|
|
if((opt = optget((*ctx)->clamdopts, "LocalSocket"))->enabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
#endif
|
2019-04-25 16:11:39 -04:00
|
|
|
if(!(opt = optget((*ctx)->clamdopts, "TCPSocket"))->enabled) {
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
(*ctx)->portnum = optget((*ctx)->clamdopts, "TCPSocket")->numarg;
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
opt = optget((*ctx)->clamdopts, "TCPAddr");
|
|
|
|
while (opt) {
|
|
|
|
|
|
|
|
if (opt->strarg) {
|
|
|
|
ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == ipaddr) {
|
|
|
|
logg("!ClamClient: Clamonacc does not support binding to INADDR_ANY, \
|
|
|
|
please specify an address with TCPAddr in your clamd.conf config file\n");
|
|
|
|
*err = CL_EARG;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
curlcode = onas_curl_init(&curl, ipaddr, (*ctx)->portnum, timeout);
|
2019-04-25 16:11:39 -04:00
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not init curl, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
*err = CL_EARG;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
curlcode = curl_easy_perform(curl);
|
2019-04-25 16:11:39 -04:00
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not connect to remote clam daemon, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
*err = CL_EARG;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
#ifndef ONAS_DEBUG
|
2019-05-30 13:29:02 -04:00
|
|
|
if(onas_sendln(curl, "zPING", 5, timeout)) {
|
2019-05-07 18:00:47 -04:00
|
|
|
logg("!ClamClient: could not ping clamd, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
*err = CL_EARG;
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
opt = opt->nextarg;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
if (*err == CL_SUCCESS) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-05-09 12:42:33 -04:00
|
|
|
CURLcode onas_curl_init(CURL **curl, const char *ipaddr, int64_t port, int64_t timeout) {
|
2019-04-25 16:11:39 -04:00
|
|
|
|
|
|
|
CURLcode curlcode = CURLE_OK;
|
|
|
|
|
2019-05-17 12:58:11 -04:00
|
|
|
if (!curl || !ipaddr) {
|
2019-04-25 16:11:39 -04:00
|
|
|
logg("!ClamClient: invalid (NULL) args passed to onas_curl_init\n");
|
|
|
|
return CURLE_FAILED_INIT;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
/* setup here, but caller needs to cleanup */
|
2019-04-25 16:11:39 -04:00
|
|
|
*curl = curl_easy_init();
|
|
|
|
|
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_PORT, port);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl with tcp port, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
2018-12-03 13:17:07 -05:00
|
|
|
}
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_URL, ipaddr);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl with tcp address, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
/* we implement our own transfer protocol via send and recv, so we only need to connect */
|
2019-05-07 18:00:47 -04:00
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_CONNECT_ONLY, 1L);
|
2019-04-25 16:11:39 -04:00
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl to connect only, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
/* we implement our own transfer protocol via send and recv, so we only need to connect */
|
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_CONNECTTIMEOUT_MS, (long) timeout);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl with connect timeout, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ONAS_DEBUG
|
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_VERBOSE, 1L);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not tell curl to be verbose, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* don't care about the body of the return message */
|
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_NOBODY, 1L);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl to send HEAD request, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
curlcode = curl_easy_setopt(*curl, CURLOPT_HEADER, 0L);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl to not send header, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(*curl);
|
|
|
|
return curlcode;
|
|
|
|
}
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
return curlcode;
|
2018-12-03 13:17:07 -05:00
|
|
|
}
|
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
cl_error_t onas_setup_client (struct onas_context **ctx) {
|
|
|
|
|
|
|
|
const struct optstruct *opts;
|
|
|
|
const struct optstruct *opt;
|
2019-04-25 16:11:39 -04:00
|
|
|
cl_error_t err;
|
2019-02-28 13:13:14 -05:00
|
|
|
int remote;
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
errno = 0;
|
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
opts = (*ctx)->opts;
|
|
|
|
|
|
|
|
if(optget(opts, "verbose")->enabled) {
|
2019-04-04 10:43:19 -04:00
|
|
|
mprintf_verbose = 1;
|
2019-02-28 13:13:14 -05:00
|
|
|
logg_verbose = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(optget(opts, "version")->enabled) {
|
|
|
|
print_server_version(ctx);
|
|
|
|
return CL_BREAK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(optget(opts, "help")->enabled) {
|
|
|
|
help();
|
|
|
|
return CL_BREAK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(optget(opts, "infected")->enabled) {
|
|
|
|
(*ctx)->printinfected = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize logger */
|
|
|
|
|
|
|
|
if((opt = optget(opts, "log"))->enabled) {
|
|
|
|
logg_file = opt->strarg;
|
|
|
|
if(logg("--------------------------------------\n")) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("!ClamClient: problem with internal logger\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
return CL_EARG;
|
|
|
|
}
|
2019-04-25 16:11:39 -04:00
|
|
|
} else {
|
2019-02-28 13:13:14 -05:00
|
|
|
logg_file = NULL;
|
2019-04-25 16:11:39 -04:00
|
|
|
}
|
2019-02-28 13:13:14 -05:00
|
|
|
|
|
|
|
if(actsetup(opts)) {
|
|
|
|
return CL_EARG;
|
|
|
|
}
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
if (curl_global_init(CURL_GLOBAL_NOTHING)) {
|
|
|
|
return CL_EARG;
|
|
|
|
}
|
|
|
|
|
2019-05-09 12:42:33 -04:00
|
|
|
(*ctx)->timeout = optget((*ctx)->clamdopts, "OnAccessCurlTimeout")->numarg;
|
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
(*ctx)->isremote = onas_check_remote(ctx, &err);
|
|
|
|
if (err) {
|
2019-02-28 13:13:14 -05:00
|
|
|
return CL_EARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
remote = (*ctx)->isremote | optget(opts, "stream")->enabled;
|
|
|
|
#ifdef HAVE_FD_PASSING
|
|
|
|
if(!remote && optget((*ctx)->clamdopts, "LocalSocket")->enabled && (optget(opts, "fdpass")->enabled)) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: client setup to scan via fd passing\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
(*ctx)->scantype = FILDES;
|
|
|
|
(*ctx)->session = optget(opts, "multiscan")->enabled;
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if(remote) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: client setup to scan via streaming\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
(*ctx)->scantype = STREAM;
|
|
|
|
(*ctx)->session = optget(opts, "multiscan")->enabled;
|
|
|
|
} else if(optget(opts, "multiscan")->enabled) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: client setup to scan in multiscan mode\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
(*ctx)->scantype = MULTI;
|
|
|
|
} else if(optget(opts, "allmatch")->enabled) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: client setup to scan in all-match mode\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
(*ctx)->scantype = ALLMATCH;
|
|
|
|
} else {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: client setup for continuous scanning\n");
|
2019-02-28 13:13:14 -05:00
|
|
|
(*ctx)->scantype = CONT;
|
|
|
|
}
|
|
|
|
|
2019-04-04 10:43:19 -04:00
|
|
|
(*ctx)->maxstream = optget((*ctx)->clamdopts, "StreamMaxLength")->numarg;
|
2019-02-28 13:13:14 -05:00
|
|
|
|
|
|
|
return CL_SUCCESS;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
int onas_get_clamd_version(struct onas_context **ctx)
|
2018-12-03 13:17:07 -05:00
|
|
|
{
|
|
|
|
char *buff;
|
2019-04-25 16:11:39 -04:00
|
|
|
CURL *curl;
|
|
|
|
CURLcode curlcode;
|
|
|
|
cl_error_t err = CL_SUCCESS;
|
|
|
|
int b_remote;
|
2018-12-03 13:17:07 -05:00
|
|
|
int len, sockd;
|
|
|
|
struct RCVLN rcv;
|
2019-05-07 18:00:47 -04:00
|
|
|
int64_t timeout;
|
|
|
|
|
|
|
|
timeout = optget((*ctx)->clamdopts, "OnAccessCurlTimeout")->numarg;
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
b_remote = onas_check_remote(ctx, &err);
|
|
|
|
if (CL_SUCCESS != err) {
|
|
|
|
logg("!ClamClient: could not check to see if daemon was remote\n");
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!b_remote) {
|
|
|
|
curl = curl_easy_init();
|
|
|
|
curlcode = curl_easy_setopt(curl, CURLOPT_UNIX_SOCKET_PATH, optget((*ctx)->clamdopts, "LocalSocket")->strarg);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl with local unix socket, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
} else {
|
2019-05-07 18:00:47 -04:00
|
|
|
curlcode = onas_curl_init(&curl, optget((*ctx)->clamdopts, "TCPAddr")->strarg, (*ctx)->portnum, timeout);
|
2019-04-25 16:11:39 -04:00
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not setup curl with tcp address and port, %s\n", curl_easy_strerror(curlcode));
|
2019-05-07 18:00:47 -04:00
|
|
|
/* curl cleanup done in onas_curl_init on error */
|
2019-04-25 16:11:39 -04:00
|
|
|
return 2;
|
|
|
|
}
|
2019-02-28 13:13:14 -05:00
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
onas_recvlninit(&rcv, curl);
|
|
|
|
|
|
|
|
curlcode = curl_easy_perform(curl);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not connect to clam daemon, %s\n", curl_easy_strerror(curlcode));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
if(onas_sendln(curl, "zVERSION", 9, timeout)) {
|
|
|
|
curl_easy_cleanup(curl);
|
2018-12-03 13:17:07 -05:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
while((len = onas_recvln(&rcv, &buff, NULL, timeout))) {
|
2018-12-03 13:17:07 -05:00
|
|
|
if(len == -1) {
|
2019-04-04 10:43:19 -04:00
|
|
|
logg("*ClamClient: clamd did not respond with version information\n");
|
2018-12-03 13:17:07 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("%s\n", buff);
|
|
|
|
}
|
|
|
|
|
2019-05-07 18:00:47 -04:00
|
|
|
curl_easy_cleanup(curl);
|
2018-12-03 13:17:07 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-22 15:36:54 -04:00
|
|
|
int onas_client_scan(const char *tcpaddr, int64_t portnum, int32_t scantype, uint64_t maxstream, const char *fname, int fd, int64_t timeout, STATBUF sb, int *infected, int *err, cl_error_t *ret_code)
|
2018-12-03 13:17:07 -05:00
|
|
|
{
|
2019-04-25 16:11:39 -04:00
|
|
|
CURL *curl = NULL;
|
|
|
|
CURLcode curlcode = CURLE_OK;
|
2019-05-09 12:42:33 -04:00
|
|
|
int errors = 0;
|
2019-02-28 13:13:14 -05:00
|
|
|
int sockd, ret;
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
*infected = 0;
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-02-28 13:13:14 -05:00
|
|
|
if((sb.st_mode & S_IFMT) != S_IFREG) {
|
|
|
|
scantype = STREAM;
|
2019-05-09 12:42:33 -04:00
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-05-09 12:42:33 -04:00
|
|
|
curlcode = onas_curl_init(&curl, tcpaddr, portnum, timeout);
|
2019-04-25 16:11:39 -04:00
|
|
|
if (CURLE_OK != curlcode) {
|
2019-05-17 12:58:11 -04:00
|
|
|
logg("!ClamClient: could not init curl for scanning, %s\n", curl_easy_strerror(curlcode));
|
2019-05-09 12:42:33 -04:00
|
|
|
/* curl cleanup done in onas_curl_init on error */
|
|
|
|
return CL_ECREAT;
|
2019-04-25 16:11:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
curlcode = curl_easy_perform(curl);
|
|
|
|
if (CURLE_OK != curlcode) {
|
|
|
|
logg("!ClamClient: could not establish connection, %s\n", curl_easy_strerror(curlcode));
|
2019-05-09 12:42:33 -04:00
|
|
|
return CL_ECREAT;
|
2019-04-25 16:11:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-22 15:36:54 -04:00
|
|
|
if((ret = onas_dsresult(curl, scantype, maxstream, fname, fd, timeout, &ret, err, ret_code)) >= 0) {
|
2019-02-28 13:13:14 -05:00
|
|
|
*infected = ret;
|
|
|
|
} else {
|
2019-04-15 07:29:20 -07:00
|
|
|
logg("*ClamClient: connection could not be established ... return code %d\n", *ret_code);
|
2019-02-28 13:13:14 -05:00
|
|
|
errors = 1;
|
|
|
|
}
|
2018-12-03 13:17:07 -05:00
|
|
|
|
2019-04-25 16:11:39 -04:00
|
|
|
curl_easy_cleanup(curl);
|
2019-05-09 12:42:33 -04:00
|
|
|
return *infected ? CL_VIRUS : (errors ? CL_ECREAT : CL_CLEAN);
|
2018-12-03 13:17:07 -05:00
|
|
|
}
|
2019-04-25 16:11:39 -04:00
|
|
|
|