git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@607 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/06/13 11:11:26... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sun Jun 13 04:03:01 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * freshclam, clamd: log version and platform information (requested by |
|
4 |
+ Tomasz Papszun <tomek*clamav.net>) |
|
5 |
+ |
|
1 | 6 |
Sat Jun 12 21:08:55 CEST 2004 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav: mspack: fix bounds error (found by Nigel). Original author |
... | ... |
@@ -26,6 +26,9 @@ |
26 | 26 |
* |
27 | 27 |
* Change History: |
28 | 28 |
* $Log: clamav-milter.c,v $ |
29 |
+ * Revision 1.94 2004/06/13 02:11:25 kojm |
|
30 |
+ * improve output |
|
31 |
+ * |
|
29 | 32 |
* Revision 1.93 2004/06/08 21:44:59 nigelhorne |
30 | 33 |
* Ensure --from takes an argument |
31 | 34 |
* |
... | ... |
@@ -290,7 +293,7 @@ |
290 | 290 |
* Revision 1.6 2003/09/28 16:37:23 nigelhorne |
291 | 291 |
* Added -f flag use MaxThreads if --max-children not set |
292 | 292 |
*/ |
293 |
-static char const rcsid[] = "$Id: clamav-milter.c,v 1.93 2004/06/08 21:44:59 nigelhorne Exp $"; |
|
293 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.94 2004/06/13 02:11:25 kojm Exp $"; |
|
294 | 294 |
|
295 | 295 |
#define CM_VERSION "0.72a" |
296 | 296 |
|
... | ... |
@@ -820,7 +823,7 @@ main(int argc, char **argv) |
820 | 820 |
/* |
821 | 821 |
* Sanity checks on the clamav configuration file |
822 | 822 |
*/ |
823 |
- if((copt = parsecfg(cfgfile)) == NULL) { |
|
823 |
+ if((copt = parsecfg(cfgfile, 1)) == NULL) { |
|
824 | 824 |
fprintf(stderr, "%s: Can't parse the config file %s\n", |
825 | 825 |
argv[0], cfgfile); |
826 | 826 |
return EX_CONFIG; |
... | ... |
@@ -53,6 +53,7 @@ |
53 | 53 |
#include "memory.h" |
54 | 54 |
#include "output.h" |
55 | 55 |
#include "shared.h" |
56 |
+#include "target.h" |
|
56 | 57 |
|
57 | 58 |
void help(void); |
58 | 59 |
void daemonize(void); |
... | ... |
@@ -102,7 +103,7 @@ void clamd(struct optstruct *opt) |
102 | 102 |
else |
103 | 103 |
cfgfile = CL_DEFAULT_CFG; |
104 | 104 |
|
105 |
- if((copt = parsecfg(cfgfile)) == NULL) { |
|
105 |
+ if((copt = parsecfg(cfgfile, 1)) == NULL) { |
|
106 | 106 |
fprintf(stderr, "ERROR: Can't open/parse the config file %s\n", cfgfile); |
107 | 107 |
exit(1); |
108 | 108 |
} |
... | ... |
@@ -165,6 +166,8 @@ void clamd(struct optstruct *opt) |
165 | 165 |
} |
166 | 166 |
#endif |
167 | 167 |
|
168 |
+ logg("clamd daemon "VERSION" (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n"); |
|
169 |
+ |
|
168 | 170 |
if(logg_size) |
169 | 171 |
logg("Log file size limited to %d bytes.\n", logg_size); |
170 | 172 |
else |
... | ... |
@@ -59,8 +59,8 @@ int client(const struct optstruct *opt) |
59 | 59 |
if(!clamav_conf) |
60 | 60 |
clamav_conf = DEFAULT_CFG; |
61 | 61 |
|
62 |
- if((copt = parsecfg(clamav_conf)) == NULL) { |
|
63 |
- mprintf("@Can't parse configuration file.\n"); |
|
62 |
+ if((copt = parsecfg(clamav_conf, 1)) == NULL) { |
|
63 |
+ mprintf("@Can't parse the configuration file.\n"); |
|
64 | 64 |
return 2; |
65 | 65 |
} |
66 | 66 |
|
... | ... |
@@ -113,7 +113,7 @@ int scanmanager(const struct optstruct *opt) |
113 | 113 |
} else { |
114 | 114 |
/* try to find fresh directory */ |
115 | 115 |
dbdir = cl_retdbdir(); |
116 |
- if((copt = parsecfg(CONFDIR"/clamav.conf"))) { |
|
116 |
+ if((copt = parsecfg(CONFDIR"/clamav.conf", 0))) { |
|
117 | 117 |
if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) { |
118 | 118 |
if(strcmp(cl_retdbdir(), cpt->strarg)) { |
119 | 119 |
char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(cl_retdbdir()) + 15); |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
#include "defaults.h" |
44 | 44 |
#include "freshclam.h" |
45 | 45 |
#include "output.h" |
46 |
+#include "target.h" |
|
46 | 47 |
|
47 | 48 |
static short terminate = 0; |
48 | 49 |
|
... | ... |
@@ -108,11 +109,11 @@ int freshclam(struct optstruct *opt) |
108 | 108 |
|
109 | 109 |
/* parse the config file */ |
110 | 110 |
if((cfgfile = getargl(opt, "config-file"))) { |
111 |
- copt = parsecfg(cfgfile); |
|
111 |
+ copt = parsecfg(cfgfile, 1); |
|
112 | 112 |
} else { |
113 | 113 |
/* TODO: force strict permissions on freshclam.conf */ |
114 |
- if((copt = parsecfg((cfgfile = CONFDIR"/freshclam.conf"))) == NULL) |
|
115 |
- copt = parsecfg((cfgfile = CONFDIR"/clamav.conf")); |
|
114 |
+ if((copt = parsecfg((cfgfile = CONFDIR"/freshclam.conf"), 1)) == NULL) |
|
115 |
+ copt = parsecfg((cfgfile = CONFDIR"/clamav.conf"), 1); |
|
116 | 116 |
} |
117 | 117 |
|
118 | 118 |
if(!copt) { |
... | ... |
@@ -274,11 +275,13 @@ int freshclam(struct optstruct *opt) |
274 | 274 |
if (pidfile) { |
275 | 275 |
writepid(pidfile); |
276 | 276 |
} |
277 |
- logg("freshclam daemon started (pid=%d)\n", getpid()); |
|
277 |
+ |
|
278 |
+ logg("freshclam daemon "VERSION" (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n"); |
|
278 | 279 |
|
279 | 280 |
sigaction(SIGTERM, &sigact, NULL); |
280 | 281 |
sigaction(SIGHUP, &sigact, NULL); |
281 | 282 |
sigaction(SIGINT, &sigact, NULL); |
283 |
+ |
|
282 | 284 |
while(!terminate) { |
283 | 285 |
ret = download(copt, opt); |
284 | 286 |
|
... | ... |
@@ -46,7 +46,7 @@ int notify(const char *cfgfile) |
46 | 46 |
char *socktype; |
47 | 47 |
|
48 | 48 |
|
49 |
- if((copt = parsecfg(cfgfile)) == NULL) { |
|
49 |
+ if((copt = parsecfg(cfgfile, 1)) == NULL) { |
|
50 | 50 |
mprintf("@Clamd was NOT notified: Can't find or parse configuration file %s\n", cfgfile); |
51 | 51 |
return 1; |
52 | 52 |
} |
... | ... |
@@ -42,7 +42,7 @@ static int isnumb(const char *str) |
42 | 42 |
return 1; |
43 | 43 |
} |
44 | 44 |
|
45 |
-struct cfgstruct *parsecfg(const char *cfgfile) |
|
45 |
+struct cfgstruct *parsecfg(const char *cfgfile, int messages) |
|
46 | 46 |
{ |
47 | 47 |
char buff[LINE_LENGTH], *name, *arg; |
48 | 48 |
FILE *fs; |
... | ... |
@@ -131,7 +131,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
131 | 131 |
continue; |
132 | 132 |
|
133 | 133 |
if(!strncmp("Example", buff, 7)) { |
134 |
- fprintf(stderr, "ERROR: Please edit the example config file %s.\n", cfgfile); |
|
134 |
+ if(messages) |
|
135 |
+ fprintf(stderr, "ERROR: Please edit the example config file %s.\n", cfgfile); |
|
135 | 136 |
return NULL; |
136 | 137 |
} |
137 | 138 |
|
... | ... |
@@ -147,14 +148,16 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
147 | 147 |
switch(pt->argtype) { |
148 | 148 |
case OPT_STR: |
149 | 149 |
if(!arg) { |
150 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires string as argument.\n", line, name); |
|
150 |
+ if(messages) |
|
151 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires string as argument.\n", line, name); |
|
151 | 152 |
return NULL; |
152 | 153 |
} |
153 | 154 |
copt = regcfg(copt, name, arg, 0); |
154 | 155 |
break; |
155 | 156 |
case OPT_FULLSTR: |
156 | 157 |
if(!arg) { |
157 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires string as argument.\n", line, name); |
|
158 |
+ if(messages) |
|
159 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires string as argument.\n", line, name); |
|
158 | 160 |
return NULL; |
159 | 161 |
} |
160 | 162 |
/* FIXME: this one is an ugly hack of the above case */ |
... | ... |
@@ -165,7 +168,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
165 | 165 |
break; |
166 | 166 |
case OPT_NUM: |
167 | 167 |
if(!arg || !isnumb(arg)) { |
168 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical argument.\n", line, name); |
|
168 |
+ if(messages) |
|
169 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical argument.\n", line, name); |
|
169 | 170 |
return NULL; |
170 | 171 |
} |
171 | 172 |
copt = regcfg(copt, name, NULL, atoi(arg)); |
... | ... |
@@ -173,7 +177,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
173 | 173 |
break; |
174 | 174 |
case OPT_COMPSIZE: |
175 | 175 |
if(!arg) { |
176 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires argument.\n", line, name); |
|
176 |
+ if(messages) |
|
177 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires argument.\n", line, name); |
|
177 | 178 |
return NULL; |
178 | 179 |
} |
179 | 180 |
ctype = tolower(arg[strlen(arg) - 1]); |
... | ... |
@@ -181,7 +186,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
181 | 181 |
char *cpy = (char *) mcalloc(strlen(arg), sizeof(char)); |
182 | 182 |
strncpy(cpy, arg, strlen(arg) - 1); |
183 | 183 |
if(!isnumb(cpy)) { |
184 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical (raw/K/M) argument.\n", line, name); |
|
184 |
+ if(messages) |
|
185 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical (raw/K/M) argument.\n", line, name); |
|
185 | 186 |
return NULL; |
186 | 187 |
} |
187 | 188 |
if(ctype == 'm') |
... | ... |
@@ -191,7 +197,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
191 | 191 |
free(cpy); |
192 | 192 |
} else { |
193 | 193 |
if(!isnumb(arg)) { |
194 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical (raw/K/M) argument.\n", line, name); |
|
194 |
+ if(messages) |
|
195 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical (raw/K/M) argument.\n", line, name); |
|
195 | 196 |
return NULL; |
196 | 197 |
} |
197 | 198 |
calc = atoi(arg); |
... | ... |
@@ -201,7 +208,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
201 | 201 |
break; |
202 | 202 |
case OPT_NOARG: |
203 | 203 |
if(arg) { |
204 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s doesn't support arguments (got '%s').\n", line, name, arg); |
|
204 |
+ if(messages) |
|
205 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s doesn't support arguments (got '%s').\n", line, name, arg); |
|
205 | 206 |
return NULL; |
206 | 207 |
} |
207 | 208 |
copt = regcfg(copt, name, NULL, 0); |
... | ... |
@@ -210,7 +218,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
210 | 210 |
copt = regcfg(copt, name, arg, 0); |
211 | 211 |
break; |
212 | 212 |
default: |
213 |
- fprintf(stderr, "ERROR: Parse error at line %d: Option %s is of unknown type %d\n", line, name, pt->argtype); |
|
213 |
+ if(messages) |
|
214 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Option %s is of unknown type %d\n", line, name, pt->argtype); |
|
214 | 215 |
free(name); |
215 | 216 |
free(arg); |
216 | 217 |
break; |
... | ... |
@@ -221,7 +230,8 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
221 | 221 |
} |
222 | 222 |
|
223 | 223 |
if(!found) { |
224 |
- fprintf(stderr, "ERROR: Parse error at line %d: Unknown option %s.\n", line, name); |
|
224 |
+ if(messages) |
|
225 |
+ fprintf(stderr, "ERROR: Parse error at line %d: Unknown option %s.\n", line, name); |
|
225 | 226 |
return NULL; |
226 | 227 |
} |
227 | 228 |
} |
... | ... |
@@ -486,7 +486,7 @@ const char *getdbdir(void) |
486 | 486 |
|
487 | 487 |
|
488 | 488 |
dbdir = cl_retdbdir(); |
489 |
- if((copt = parsecfg(CONFDIR"/clamav.conf"))) { |
|
489 |
+ if((copt = parsecfg(CONFDIR"/clamav.conf", 0))) { |
|
490 | 490 |
if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) { |
491 | 491 |
if(strcmp(cl_retdbdir(), cpt->strarg)) { |
492 | 492 |
char *daily = (char *) mmalloc(strlen(cpt->strarg) + strlen(cl_retdbdir()) + 15); |