~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to clamd/scanner.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:
18
18
 *  MA 02110-1301, USA.
19
19
 */
20
20
 
21
 
#ifdef  _MSC_VER
22
 
#include <winsock.h>
23
 
#endif
24
 
 
25
21
#if HAVE_CONFIG_H
26
22
#include "clamav-config.h"
27
23
#endif
35
31
#include <errno.h>
36
32
#include <sys/stat.h>
37
33
#include <sys/types.h>
38
 
#ifndef C_WINDOWS
 
34
#include <dirent.h>
 
35
#ifndef _WIN32
39
36
#include <sys/time.h>
40
37
#include <sys/wait.h>
41
38
#include <sys/param.h>
42
39
#include <signal.h>
43
 
#include <dirent.h>
44
40
#include <sys/socket.h>
45
41
#include <netinet/in.h>
46
42
#include <arpa/inet.h>
63
59
#include "others.h"
64
60
#include "scanner.h"
65
61
#include "shared.h"
66
 
#include "network.h"
67
62
#include "thrmgr.h"
68
63
#include "server.h"
69
64
 
71
66
dev_t procdev; /* /proc device */
72
67
#endif
73
68
 
74
 
#ifndef C_WINDOWS
75
 
#define closesocket(s)  close(s)
76
 
#endif
77
 
 
78
69
extern int progexit;
79
70
extern time_t reloaded_time;
80
71
extern pthread_mutex_t reload_mutex;
115
106
            scandata->errors++;
116
107
            return CL_EMEM;
117
108
        case error_stat:
118
 
            if (msg == scandata->toplevel_path)
119
 
                conn_reply_errno(scandata->conn, msg, "lstat() failed:");
 
109
            conn_reply_errno(scandata->conn, msg, "lstat() failed:");
120
110
            logg("^lstat() failed on: %s\n", msg);
121
111
            scandata->errors++;
122
112
            return CL_SUCCESS;
173
163
                pthread_mutex_lock(&reload_mutex);
174
164
                client_conn->engine_timestamp = reloaded_time;
175
165
                pthread_mutex_unlock(&reload_mutex);
176
 
                if(!thrmgr_group_dispatch(scandata->thr_pool, scandata->group, client_conn)) {
 
166
                if(!thrmgr_group_dispatch(scandata->thr_pool, scandata->group, client_conn, 1)) {
177
167
                    logg("!thread dispatch failed\n");
178
168
                    free(filename);
179
169
                    return CL_EMEM;
246
236
{
247
237
        struct scan_cb_data *scandata = data->data;
248
238
        const struct optstruct *opt;
 
239
        struct stat statbuf;
249
240
 
250
241
    if((opt = optget(scandata->opts, "ExcludePath"))->enabled) {
251
242
        while(opt) {
252
243
            if(match_regex(path, opt->strarg) == 1) {
253
244
                if(scandata->type != TYPE_MULTISCAN)
254
245
                    conn_reply_single(scandata->conn, path, "Excluded");
255
 
                    return 1;
 
246
                return 1;
256
247
            }
257
248
            opt = (const struct optstruct *) opt->nextarg;
258
249
        }
259
250
    }
 
251
 
 
252
    if(!optget(scandata->opts, "CrossFilesystems")->enabled) {
 
253
        if(stat(path, &statbuf) == 0) {
 
254
            if(statbuf.st_dev != scandata->dev) {
 
255
                if(scandata->type != TYPE_MULTISCAN)
 
256
                    conn_reply_single(scandata->conn, path, "Excluded (another filesystem)");
 
257
                return 1;
 
258
            }
 
259
        }
 
260
    }
 
261
 
260
262
    return 0;
261
263
}
262
264
 
388
390
        return -1;
389
391
    }
390
392
 
391
 
    snprintf(peer_addr, sizeof(peer_addr), "%s", inet_ntoa(peer.sin_addr));
 
393
    *peer_addr = '\0';
 
394
    inet_ntop(peer.sin_family, &peer.sin_addr, peer_addr, sizeof(peer_addr));
392
395
    logg("*Accepted connection from %s on port %u, fd %d\n", peer_addr, port, acceptd);
393
396
 
394
397
    if(cli_gentempfd(optget(opts, "TemporaryDirectory")->strarg, &tmpname, &tmpd)) {