~ubuntu-branches/ubuntu/jaunty/clamav/jaunty-updates

« back to all changes in this revision

Viewing changes to clamav-milter/clamfi.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman, Scott Kitterman, Jamie Strandboge, Michael Meskes, Stephen Gran, Michael Tautschnig
  • Date: 2009-07-30 15:00:14 UTC
  • mfrom: (64.1.1 jaunty-proposed)
  • Revision ID: james.westby@ubuntu.com-20090730150014-0q3rddh939yhe0uy
Tags: 0.95.2+dfsg-4ubuntu1.1
* New upstream micro-version ugrade (LP: #394870)
* Upgrade packaging to karmic standard due to immaturity of 0.95 packaging
  when jaunty released:

[ Scott Kitterman ]
* Add the milter logrotate file to the list of purged files
  - Cherry picked from pkg-clamav git (thanks to Stephen Gran)
    0aebeb19f8169da097d21b021dd67ca06ffe3ca6

[ Jamie Strandboge ]
* update clamav-freshclam and clamav-daemon postinst to reload the
  individual AppArmor profiles instead of reloading all of AppArmor
  - LP: #397988

[ Michael Meskes ]
* Applied patch assembled by Christian Perrier <bubulle@debian.org>:
  - Debconf templates and debian/control reviewed by the debian-l10n-
    english team as part of the Smith review project. Closes: #523573
  - [Debconf translation updates]
    - Swedish. Closes: #525044
    - Japanese. Closes: #525084
    - French. Closes: #526024
    - Portuguese. Closes: #526644
    - Russian. Closes: #526727
    - German. Closes: #526730
    - Dutch. Closes: #526745
    - Galician. Closes: #527320
    - Basque. Closes: #530854
    - Finnish (closes: #534339)
* Made pid files word readable. There doesn't seem to be any sense in not
  doing this given that the information is available for everyone anyway.
  Closes: #527901

[ Stephen Gran ]
* Lots more milter maintainer script cleanups
* Don't abort dpkg on failed start (closes: #533397)
* Get rid of spurious patch downgrading version (closes: #533638)
* Should fix crash on unofficial sigs (closes: #525483)
* Get rid of ridiculous home rolled suid (closes: #522106)
* Freshclam gets 0400 or 0444 config file (closes: #524356)
* Debconf templates and debian/control reviewed by the debian-l10n-
  english team as part of the Smith review project. Closes: #523573
* [Debconf translation updates]
  - French (closes: #533667)
  - Portuguese (closes: #533779)
  - Russian (closes: #533548)
  - Swedish (closes: #533568)
  - Swedish. Closes: #525044
  - Japanese. Closes: #525084
  - French. Closes: #526024
  - Portuguese. Closes: #526644
  - Russian. Closes: #526727
  - German. Closes: #526730
  - Dutch. Closes: #526745
  - Galician. Closes: #527320
* Define status_of_proc in the event that it's not in lsb/init-functions
  (closes: #527903)
* Stop referencing /etc/default/clamav-milter and drop command line 
  arguments in milter init script (closes: #526123)
* Fix wrong variable useage in milter init script
* More work on clamav-milter's init script

[ Michael Tautschnig ]
* Unignored make check results on ia64, sparc (alpha still broken): tell
  electric-fence that the alignment is at least 8 bytes (thanks Aurelien
  Jarno).
* Fixed LogFile handling in clamav-milter.postinst (logrotation was broken) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
static sfsistat (*InfectedAction)(SMFICTX *ctx);
53
53
static char *rejectfmt = NULL;
54
54
 
55
 
int addxvirus = 0;
 
55
int addxvirus = 0; /* 0 - don't add | 1 - replace | 2 - add */
56
56
char xvirushdr[255];
57
57
enum {
58
58
    LOGINF_NONE,
76
76
    unsigned int bufsz;
77
77
    unsigned int all_whitelisted;
78
78
    unsigned int gotbody;
 
79
    unsigned int scanned_count;
 
80
    unsigned int status_count;
79
81
};
80
82
 
81
83
 
82
 
static void add_x_header(SMFICTX *ctx, char *st) {
83
 
    smfi_chgheader(ctx, (char *)"X-Virus-Scanned", 1, xvirushdr);
84
 
    smfi_chgheader(ctx, (char *)"X-Virus-Status", 1, st);
 
84
static void add_x_header(SMFICTX *ctx, char *st, unsigned int scanned, unsigned int status) {
 
85
    if(addxvirus == 1) { /* Replace/Yes */
 
86
        while(scanned)
 
87
            if(smfi_chgheader(ctx, (char *)"X-Virus-Scanned", scanned--, NULL) != MI_SUCCESS)
 
88
                logg("^Failed to remove existing X-Virus-Scanned header\n");
 
89
        while(status)
 
90
            if(smfi_chgheader(ctx, (char *)"X-Virus-Status", status--, NULL) != MI_SUCCESS)
 
91
                logg("^Failed to remove existing X-Virus-Status header\n");
 
92
        if(smfi_addheader(ctx, (char *)"X-Virus-Scanned", xvirushdr) != MI_SUCCESS)
 
93
            logg("^Failed to add X-Virus-Scanned header\n");
 
94
        if(smfi_addheader(ctx, (char *)"X-Virus-Status", st) != MI_SUCCESS)
 
95
            logg("^Failed to add X-Virus-Status header\n");
 
96
    } else { /* Add */
 
97
        if(smfi_insheader(ctx, 1, (char *)"X-Virus-Scanned", xvirushdr) != MI_SUCCESS)
 
98
            logg("^Failed to insert X-Virus-Scanned header\n");
 
99
        if(smfi_insheader(ctx, 1, (char *)"X-Virus-Status", st) != MI_SUCCESS)
 
100
            logg("^Failed to insert X-Virus-Status header\n");
 
101
    }
85
102
}
86
103
 
87
104
enum CFWHAT {
201
218
            cf->msg_id = strdup(headerv ? headerv : "");
202
219
    }
203
220
 
 
221
    if(addxvirus==1) {
 
222
        if(!strcasecmp(headerf, "X-Virus-Scanned")) cf->scanned_count++;
 
223
        if(!strcasecmp(headerf, "X-Virus-Status")) cf->status_count++;
 
224
    }
 
225
 
204
226
    if((ret = sendchunk(cf, (unsigned char *)headerf, strlen(headerf), ctx)) != SMFIS_CONTINUE)
205
227
        return ret;
206
228
    if((ret = sendchunk(cf, (unsigned char *)": ", 2, ctx)) != SMFIS_CONTINUE)
290
312
 
291
313
    len = strlen(reply);
292
314
    if(len>5 && !strcmp(reply + len - 5, ": OK\n")) {
293
 
        if(addxvirus) add_x_header(ctx, "Clean");
 
315
        if(addxvirus) add_x_header(ctx, "Clean", cf->scanned_count, cf->status_count);
294
316
        ret = CleanAction(ctx);
295
317
    } else if (len>7 && !strcmp(reply + len - 7, " FOUND\n")) {
296
318
        cf->virusname = NULL;
309
331
                    char msg[255];
310
332
                    snprintf(msg, sizeof(msg), "Infected (%s)", vir);
311
333
                    msg[sizeof(msg)-1] = '\0';
312
 
                    add_x_header(ctx, msg);
 
334
                    add_x_header(ctx, msg, cf->scanned_count, cf->status_count);
313
335
                }
314
336
 
315
337
                if(loginfected) {
402
424
    }
403
425
    return SMFIS_ACCEPT;
404
426
}
 
427
 
405
428
static sfsistat action_reject_msg(SMFICTX *ctx) {
406
429
    struct CLAMFI *cf;
407
430
    char buf[1024];
554
577
    cf->all_whitelisted = 1;
555
578
    cf->gotbody = 0;
556
579
    cf->msg_subj = cf->msg_date = cf->msg_id = NULL;
 
580
    if(addxvirus==1) {
 
581
        cf->scanned_count = 0;
 
582
        cf->status_count = 0;
 
583
    }
557
584
    smfi_setpriv(ctx, (void *)cf);
558
585
 
559
586
    return SMFIS_CONTINUE;