~ubuntu-branches/ubuntu/raring/clamav/raring

« back to all changes in this revision

Viewing changes to clamconf/clamconf.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran
  • Date: 2008-09-05 17:25:34 UTC
  • mfrom: (0.35.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080905172534-yi3f8fkye1o7u1r3
* New upstream version (closes: #497662, #497773)
  - lots of new options for clamd.conf
  - fixes CVEs CVE-2008-3912, CVE-2008-3913, CVE-2008-3914, and
    CVE-2008-1389
* No longer supports --unzip option, so typo is gone (closes: #496276)
* Translations:
  - sv (thanks Martin Bagge <brother@bsnet.se>) (closes: #491760)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include "shared/misc.h"
36
36
#include "libclamav/clamav.h"
 
37
#include "libclamav/version.h"
37
38
 
38
39
#include "cfgparser.h"
39
40
#define _GNU_SOURCE
48
49
        return;
49
50
    }
50
51
 
51
 
    switch(opt->argtype) {
52
 
        case OPT_STR:
53
 
        case OPT_FULLSTR:
54
 
        case OPT_QUOTESTR:
55
 
            if(!nondef || !opt->strarg || strcmp(opt->strarg, cpt->strarg))
56
 
                printf("%s = \"%s\"\n", opt->name, cpt->strarg);
57
 
            break;
58
 
        case OPT_NUM:
59
 
        case OPT_COMPSIZE:
60
 
            if(!nondef || (opt->numarg != cpt->numarg))
61
 
                printf("%s = %u\n", opt->name, cpt->numarg);
62
 
            break;
63
 
        case OPT_BOOL:
64
 
            if(!nondef || (opt->numarg != cpt->numarg))
65
 
                printf("%s = %s\n", opt->name, cpt->enabled ? "yes" : "no");
66
 
            break;
67
 
        default:
68
 
            printf("%s: UNKNOWN ARGUMENT TYPE\n", opt->name);
 
52
    while(cpt) {
 
53
        switch(opt->argtype) {
 
54
            case OPT_STR:
 
55
            case OPT_FULLSTR:
 
56
            case OPT_QUOTESTR:
 
57
                if(!nondef || !opt->strarg || strcmp(opt->strarg, cpt->strarg))
 
58
                    printf("%s = \"%s\"\n", opt->name, cpt->strarg);
 
59
                break;
 
60
            case OPT_NUM:
 
61
            case OPT_COMPSIZE:
 
62
                if(!nondef || (opt->numarg != cpt->numarg))
 
63
                    printf("%s = %u\n", opt->name, cpt->numarg);
 
64
                break;
 
65
            case OPT_BOOL:
 
66
                if(!nondef || (opt->numarg != cpt->numarg))
 
67
                    printf("%s = %s\n", opt->name, cpt->enabled ? "yes" : "no");
 
68
                break;
 
69
            default:
 
70
                printf("%s: UNKNOWN ARGUMENT TYPE\n", opt->name);
 
71
        }
 
72
        cpt = cpt->nextarg;
69
73
    }
70
74
}
71
75
 
175
179
{
176
180
        struct cl_cvd *cvd;
177
181
        char path[256];
178
 
        unsigned int inc = 0;
 
182
        unsigned int cld = 0;
179
183
        time_t t;
180
184
 
181
185
 
182
186
    snprintf(path, sizeof(path), "%s/%s.cvd", dir, db);
183
187
    if(access(path, R_OK) == -1) {
184
 
        snprintf(path, sizeof(path), "%s/%s.inc/%s.info", dir, db, db);
185
 
        inc = 1;
 
188
        snprintf(path, sizeof(path), "%s/%s.cld", dir, db);
 
189
        cld = 1;
186
190
        if(access(path, R_OK) == -1) {
187
191
            printf("%s db: Not found\n", db);
188
192
            return;
191
195
 
192
196
    if((cvd = cl_cvdhead(path))) {
193
197
        t = (time_t) cvd->stime;
194
 
        printf("%s db: Format: %s, Version: %u, Build time: %s", db, inc ? ".inc" : ".cvd", cvd->version, ctime(&t));
 
198
        printf("%s db: Format: %s, Version: %u, Build time: %s", db, cld ? ".cld" : ".cvd", cvd->version, ctime(&t));
195
199
        cl_cvdfree(cvd);
196
200
    }
197
201
}
198
202
 
 
203
static void version(void)
 
204
{
 
205
    printf("Clam AntiVirus Configuration Tool %s\n", get_version());
 
206
}
 
207
 
199
208
static void help(void)
200
209
{
201
210
    printf("\n");
202
 
    printf("             Clam AntiVirus: Configuration Tool "VERSION"\n");
 
211
    printf("             Clam AntiVirus: Configuration Tool %s\n", get_version());
203
212
    printf("         (C) 2006 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
204
213
 
205
214
    printf("    --help                 -h              show help\n");
 
215
    printf("    --version              -v              show version\n");
206
216
    printf("    --config-dir DIR       -c DIR          search for config files in DIR\n");
207
217
    printf("    --non-default          -n              only print non-default settings\n");
208
218
    printf("\n");
209
219
}
210
220
 
 
221
 
 
222
#ifndef REPO_VERSION
 
223
#define REPO_VERSION VERSION
 
224
#endif
 
225
 
211
226
int main(int argc, char **argv)
212
227
{
213
228
        char path[1024];
214
229
        struct stat sb;
215
230
        int ret, opt_index, nondef = 0;
216
 
        const char *getopt_parameters = "hc:n";
 
231
        const char *getopt_parameters = "hVc:n";
217
232
        static struct option long_options[] = {
218
233
            {"help", 0, 0, 'h'},
 
234
            {"version", 0, 0, 'V'},
219
235
            {"config-dir", 1, 0, 'c'},
220
236
            {"non-default", 0, 0, 'n'},
221
237
            {0, 0, 0, 0}
249
265
                nondef = 1;
250
266
                break;
251
267
 
 
268
            case 'V':
 
269
                version();
 
270
                free(confdir);
 
271
                exit(0);
 
272
 
252
273
            default:
253
274
                printf("ERROR: Unknown option passed\n");
254
275
                free(confdir);
280
301
    printf("------------------------------\n");
281
302
 
282
303
#ifdef CL_EXPERIMENTAL
283
 
    printf("Engine version: "VERSION" (with experimental code)\n");
 
304
    printf("Engine version: %s (with experimental code)\n", get_version());
284
305
#else
285
 
    printf("Engine version: "VERSION"\n");
 
306
    printf("Engine version: %s\n", get_version());
286
307
#endif
287
308
 
288
 
    if(strcmp(VERSION, cl_retver()))
289
 
        printf("WARNING: Version mismatch: clamconf: "VERSION", libclamav: %s\n", cl_retver());
 
309
    if(strcmp(REPO_VERSION, cl_retver()))
 
310
        printf("WARNING: Version mismatch: clamconf: "REPO_VERSION", libclamav: %s\n", cl_retver());
290
311
 
291
312
    printf("Database directory: ");
292
313
    dbdir = freshdbdir();