clamdscan/proto.c
f6870133
 /*
e1cbc270
  *  Copyright (C) 2013-2019 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  *  Copyright (C) 2009-2013 Sourcefire, Inc.
f6870133
  *
  *  Authors: Tomasz Kojm, aCaB
  *
  *  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.
  */
 
bfd89d7c
 #if HAVE_CONFIG_H
 #include "clamav-config.h"
 #endif
 
a3962a62
 #if defined(C_SOLARIS)
ac5da57a
 #ifndef __EXTENSIONS__
a3962a62
 #define __EXTENSIONS__
 #endif
ac5da57a
 #endif
a3962a62
 
bfd89d7c
 /* must be first because it may define _XOPEN_SOURCE */
 #include "shared/fdpassing.h"
f6870133
 #include <stdio.h>
4cd80898
 #ifdef HAVE_UNISTD_H
f6870133
 #include <unistd.h>
4cd80898
 #endif
f6870133
 #include <string.h>
 #include <errno.h>
5ad17a13
 #include <stdlib.h>
f6870133
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/types.h>
be4bf7f4
 #ifdef HAVE_SYS_SELECT_H
ea2799a2
 #include <sys/select.h>
be4bf7f4
 #endif
4cd80898
 #ifndef _WIN32
f6870133
 #include <arpa/inet.h>
4cd80898
 #include <sys/socket.h>
68900531
 #include <sys/un.h>
a3962a62
 #include <netdb.h>
4cd80898
 #endif
f6870133
 
60d8d2c3
 #include "libclamav/clamav.h"
f6870133
 #include "libclamav/others.h"
ee6702ab
 #include "shared/actions.h"
f6870133
 #include "shared/output.h"
247fe3ae
 #include "shared/misc.h"
3507891f
 #include "shared/clamdcom.h"
f6870133
 
 #include "proto.h"
 #include "client.h"
 
9877f2d8
 extern unsigned long int maxstream;
fadd3046
 int printinfected;
247fe3ae
 extern struct optstruct *clamdopts;
f0e1c2e6
 #ifndef _WIN32
 extern struct sockaddr_un nixsock;
 #endif
f6870133
 
288057e9
 static const char *scancmd[] = {"CONTSCAN", "MULTISCAN", "INSTREAM", "FILDES", "ALLMATCHSCAN"};
f6870133
 
 /* Connects to clamd 
  * Returns a FD or -1 on error */
