git-svn: trunk@2725
Tomasz Kojm authored on 2007/02/13 08:05:58... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Feb 13 00:02:26 CET 2007 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * clamconf/clamconf.c: add -n switch |
|
4 |
+ * docs/man: add clamconf.1 manpage |
|
5 |
+ |
|
1 | 6 |
Mon Feb 12 22:25:30 GMT 2007 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* Changed some URLs, patch from Luca |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2006 Tomasz Kojm <tkojm@clamav.net> |
|
2 |
+ * Copyright (C) 2006 - 2007 Tomasz Kojm <tkojm@clamav.net> |
|
3 | 3 |
* |
4 | 4 |
* This program is free software; you can redistribute it and/or modify |
5 | 5 |
* it under the terms of the GNU General Public License as published by |
... | ... |
@@ -32,40 +32,37 @@ |
32 | 32 |
#define _GNU_SOURCE |
33 | 33 |
#include "getopt.h" |
34 | 34 |
|
35 |
-static void printopt(const struct cfgoption *opt, const struct cfgstruct *cpt) |
|
35 |
+static void printopt(const struct cfgoption *opt, const struct cfgstruct *cpt, int nondef) |
|
36 | 36 |
{ |
37 |
- if(!cpt->enabled) { |
|
38 |
- printf("%s not set\n", opt->name); |
|
37 |
+ |
|
38 |
+ if(!cpt->enabled && opt->numarg == -1) { |
|
39 |
+ if(!nondef || (opt->numarg != cpt->numarg)) |
|
40 |
+ printf("%s not set\n", opt->name); |
|
39 | 41 |
return; |
40 | 42 |
} |
41 | 43 |
|
42 |
- /* |
|
43 |
- printf("opt: %s, %d, %d, %s, %d, %d\n", opt->name, opt->argtype, opt->numarg, opt->strarg, opt->multiple, opt->owner); |
|
44 |
- printf("cpt: %s, %s, %d, %d, %d\n", cpt->optname, cpt->strarg, cpt->numarg, cpt->enabled, cpt->multiple); |
|
45 |
- */ |
|
46 |
- |
|
47 | 44 |
switch(opt->argtype) { |
48 | 45 |
case OPT_STR: |
49 | 46 |
case OPT_FULLSTR: |
50 | 47 |
case OPT_QUOTESTR: |
51 |
- printf("%s = \"%s\"\n", opt->name, cpt->strarg); |
|
48 |
+ if(!nondef || !opt->strarg || strcmp(opt->strarg, cpt->strarg)) |
|
49 |
+ printf("%s = \"%s\"\n", opt->name, cpt->strarg); |
|
52 | 50 |
break; |
53 | 51 |
case OPT_NUM: |
54 | 52 |
case OPT_COMPSIZE: |
55 |
- printf("%s = %d\n", opt->name, cpt->numarg); |
|
53 |
+ if(!nondef || (opt->numarg != cpt->numarg)) |
|
54 |
+ printf("%s = %u\n", opt->name, cpt->numarg); |
|
56 | 55 |
break; |
57 | 56 |
case OPT_BOOL: |
58 |
- if(cpt->enabled) |
|
59 |
- printf("%s = yes\n", opt->name); |
|
60 |
- else |
|
61 |
- printf("%s = no\n", opt->name); |
|
57 |
+ if(!nondef || (opt->numarg != cpt->numarg)) |
|
58 |
+ printf("%s = %s\n", opt->name, cpt->enabled ? "yes" : "no"); |
|
62 | 59 |
break; |
63 | 60 |
default: |
64 | 61 |
printf("%s: UNKNOWN ARGUMENT TYPE\n", opt->name); |
65 | 62 |
} |
66 | 63 |
} |
67 | 64 |
|
68 |
-static void printcfg(const char *cfgfile) |
|
65 |
+static void printcfg(const char *cfgfile, int nondef) |
|
69 | 66 |
{ |
70 | 67 |
const struct cfgoption *opt; |
71 | 68 |
const struct cfgstruct *cpt; |
... | ... |
@@ -107,7 +104,7 @@ static void printcfg(const char *cfgfile) |
107 | 107 |
break; |
108 | 108 |
if((opt->owner & OPT_CLAMD) && (opt->owner & OPT_FRESHCLAM)) { |
109 | 109 |
cpt = cfgopt(cfg, opt->name); |
110 |
- printopt(opt, cpt); |
|
110 |
+ printopt(opt, cpt, nondef); |
|
111 | 111 |
} |
112 | 112 |
} |
113 | 113 |
|
... | ... |
@@ -118,7 +115,7 @@ static void printcfg(const char *cfgfile) |
118 | 118 |
break; |
119 | 119 |
if((opt->owner & OPT_CLAMD) && !(opt->owner & OPT_FRESHCLAM)) { |
120 | 120 |
cpt = cfgopt(cfg, opt->name); |
121 |
- printopt(opt, cpt); |
|
121 |
+ printopt(opt, cpt, nondef); |
|
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
... | ... |
@@ -129,7 +126,7 @@ static void printcfg(const char *cfgfile) |
129 | 129 |
break; |
130 | 130 |
if((opt->owner & OPT_FRESHCLAM) && !(opt->owner & OPT_CLAMD)) { |
131 | 131 |
cpt = cfgopt(cfg, opt->name); |
132 |
- printopt(opt, cpt); |
|
132 |
+ printopt(opt, cpt, nondef); |
|
133 | 133 |
} |
134 | 134 |
} |
135 | 135 |
|
... | ... |
@@ -145,7 +142,7 @@ static void printcfg(const char *cfgfile) |
145 | 145 |
break; |
146 | 146 |
if(opt->owner & OPT_CLAMD) { |
147 | 147 |
cpt = cfgopt(cfg, opt->name); |
148 |
- printopt(opt, cpt); |
|
148 |
+ printopt(opt, cpt, nondef); |
|
149 | 149 |
} |
150 | 150 |
} |
151 | 151 |
} else { |
... | ... |
@@ -158,7 +155,7 @@ static void printcfg(const char *cfgfile) |
158 | 158 |
break; |
159 | 159 |
if(opt->owner & OPT_FRESHCLAM) { |
160 | 160 |
cpt = cfgopt(cfg, opt->name); |
161 |
- printopt(opt, cpt); |
|
161 |
+ printopt(opt, cpt, nondef); |
|
162 | 162 |
} |
163 | 163 |
} |
164 | 164 |
} |
... | ... |
@@ -175,6 +172,7 @@ static void help(void) |
175 | 175 |
|
176 | 176 |
printf(" --help -h show help\n"); |
177 | 177 |
printf(" --config-dir DIR -c DIR search for config files in DIR\n"); |
178 |
+ printf(" --non-default -n only print non-default settings\n"); |
|
178 | 179 |
printf("\n"); |
179 | 180 |
} |
180 | 181 |
|
... | ... |
@@ -182,11 +180,12 @@ int main(int argc, char **argv) |
182 | 182 |
{ |
183 | 183 |
char path[1024]; |
184 | 184 |
struct stat sb; |
185 |
- int ret, opt_index; |
|
186 |
- const char *getopt_parameters = "hc:"; |
|
185 |
+ int ret, opt_index, nondef = 0; |
|
186 |
+ const char *getopt_parameters = "hc:n"; |
|
187 | 187 |
static struct option long_options[] = { |
188 | 188 |
{"help", 0, 0, 'h'}, |
189 | 189 |
{"config-dir", 1, 0, 'c'}, |
190 |
+ {"non-default", 0, 0, 'n'}, |
|
190 | 191 |
{0, 0, 0, 0} |
191 | 192 |
}; |
192 | 193 |
char *confdir = strdup(CONFDIR); |
... | ... |
@@ -207,15 +206,17 @@ int main(int argc, char **argv) |
207 | 207 |
case 'c': |
208 | 208 |
free(confdir); |
209 | 209 |
confdir = strdup(optarg); |
210 |
- printf("LONG: %s, %c, idx: %d\n", long_options[opt_index].name, ret, opt_index); |
|
211 | 210 |
break; |
212 | 211 |
|
213 | 212 |
case 'h': |
214 | 213 |
help(); |
215 | 214 |
free(confdir); |
216 |
- printf("LONG: %s, %c, idx: %d\n", long_options[opt_index].name, ret, opt_index); |
|
217 | 215 |
exit(0); |
218 | 216 |
|
217 |
+ case 'n': |
|
218 |
+ nondef = 1; |
|
219 |
+ break; |
|
220 |
+ |
|
219 | 221 |
default: |
220 | 222 |
printf("ERROR: Unknown option passed\n"); |
221 | 223 |
free(confdir); |
... | ... |
@@ -225,14 +226,14 @@ int main(int argc, char **argv) |
225 | 225 |
|
226 | 226 |
snprintf(path, sizeof(path), "%s/clamd.conf", confdir); |
227 | 227 |
if(stat(path, &sb) != -1) { |
228 |
- printcfg(path); |
|
228 |
+ printcfg(path, nondef); |
|
229 | 229 |
found = 1; |
230 | 230 |
printf("\n"); |
231 | 231 |
} |
232 | 232 |
|
233 | 233 |
snprintf(path, sizeof(path), "%s/freshclam.conf", confdir); |
234 | 234 |
if(stat(path, &sb) != -1) { |
235 |
- printcfg(path); |
|
235 |
+ printcfg(path, nondef); |
|
236 | 236 |
found = 1; |
237 | 237 |
} |
238 | 238 |
|
... | ... |
@@ -17,4 +17,4 @@ |
17 | 17 |
# MA 02110-1301, USA. |
18 | 18 |
|
19 | 19 |
EXTRA_DIST = html man clamdoc.pdf clamdoc.tex clamav-mirror-howto.pdf signatures.pdf signatures.tex clam.eps |
20 |
-man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/freshclam.conf.5 |
|
20 |
+man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/freshclam.conf.5 man/clamconf.1 |
... | ... |
@@ -200,7 +200,7 @@ target_cpu = @target_cpu@ |
200 | 200 |
target_os = @target_os@ |
201 | 201 |
target_vendor = @target_vendor@ |
202 | 202 |
EXTRA_DIST = html man clamdoc.pdf clamdoc.tex clamav-mirror-howto.pdf signatures.pdf signatures.tex clam.eps |
203 |
-man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/freshclam.conf.5 |
|
203 |
+man_MANS = man/clamscan.1 man/freshclam.1 man/sigtool.1 man/clamd.8 man/clamd.conf.5 man/clamdscan.1 man/clamav-milter.8 man/freshclam.conf.5 man/clamconf.1 |
|
204 | 204 |
all: all-am |
205 | 205 |
|
206 | 206 |
.SUFFIXES: |
207 | 207 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,30 @@ |
0 |
+.TH "Config tool" "1" "February 12, 2007" "ClamAV 0.90" "Clam AntiVirus" |
|
1 |
+.SH "NAME" |
|
2 |
+.LP |
|
3 |
+clamconf \- Clam AntiVirus configuration utility |
|
4 |
+.SH "SYNOPSIS" |
|
5 |
+.LP |
|
6 |
+clamconf [options] |
|
7 |
+.SH "DESCRIPTION" |
|
8 |
+.LP |
|
9 |
+clamconf displays the values of configuration options. |
|
10 |
+.SH "OPTIONS" |
|
11 |
+.LP |
|
12 |
+ |
|
13 |
+.TP |
|
14 |
+\fB\-h, \-\-help\fR |
|
15 |
+Display help and exit. |
|
16 |
+.TP |
|
17 |
+\fB\-c DIR, \-\-config\-dir DIR\fR |
|
18 |
+Search for configuration files clamd.conf and freshclam.conf in DIR. |
|
19 |
+.TP |
|
20 |
+\fB\-n, \-\-non\-default\fR |
|
21 |
+Only print non-default settings. |
|
22 |
+.SH "CREDITS" |
|
23 |
+The idea of this tool is based on Postfix's postconf. clamconf was created under pressure from Tomasz Papszun ;-) |
|
24 |
+.SH "AUTHOR" |
|
25 |
+.LP |
|
26 |
+Tomasz Kojm <tkojm@clamav.net> |
|
27 |
+.SH "SEE ALSO" |
|
28 |
+.LP |
|
29 |
+clamd.conf(5), freshclam.conf(5) |
... | ... |
@@ -93,12 +93,12 @@ struct cfgoption cfg_options[] = { |
93 | 93 |
{"SelfCheck", OPT_NUM, 1800, NULL, 0, OPT_CLAMD}, |
94 | 94 |
{"VirusEvent", OPT_FULLSTR, -1, NULL, 0, OPT_CLAMD}, |
95 | 95 |
{"NodalCoreAcceleration", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
96 |
- {"ClamukoScanOnAccess", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
|
97 |
- {"ClamukoScanOnOpen", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
|
98 |
- {"ClamukoScanOnClose", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
|
99 |
- {"ClamukoScanOnExec", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
|
100 |
- {"ClamukoIncludePath", OPT_QUOTESTR, 0, NULL, 0, OPT_CLAMD}, |
|
101 |
- {"ClamukoExcludePath", OPT_QUOTESTR, 0, NULL, 0, OPT_CLAMD}, |
|
96 |
+ {"ClamukoScanOnAccess", OPT_BOOL, -1, NULL, 0, OPT_CLAMD}, |
|
97 |
+ {"ClamukoScanOnOpen", OPT_BOOL, -1, NULL, 0, OPT_CLAMD}, |
|
98 |
+ {"ClamukoScanOnClose", OPT_BOOL, -1, NULL, 0, OPT_CLAMD}, |
|
99 |
+ {"ClamukoScanOnExec", OPT_BOOL, -1, NULL, 0, OPT_CLAMD}, |
|
100 |
+ {"ClamukoIncludePath", OPT_QUOTESTR, -1, NULL, 0, OPT_CLAMD}, |
|
101 |
+ {"ClamukoExcludePath", OPT_QUOTESTR, -1, NULL, 0, OPT_CLAMD}, |
|
102 | 102 |
{"ClamukoMaxFileSize", OPT_COMPSIZE, 5242880, NULL, 0, OPT_CLAMD}, |
103 | 103 |
{"DatabaseOwner", OPT_QUOTESTR, -1, CLAMAVUSER, 0, OPT_FRESHCLAM}, |
104 | 104 |
{"Checks", OPT_NUM, 12, NULL, 0, OPT_FRESHCLAM}, |