~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to clamdscan/clamdscan.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <stdio.h>
26
26
#include <string.h>
27
27
#include <stdlib.h>
 
28
#ifdef HAVE_UNISTD_H
28
29
#include <unistd.h>
 
30
#endif
 
31
#ifndef _WIN32
29
32
#include <sys/time.h>
 
33
#endif
30
34
#include <time.h>
31
35
#include <signal.h>
32
36
 
51
55
 
52
56
int main(int argc, char **argv)
53
57
{
54
 
        int ds, dms, ret, infected;
 
58
        int ds, dms, ret, infected = 0, err = 0;
55
59
        struct timeval t1, t2;
56
 
        struct timezone tz;
57
60
        time_t starttime;
58
61
        struct optstruct *opts;
59
62
        const struct optstruct *opt;
 
63
#ifndef _WIN32
60
64
        struct sigaction sigact;
61
 
 
 
65
#endif
62
66
 
63
67
    if((opts = optparse(NULL, argc, argv, 1, OPT_CLAMDSCAN, OPT_CLAMSCAN, NULL)) == NULL) {
64
68
        mprintf("!Can't parse command line options\n");
116
120
        exit(2);
117
121
    }
118
122
 
 
123
#ifndef _WIN32
119
124
    memset(&sigact, 0, sizeof(struct sigaction));
120
125
    sigact.sa_handler = SIG_IGN;
121
126
    sigemptyset(&sigact.sa_mask);
122
127
    sigaddset(&sigact.sa_mask, SIGPIPE);
123
128
    sigaction(SIGPIPE, &sigact, NULL);
 
129
#endif
124
130
 
125
131
    time(&starttime);
126
132
    /* ctime() does \n, but I need it once more */
127
133
 
128
 
    gettimeofday(&t1, &tz);
 
134
    gettimeofday(&t1, NULL);
129
135
 
130
 
    ret = client(opts, &infected);
 
136
    ret = client(opts, &infected, &err);
131
137
 
132
138
    /* TODO: Implement STATUS in clamd */
133
 
    if((infected || ret != 2) && !optget(opts, "no-summary")->enabled) {
134
 
        gettimeofday(&t2, &tz);
 
139
    if(!optget(opts, "no-summary")->enabled) {
 
140
        gettimeofday(&t2, NULL);
135
141
        ds = t2.tv_sec - t1.tv_sec;
136
142
        dms = t2.tv_usec - t1.tv_usec;
137
143
        ds -= (dms < 0) ? (1):(0);
138
144
        dms += (dms < 0) ? (1000000):(0);
139
145
        logg("\n----------- SCAN SUMMARY -----------\n");
140
146
        logg("Infected files: %d\n", infected);
 
147
        if(err)
 
148
            logg("Total errors: %d\n", err);
141
149
        if(notremoved) {
142
150
            logg("Not removed: %d\n", notremoved);
143
151
        }