288057e9
 int dconnect()
 {
1c1d726d
     int sockd, res;
     const struct optstruct *opt;
     struct addrinfo hints, *info, *p;
     char port[10];
6432bbfb
     char *ipaddr;
f6870133
 
f0e1c2e6
 #ifndef _WIN32
     opt = optget(clamdopts, "LocalSocket");
     if (opt->enabled) {
         if ((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) {
             if (connect(sockd, (struct sockaddr *)&nixsock, sizeof(nixsock)) == 0)
                 return sockd;
f08ce33c
             else {
                 logg("!Could not connect to clamd on LocalSocket %s: %s\n", opt->strarg, strerror(errno));
f0e1c2e6
                 close(sockd);
f08ce33c
             }
f0e1c2e6
         }
     }
 #endif
 
1c1d726d
     snprintf(port, sizeof(port), "%lld", optget(clamdopts, "TCPSocket")->numarg);
f6870133
 
1c1d726d
     opt = optget(clamdopts, "TCPAddr");
     while (opt) {
bb30678c
         if (opt->enabled) {
             ipaddr = NULL;
             if (opt->strarg)
                 ipaddr = (!strcmp(opt->strarg, "any") ? NULL : opt->strarg);
 
             memset(&hints, 0x00, sizeof(struct addrinfo));
288057e9
             hints.ai_family   = AF_UNSPEC;
bb30678c
             hints.ai_socktype = SOCK_STREAM;
 
             if ((res = getaddrinfo(ipaddr, port, &hints, &info))) {
                 logg("!Could not lookup %s: %s\n", ipaddr ? ipaddr : "", gai_strerror(res));
                 opt = opt->nextarg;
1c1d726d
                 continue;
             }
 
bb30678c
             for (p = info; p != NULL; p = p->ai_next) {
288057e9
                 if ((sockd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) {
bb30678c
                     logg("!Can't create the socket: %s\n", strerror(errno));
                     continue;
                 }
 
288057e9
                 if (connect(sockd, p->ai_addr, p->ai_addrlen) < 0) {
bb30678c
                     logg("!Could not connect to clamd on %s: %s\n", opt->strarg, strerror(errno));
                     closesocket(sockd);
                     continue;
                 }
 
                 freeaddrinfo(info);
                 return sockd;
1c1d726d
             }
 
             freeaddrinfo(info);
         }
6432bbfb
         opt = opt->nextarg;
f6870133
     }
1c1d726d
 
     return -1;
f6870133
 }
 
 /* Issues an INSTREAM command to clamd and streams the given file
f592af6c
  * Returns >0 on success, 0 soft fail, -1 hard fail */
288057e9
 static int send_stream(int sockd, const char *filename)
 {
     uint32_t buf[BUFSIZ / sizeof(uint32_t)];
f6870133
     int fd, len;
83c52f7e
     unsigned long int todo = maxstream;
f6870133
 
288057e9
     if (filename) {
         if ((fd = safe_open(filename, O_RDONLY | O_BINARY)) < 0) {
             logg("~%s: Access denied. ERROR\n", filename);
             return 0;
         }
     } else
         fd = 0;
f6870133
 
288057e9
     if (sendln(sockd, "zINSTREAM", 10)) {
         close(fd);
         return -1;
9b3e1e85
     }
f6870133
 
288057e9
     while ((len = read(fd, &buf[1], sizeof(buf) - sizeof(uint32_t))) > 0) {
         if ((unsigned int)len > todo) len = todo;
         buf[0] = htonl(len);
         if (sendln(sockd, (const char *)buf, len + sizeof(uint32_t))) {
             close(fd);
             return -1;
         }
         todo -= len;
         if (!todo) {
             len = 0;
             break;
         }
f6870133
     }
     close(fd);
288057e9
     if (len) {
         logg("!Failed to read from %s.\n", filename ? filename : "STDIN");
         return 0;
f6870133
     }
288057e9
     *buf = 0;
83c52f7e
     sendln(sockd, (const char *)buf, 4);
f592af6c
     return 1;
f6870133
 }
 
ea2799a2
 #ifdef HAVE_FD_PASSING
f6870133
 /* Issues a FILDES command and pass a FD to clamd
f592af6c
  * Returns >0 on success, 0 soft fail, -1 hard fail */
288057e9
 static int send_fdpass(int sockd, const char *filename)
 {
f6870133
     struct iovec iov[1];
     struct msghdr msg;
     struct cmsghdr *cmsg;
     unsigned char fdbuf[CMSG_SPACE(sizeof(int))];
288057e9
     char dummy[] = "";
f6870133
     int fd;
 
288057e9
     if (filename) {
         if ((fd = open(filename, O_RDONLY)) < 0) {
             logg("~%s: Access denied. ERROR\n", filename);
             return 0;
         }
     } else
         fd = 0;
     if (sendln(sockd, "zFILDES", 8)) {
         close(fd);
         return -1;
ea2799a2
     }
f6870133
 
     iov[0].iov_base = dummy;
288057e9
     iov[0].iov_len  = 1;
f6870133
     memset(&msg, 0, sizeof(msg));
288057e9
     msg.msg_control         = fdbuf;
     msg.msg_iov             = iov;
     msg.msg_iovlen          = 1;
     msg.msg_controllen      = CMSG_LEN(sizeof(int));
     cmsg                    = CMSG_FIRSTHDR(&msg);
     cmsg->cmsg_len          = CMSG_LEN(sizeof(int));
     cmsg->cmsg_level        = SOL_SOCKET;
     cmsg->cmsg_type         = SCM_RIGHTS;
f6870133
     *(int *)CMSG_DATA(cmsg) = fd;
288057e9
     if (sendmsg(sockd, &msg, 0) == -1) {
         logg("!FD send failed: %s\n", strerror(errno));
         close(fd);
         return -1;
f6870133
     }
ea2799a2
     close(fd);
f592af6c
     return 1;
f6870133
 }
ea2799a2
 #endif
f6870133
 
247fe3ae
 /* 0: scan, 1: skip */
 static int chkpath(const char *path)
 {
288057e9
     const struct optstruct *opt;
247fe3ae
 
288057e9
     if ((opt = optget(clamdopts, "ExcludePath"))->enabled) {
         while (opt) {
             if (match_regex(path, opt->strarg) == 1) {
ee353f12
                 if (printinfected != 1)
                     logg("~%s: Excluded\n", path);
288057e9
                 return 1;
             }
             opt = opt->nextarg;
         }
247fe3ae
     }
     return 0;
 }
 
eab93adf
 static int ftw_chkpath(const char *path, struct cli_ftw_cbdata *data)
 {
6df13d04
     UNUSEDPARAM(data);
eab93adf
     return chkpath(path);
 }
 
f6870133
 /* Sends a proper scan request to clamd and parses its replies
  * This is used only in non IDSESSION mode
339f62ef
  * Returns the number of infected files or -1 on error
  * NOTE: filename may be NULL for STREAM scantype. */
288057e9
 int dsresult(int sockd, int scantype, const char *filename, int *printok, int *errors)
 {
b33354e5
     int infected = 0, len = 0, beenthere = 0;
5b1eee09
     char *bol, *eol;
     struct RCVLN rcv;
a2a004df
     STATBUF sb;
f6870133
 
288057e9
     if (filename && chkpath(filename))
         return 0;
f6870133
     recvlninit(&rcv, sockd);
 
288057e9
     switch (scantype) {
         case MULTI:
         case CONT:
         case ALLMATCH:
             if (!filename) {
                 logg("Filename cannot be NULL for MULTISCAN or CONTSCAN.\n");
                 return -1;
             }
             len = strlen(filename) + strlen(scancmd[scantype]) + 3;
             if (!(bol = malloc(len))) {
                 logg("!Cannot allocate a command buffer: %s\n", strerror(errno));
                 return -1;
             }
             sprintf(bol, "z%s %s", scancmd[scantype], filename);
             if (sendln(sockd, bol, len)) {
                 free(bol);
                 return -1;
             }
             free(bol);
             break;
f6870133
 
288057e9
         case STREAM:
             /* NULL filename safe in send_stream() */
             len = send_stream(sockd, filename);
             break;
f6870133
 #ifdef HAVE_FD_PASSING
288057e9
         case FILDES:
             /* NULL filename safe in send_fdpass() */
             len = send_fdpass(sockd, filename);
             break;
f6870133
 #endif
     }
 
288057e9
     if (len <= 0) {
         *printok = 0;
         if (errors)
             (*errors)++;
         return len;
22446430
     }
f592af6c
 
288057e9
     while ((len = recvln(&rcv, &bol, &eol))) {
         if (len == -1) return -1;
         beenthere = 1;
         if (!filename) logg("~%s\n", bol);
         if (len > 7) {
             char *colon = strrchr(bol, ':');
             if (colon && colon[1] != ' ') {
                 char *br;
                 *colon = 0;
                 br     = strrchr(bol, '(');
                 if (br)
                     *br = 0;
                 colon = strrchr(bol, ':');
             }
             if (!colon) {
                 char *unkco = "UNKNOWN COMMAND";
                 if (!strncmp(bol, unkco, sizeof(unkco) - 1))
                     logg("clamd replied \"UNKNOWN COMMAND\". Command was %s\n",
                          (scantype < 0 || scantype > MAX_SCANTYPE) ? "unidentified" : scancmd[scantype]);
                 else
                     logg("Failed to parse reply: \"%s\"\n", bol);
                 return -1;
             } else if (!memcmp(eol - 7, " FOUND", 6)) {
                 static char last_filename[PATH_MAX + 1] = {'\0'};
                 *(eol - 7)                              = 0;
                 *printok                                = 0;
9989e980
                 if (scantype != ALLMATCH) {
1f1bf36b
                     infected++;
9989e980
                 } else {
                     if (filename != NULL && strcmp(filename, last_filename)) {
                         infected++;
                         strncpy(last_filename, filename, PATH_MAX);
                         last_filename[PATH_MAX] = '\0';
                     }
1f1bf36b
                 }
288057e9
                 if (filename) {
                     if (scantype >= STREAM) {
                         logg("~%s%s FOUND\n", filename, colon);
                         if (action) action(filename);
                     } else {
                         logg("~%s FOUND\n", bol);
                         *colon = '\0';
                         if (action)
                             action(bol);
                     }
                 }
             } else if (!memcmp(eol - 7, " ERROR", 6)) {
                 if (errors)
                     (*errors)++;
                 *printok = 0;
                 if (filename) {
                     if (scantype >= STREAM)
                         logg("~%s%s\n", filename, colon);
                     else
                         logg("~%s\n", bol);
                 }
             }
         }
f6870133
     }
288057e9
     if (!beenthere) {
339f62ef
         if (!filename) {
288057e9
             logg("STDIN: noreply from clamd\n.");
             return -1;
         }
         if (CLAMSTAT(filename, &sb) == -1) {
             logg("~%s: stat() failed with %s, clamd may not be responding\n",
                  filename, strerror(errno));
             return -1;
         }
         if (!S_ISDIR(sb.st_mode)) {
             logg("~%s: no reply from clamd\n", filename);
             return -1;
         }
6a779d44
     }
5b1eee09
     return infected;
f6870133
 }
 
 /* Used by serial_callback() */
 struct client_serial_data {
     int infected;
     int scantype;
22446430
     int printok;
9cdf477e
     int files;
     int errors;
f6870133
 };
 
83c52f7e
 /* FTW callback for scanning in non IDSESSION mode
  * Returns SUCCESS or BREAK on success, CL_EXXX on error */
288057e9
 static int serial_callback(STATBUF *sb, char *filename, const char *path, enum cli_ftw_reason reason, struct cli_ftw_cbdata *data)
 {
f6870133
     struct client_serial_data *c = (struct client_serial_data *)data->data;
     int sockd, ret;
     const char *f = filename;
 
6df13d04
     UNUSEDPARAM(sb);
 
288057e9
     if (chkpath(path))
         return CL_SUCCESS;
dd5092ff
     c->files++;
288057e9
     switch (reason) {
         case error_stat:
             logg("!Can't access file %s\n", path);
             c->errors++;
             return CL_SUCCESS;
         case error_mem:
             logg("!Memory allocation failed in ftw\n");
             c->errors++;
             return CL_EMEM;
         case warning_skipped_dir:
             logg("^Directory recursion limit reached\n");
         case warning_skipped_link:
             return CL_SUCCESS;
         case warning_skipped_special:
             logg("^%s: Not supported file type\n", path);
             c->errors++;
             return CL_SUCCESS;
         case visit_directory_toplev:
             if (c->scantype >= STREAM)
                 return CL_SUCCESS;
             f        = path;
             filename = NULL;
         case visit_file:
             break;
f6870133
     }
ea2799a2
 
288057e9
     if ((sockd = dconnect()) < 0) {
         if (filename) free(filename);
         c->errors++;
         return CL_EOPEN;
f6870133
     }
dd5092ff
     ret = dsresult(sockd, c->scantype, f, &c->printok, &c->errors);
288057e9
     if (filename) free(filename);
081f6473
     closesocket(sockd);
288057e9
     if (ret < 0) {
         c->errors++;
         return CL_EOPEN;
dd5092ff
     }
5b1eee09
     c->infected += ret;
288057e9
     if (reason == visit_directory_toplev)
         return CL_BREAK;
f6870133
     return CL_SUCCESS;
 }
 
 /* Non-IDSESSION handler
83c52f7e
  * Returns non zero for serious errors, zero otherwise */
288057e9
 int serial_client_scan(char *file, int scantype, int *infected, int *err, int maxlevel, int flags)
 {
f6870133
     struct cli_ftw_cbdata data;
     struct client_serial_data cdata;
83c52f7e
     int ftw;
f6870133
 
     cdata.infected = 0;
288057e9
     cdata.files    = 0;
     cdata.errors   = 0;
     cdata.printok  = printinfected ^ 1;
f6870133
     cdata.scantype = scantype;
288057e9
     data.data      = &cdata;
f6870133
 
eab93adf
     ftw = cli_ftw(file, flags, maxlevel ? maxlevel : INT_MAX, serial_callback, &data, ftw_chkpath);
f6870133
     *infected += cdata.infected;
dd5092ff
     *err += cdata.errors;
83c52f7e
 
288057e9
     if (!cdata.errors && (ftw == CL_SUCCESS || ftw == CL_BREAK)) {
         if (cdata.printok)
             logg("~%s: OK\n", file);
         return 0;
     } else if (!cdata.files) {
         logg("~%s: No files scanned\n", file);
         return 0;
83c52f7e
     }
     return 1;
f6870133
 }
 
 /* Used in IDSESSION mode */
 struct client_parallel_data {
     int infected;
9cdf477e
     int files;
     int errors;
f6870133
     int scantype;
     int sockd;
     int lastid;
22446430
     int printok;
f6870133
     struct SCANID {
288057e9
         unsigned int id;
         const char *file;
         struct SCANID *next;
     } * ids;
f6870133
 };
 
 /* Sends a proper scan request to clamd and parses its replies
  * This is used only in IDSESSION mode
d90f43a1
  * Returns 0 on success, 1 on hard failures, 2 on len == 0 (bb#1717) */
288057e9
 static int dspresult(struct client_parallel_data *c)
 {
f6870133
     const char *filename;
     char *bol, *eol;
     unsigned int rid;
     int len;
     struct SCANID **id = NULL;
     struct RCVLN rcv;
 
     recvlninit(&rcv, c->sockd);
     do {
288057e9
         len = recvln(&rcv, &bol, &eol);
         if (len < 0) return 1;
         if (!len) return 2;
         if ((rid = atoi(bol))) {
             id = &c->ids;
             while (*id) {
                 if ((*id)->id == rid) break;
                 id = &((*id)->next);
             }
             if (!*id) id = NULL;
         }
         if (!id) {
             logg("!Bogus session id from clamd\n");
             return 1;
         }
         filename = (*id)->file;
         if (len > 7) {
             char *colon = strrchr(bol, ':');
             if (!colon) {
                 logg("!Failed to parse reply\n");
                 free((void *)filename);
                 return 1;
             } else if (!memcmp(eol - 7, " FOUND", 6)) {
                 c->infected++;
                 c->printok = 0;
                 logg("~%s%s\n", filename, colon);
                 if (action) action(filename);
             } else if (!memcmp(eol - 7, " ERROR", 6)) {
                 c->errors++;
                 c->printok = 0;
                 logg("~%s%s\n", filename, colon);
             }
         }
         free((void *)filename);
         bol = (char *)*id;
         *id = (*id)->next;
         free(bol);
     } while (rcv.cur != rcv.buf); /* clamd sends whole lines, so, on partial lines, we just assume
f6870133
 				    more data can be recv()'d with close to zero latency */
     return 0;
 }
 
83c52f7e
 /* FTW callback for scanning in IDSESSION mode
5b1eee09
  * Returns SUCCESS on success, CL_EXXX or BREAK on error */
288057e9
 static int parallel_callback(STATBUF *sb, char *filename, const char *path, enum cli_ftw_reason reason, struct cli_ftw_cbdata *data)
 {
f6870133
     struct client_parallel_data *c = (struct client_parallel_data *)data->data;
f592af6c
     struct SCANID *cid;
b33354e5
     int res = CL_CLEAN;
f6870133
 
6df13d04
     UNUSEDPARAM(sb);
 
288057e9
     if (chkpath(path))
         return CL_SUCCESS;
dd5092ff
     c->files++;
288057e9
     switch (reason) {
         case error_stat:
             logg("!Can't access file %s\n", path);
             c->errors++;
             return CL_SUCCESS;
         case error_mem:
             logg("!Memory allocation failed in ftw\n");
             c->errors++;
             return CL_EMEM;
         case warning_skipped_dir:
             logg("^Directory recursion limit reached\n");
             return CL_SUCCESS;
         case warning_skipped_special:
             logg("^%s: Not supported file type\n", path);
             c->errors++;
         case warning_skipped_link:
         case visit_directory_toplev:
             return CL_SUCCESS;
         case visit_file:
             break;
f6870133
     }
 
288057e9
     while (1) {
         /* consume all the available input to let some of the clamd
f6870133
 	 * threads blocked on send() to be dead.
 	 * by doing so we shouldn't deadlock on the next recv() */
288057e9
         fd_set rfds, wfds;
         FD_ZERO(&rfds);
         FD_SET(c->sockd, &rfds);
         FD_ZERO(&wfds);
         FD_SET(c->sockd, &wfds);
         if (select(c->sockd + 1, &rfds, &wfds, NULL, NULL) < 0) {
             if (errno == EINTR) continue;
             free(filename);
             logg("!select() failed during session: %s\n", strerror(errno));
             return CL_BREAK;
         }
         if (FD_ISSET(c->sockd, &rfds)) {
             if (dspresult(c)) {
                 free(filename);
                 return CL_BREAK;
             } else
                 continue;
         }
         if (FD_ISSET(c->sockd, &wfds)) break;
f6870133
     }
 
fadd3046
     cid = (struct SCANID *)malloc(sizeof(struct SCANID));
288057e9
     if (!cid) {
         free(filename);
         logg("!Failed to allocate scanid entry: %s\n", strerror(errno));
         return CL_BREAK;
83c52f7e
     }
288057e9
     cid->id   = ++c->lastid;
f6870133
     cid->file = filename;
f592af6c
     cid->next = c->ids;
288057e9
     c->ids    = cid;
f6870133
 
288057e9
     switch (c->scantype) {
b7990b9c
 #ifdef HAVE_FD_PASSING
288057e9
         case FILDES:
             res = send_fdpass(c->sockd, filename);
             break;
b7990b9c
 #endif
288057e9
         case STREAM:
             res = send_stream(c->sockd, filename);
             break;
f6870133
     }
288057e9
     if (res <= 0) {
         c->printok = 0;
         c->errors++;
         c->ids = cid->next;
         c->lastid--;
         free(cid);
         free(filename);
         return res ? CL_BREAK : CL_SUCCESS;
f592af6c
     }
f6870133
     return CL_SUCCESS;
 }
 
b7990b9c
 /* IDSESSION handler
83c52f7e
  * Returns non zero for serious errors, zero otherwise */
288057e9
 int parallel_client_scan(char *file, int scantype, int *infected, int *err, int maxlevel, int flags)
 {
f6870133
     struct cli_ftw_cbdata data;
     struct client_parallel_data cdata;
83c52f7e
     int ftw;
f6870133
 
288057e9
     if ((cdata.sockd = dconnect()) < 0)
         return 1;
f6870133
 
288057e9
     if (sendln(cdata.sockd, "zIDSESSION", 11)) {
         closesocket(cdata.sockd);
         return 1;
f6870133
     }
 
     cdata.infected = 0;
288057e9
     cdata.files    = 0;
     cdata.errors   = 0;
f6870133
     cdata.scantype = scantype;
288057e9
     cdata.lastid   = 0;
     cdata.ids      = NULL;
     cdata.printok  = printinfected ^ 1;
     data.data      = &cdata;
f6870133
 
eab93adf
     ftw = cli_ftw(file, flags, maxlevel ? maxlevel : INT_MAX, parallel_callback, &data, ftw_chkpath);
83c52f7e
 
288057e9
     if (ftw != CL_SUCCESS) {
         *err += cdata.errors;
         *infected += cdata.infected;
         closesocket(cdata.sockd);
         return 1;
83c52f7e
     }
f6870133
 
6ef6ea82
     sendln(cdata.sockd, "zEND", 5);
27948a03
     while (cdata.ids && !dspresult(&cdata)) continue;
081f6473
     closesocket(cdata.sockd);
6ef6ea82
 
2097428f
     *infected += cdata.infected;
dd5092ff
     *err += cdata.errors;
2097428f
 
288057e9
     if (cdata.ids) {
         logg("!Clamd closed the connection before scanning all files.\n");
         return 1;
533fa895
     }
288057e9
     if (cdata.errors)
         return 1;
dd5092ff
 
288057e9
     if (!cdata.files)
         return 0;
dd5092ff
 
288057e9
     if (cdata.printok)
         logg("~%s: OK\n", file);
83c52f7e
     return 0;
f6870133
 }