git-svn: trunk@1606
Tomasz Kojm authored on 2005/06/07 10:40:08... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Tue Jun 7 03:34:25 CEST 2005 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * Simplify output handling in all programs: move most of the logic of how |
|
4 |
+ to handle output into the logg() function, and change all of the programs |
|
5 |
+ to use logg(). Patch by Stephen Gran <steve*lobefin.net> |
|
6 |
+ |
|
1 | 7 |
Sun Jun 5 06:58:45 BST 2005 (njh) |
2 | 8 |
---------------------------------- |
3 | 9 |
* clamav-milter: Better error message if the white-list file can't be |
... | ... |
@@ -60,6 +60,8 @@ void daemonize(void); |
60 | 60 |
|
61 | 61 |
short debug_mode = 0, logok = 0; |
62 | 62 |
|
63 |
+short foreground = 0; |
|
64 |
+ |
|
63 | 65 |
void clamd(struct optstruct *opt) |
64 | 66 |
{ |
65 | 67 |
struct cfgstruct *copt, *cpt; |
... | ... |
@@ -109,6 +111,49 @@ void clamd(struct optstruct *opt) |
109 | 109 |
|
110 | 110 |
umask(0); |
111 | 111 |
|
112 |
+ /* drop privileges */ |
|
113 |
+#ifndef C_OS2 |
|
114 |
+ if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))->enabled) { |
|
115 |
+ if((user = getpwnam(cpt->strarg)) == NULL) { |
|
116 |
+ fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg); |
|
117 |
+ logg("!Can't get information about user %s.\n", cpt->strarg); |
|
118 |
+ exit(1); |
|
119 |
+ } |
|
120 |
+ |
|
121 |
+ if(cfgopt(copt, "AllowSupplementaryGroups")->enabled) { |
|
122 |
+#ifdef HAVE_INITGROUPS |
|
123 |
+ if(initgroups(cpt->strarg, user->pw_gid)) { |
|
124 |
+ fprintf(stderr, "ERROR: initgroups() failed.\n"); |
|
125 |
+ logg("!initgroups() failed.\n"); |
|
126 |
+ exit(1); |
|
127 |
+ } |
|
128 |
+#else |
|
129 |
+ logg("AllowSupplementaryGroups: initgroups() not supported.\n"); |
|
130 |
+#endif |
|
131 |
+ } else { |
|
132 |
+#ifdef HAVE_SETGROUPS |
|
133 |
+ if(setgroups(1, &user->pw_gid)) { |
|
134 |
+ fprintf(stderr, "ERROR: setgroups() failed.\n"); |
|
135 |
+ logg("!setgroups() failed.\n"); |
|
136 |
+ exit(1); |
|
137 |
+ } |
|
138 |
+#endif |
|
139 |
+ } |
|
140 |
+ |
|
141 |
+ if(setgid(user->pw_gid)) { |
|
142 |
+ fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); |
|
143 |
+ logg("!setgid(%d) failed.\n", (int) user->pw_gid); |
|
144 |
+ exit(1); |
|
145 |
+ } |
|
146 |
+ |
|
147 |
+ if(setuid(user->pw_uid)) { |
|
148 |
+ fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid); |
|
149 |
+ logg("!setuid(%d) failed.\n", (int) user->pw_uid); |
|
150 |
+ exit(1); |
|
151 |
+ } |
|
152 |
+ } |
|
153 |
+#endif |
|
154 |
+ |
|
112 | 155 |
/* initialize logger */ |
113 | 156 |
|
114 | 157 |
logg_lock = cfgopt(copt, "LogFileUnlock")->enabled; |
... | ... |
@@ -146,7 +191,6 @@ void clamd(struct optstruct *opt) |
146 | 146 |
|
147 | 147 |
openlog("clamd", LOG_PID, fac); |
148 | 148 |
logg_syslog = 1; |
149 |
- syslog(LOG_INFO, "Daemon started.\n"); |
|
150 | 149 |
} |
151 | 150 |
#endif |
152 | 151 |
|
... | ... |
@@ -181,51 +225,6 @@ void clamd(struct optstruct *opt) |
181 | 181 |
exit(1); |
182 | 182 |
} |
183 | 183 |
|
184 |
- /* drop privileges */ |
|
185 |
-#ifndef C_OS2 |
|
186 |
- if(geteuid() == 0 && (cpt = cfgopt(copt, "User"))->enabled) { |
|
187 |
- if((user = getpwnam(cpt->strarg)) == NULL) { |
|
188 |
- fprintf(stderr, "ERROR: Can't get information about user %s.\n", cpt->strarg); |
|
189 |
- logg("!Can't get information about user %s.\n", cpt->strarg); |
|
190 |
- exit(1); |
|
191 |
- } |
|
192 |
- |
|
193 |
- if(cfgopt(copt, "AllowSupplementaryGroups")->enabled) { |
|
194 |
-#ifdef HAVE_INITGROUPS |
|
195 |
- if(initgroups(cpt->strarg, user->pw_gid)) { |
|
196 |
- fprintf(stderr, "ERROR: initgroups() failed.\n"); |
|
197 |
- logg("!initgroups() failed.\n"); |
|
198 |
- exit(1); |
|
199 |
- } |
|
200 |
-#else |
|
201 |
- logg("AllowSupplementaryGroups: initgroups() not supported.\n"); |
|
202 |
-#endif |
|
203 |
- } else { |
|
204 |
-#ifdef HAVE_SETGROUPS |
|
205 |
- if(setgroups(1, &user->pw_gid)) { |
|
206 |
- fprintf(stderr, "ERROR: setgroups() failed.\n"); |
|
207 |
- logg("!setgroups() failed.\n"); |
|
208 |
- exit(1); |
|
209 |
- } |
|
210 |
-#endif |
|
211 |
- } |
|
212 |
- |
|
213 |
- if(setgid(user->pw_gid)) { |
|
214 |
- fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid); |
|
215 |
- logg("!setgid(%d) failed.\n", (int) user->pw_gid); |
|
216 |
- exit(1); |
|
217 |
- } |
|
218 |
- |
|
219 |
- if(setuid(user->pw_uid)) { |
|
220 |
- fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid); |
|
221 |
- logg("!setuid(%d) failed.\n", (int) user->pw_uid); |
|
222 |
- exit(1); |
|
223 |
- } |
|
224 |
- |
|
225 |
- logg("Running as user %s (UID %d, GID %d)\n", cpt->strarg, user->pw_uid, user->pw_gid); |
|
226 |
- } |
|
227 |
-#endif |
|
228 |
- |
|
229 | 184 |
/* set the temporary dir */ |
230 | 185 |
if((cpt = cfgopt(copt, "TemporaryDirectory"))->enabled) |
231 | 186 |
cl_settempdir(cpt->strarg, 0); |
... | ... |
@@ -256,9 +255,13 @@ void clamd(struct optstruct *opt) |
256 | 256 |
exit(1); |
257 | 257 |
} |
258 | 258 |
|
259 |
+ |
|
260 |
+ logg("Running as user %s (UID %d, GID %d)\n", cpt->strarg, user->pw_uid, user->pw_gid); |
|
259 | 261 |
/* fork into background */ |
260 | 262 |
if(!cfgopt(copt, "Foreground")->enabled) |
261 | 263 |
daemonize(); |
264 |
+ else |
|
265 |
+ foreground = 1; |
|
262 | 266 |
|
263 | 267 |
if(tcpsock) |
264 | 268 |
ret = tcpserver(opt, copt, root); |
... | ... |
@@ -421,7 +421,7 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop |
421 | 421 |
* We need to allow for that. |
422 | 422 |
*/ |
423 | 423 |
pthread_attr_getstacksize(&thattr, &stacksize); |
424 |
- cli_dbgmsg("set stacksize to %u\n", stacksize + SCANBUFF + 64 * 1024); |
|
424 |
+ logg("*set stacksize to %u\n", stacksize + SCANBUFF + 64 * 1024); |
|
425 | 425 |
pthread_attr_setstacksize(&thattr, stacksize + SCANBUFF + 64 * 1024); |
426 | 426 |
#endif |
427 | 427 |
|
... | ... |
@@ -42,6 +42,7 @@ short printinfected = 0; |
42 | 42 |
|
43 | 43 |
extern int notremoved, notmoved; |
44 | 44 |
|
45 |
+ |
|
45 | 46 |
void clamscan(struct optstruct *opt) |
46 | 47 |
{ |
47 | 48 |
int ds, dms, ret, infected; |
... | ... |
@@ -103,20 +104,15 @@ void clamscan(struct optstruct *opt) |
103 | 103 |
dms = t2.tv_usec - t1.tv_usec; |
104 | 104 |
ds -= (dms < 0) ? (1):(0); |
105 | 105 |
dms += (dms < 0) ? (1000000):(0); |
106 |
- mprintf("\n----------- SCAN SUMMARY -----------\n"); |
|
107 |
- logg("\n-- summary --\n"); |
|
108 |
- mprintf("Infected files: %d\n", infected); |
|
109 |
- logg("Infected files: %d\n", infected); |
|
106 |
+ logg("\n----------- SCAN SUMMARY -----------\n"); |
|
107 |
+ logg("Infected files: %d\n", infected); |
|
110 | 108 |
if(notremoved) { |
111 |
- mprintf("Not removed: %d\n", notremoved); |
|
112 |
- logg("Not removed: %d\n", notremoved); |
|
109 |
+ logg("Not removed: %d\n", notremoved); |
|
113 | 110 |
} |
114 | 111 |
if(notmoved) { |
115 |
- mprintf("Not moved: %d\n", notmoved); |
|
116 |
- logg("Not moved: %d\n", notmoved); |
|
112 |
+ logg("Not moved: %d\n", notmoved); |
|
117 | 113 |
} |
118 |
- mprintf("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
119 |
- logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
114 |
+ logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
120 | 115 |
} |
121 | 116 |
|
122 | 117 |
exit(ret); |
... | ... |
@@ -71,7 +71,7 @@ int dsresult(int sockd, const struct optstruct *opt) |
71 | 71 |
#else /* FIXME: accoriding to YD OS/2 does not support dup() for sockets */ |
72 | 72 |
if((fd = fdopen(sockd, "r")) == NULL) { |
73 | 73 |
#endif |
74 |
- mprintf("@Can't open descriptor for reading.\n"); |
|
74 |
+ logg("^Can't open descriptor for reading.\n"); |
|
75 | 75 |
return -1; |
76 | 76 |
} |
77 | 77 |
|
... | ... |
@@ -79,7 +79,6 @@ int dsresult(int sockd, const struct optstruct *opt) |
79 | 79 |
if(strstr(buff, "FOUND\n")) { |
80 | 80 |
infected++; |
81 | 81 |
logg("%s", buff); |
82 |
- mprintf("%s", buff); |
|
83 | 82 |
if(optl(opt, "move")) { |
84 | 83 |
pt = strrchr(buff, ':'); |
85 | 84 |
*pt = 0; |
... | ... |
@@ -89,11 +88,9 @@ int dsresult(int sockd, const struct optstruct *opt) |
89 | 89 |
pt = strrchr(buff, ':'); |
90 | 90 |
*pt = 0; |
91 | 91 |
if(unlink(buff)) { |
92 |
- mprintf("%s: Can't remove.\n", buff); |
|
93 | 92 |
logg("%s: Can't remove.\n", buff); |
94 | 93 |
notremoved++; |
95 | 94 |
} else { |
96 |
- mprintf("%s: Removed.\n", buff); |
|
97 | 95 |
logg("%s: Removed.\n", buff); |
98 | 96 |
} |
99 | 97 |
} |
... | ... |
@@ -101,7 +98,6 @@ int dsresult(int sockd, const struct optstruct *opt) |
101 | 101 |
|
102 | 102 |
if(strstr(buff, "ERROR\n")) { |
103 | 103 |
logg("%s", buff); |
104 |
- mprintf("%s", buff); |
|
105 | 104 |
waserror = 1; |
106 | 105 |
} |
107 | 106 |
} |
... | ... |
@@ -123,7 +119,7 @@ int dsfile(int sockd, const char *filename, const struct optstruct *opt) |
123 | 123 |
sprintf(scancmd, "CONTSCAN %s", filename); |
124 | 124 |
|
125 | 125 |
if(write(sockd, scancmd, strlen(scancmd)) <= 0) { |
126 |
- mprintf("@Can't write to the socket.\n"); |
|
126 |
+ logg("^Can't write to the socket.\n"); |
|
127 | 127 |
free(scancmd); |
128 | 128 |
return -1; |
129 | 129 |
} |
... | ... |
@@ -133,7 +129,7 @@ int dsfile(int sockd, const char *filename, const struct optstruct *opt) |
133 | 133 |
ret = dsresult(sockd, opt); |
134 | 134 |
|
135 | 135 |
if(!ret) |
136 |
- mprintf("%s: OK\n", filename); |
|
136 |
+ logg("%s: OK\n", filename); |
|
137 | 137 |
|
138 | 138 |
return ret; |
139 | 139 |
} |
... | ... |
@@ -175,7 +171,7 @@ int dsfd(int sockfd, int fd, const struct optstruct *opt) |
175 | 175 |
msg.msg_accrightslen = sizeof(fd); |
176 | 176 |
#endif |
177 | 177 |
if (sendmsg(sockfd, &msg, 0) != iov[0].iov_len) { |
178 |
- mprintf("@Can't write to the socket.\n"); |
|
178 |
+ logg("^Can't write to the socket.\n"); |
|
179 | 179 |
return -1; |
180 | 180 |
} |
181 | 181 |
return dsresult(sockfd, opt); |
... | ... |
@@ -197,7 +193,7 @@ int dsstream(int sockd, const struct optstruct *opt) |
197 | 197 |
|
198 | 198 |
|
199 | 199 |
if(write(sockd, "STREAM", 6) <= 0) { |
200 |
- mprintf("@Can't write to the socket.\n"); |
|
200 |
+ logg("^Can't write to the socket.\n"); |
|
201 | 201 |
return 2; |
202 | 202 |
} |
203 | 203 |
|
... | ... |
@@ -213,7 +209,7 @@ int dsstream(int sockd, const struct optstruct *opt) |
213 | 213 |
} |
214 | 214 |
|
215 | 215 |
if(!loopw) { |
216 |
- mprintf("@Daemon not ready for stream scanning.\n"); |
|
216 |
+ logg("^Daemon not ready for stream scanning.\n"); |
|
217 | 217 |
return -1; |
218 | 218 |
} |
219 | 219 |
|
... | ... |
@@ -221,7 +217,7 @@ int dsstream(int sockd, const struct optstruct *opt) |
221 | 221 |
|
222 | 222 |
if((wsockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) { |
223 | 223 |
perror("socket()"); |
224 |
- mprintf("@Can't create the socket.\n"); |
|
224 |
+ logg("^Can't create the socket.\n"); |
|
225 | 225 |
return -1; |
226 | 226 |
} |
227 | 227 |
|
... | ... |
@@ -231,7 +227,7 @@ int dsstream(int sockd, const struct optstruct *opt) |
231 | 231 |
peer_size = sizeof(peer); |
232 | 232 |
if(getpeername(sockd, (struct sockaddr *) &peer, &peer_size) < 0) { |
233 | 233 |
perror("getpeername()"); |
234 |
- mprintf("@Can't get socket peer name.\n"); |
|
234 |
+ logg("^Can't get socket peer name.\n"); |
|
235 | 235 |
return -1; |
236 | 236 |
} |
237 | 237 |
|
... | ... |
@@ -243,20 +239,20 @@ int dsstream(int sockd, const struct optstruct *opt) |
243 | 243 |
server.sin_addr.s_addr = peer.sin_addr.s_addr; |
244 | 244 |
break; |
245 | 245 |
default: |
246 |
- mprintf("@Unexpected socket type: %d.\n", peer.sin_family); |
|
246 |
+ mprintf("^Unexpected socket type: %d.\n", peer.sin_family); |
|
247 | 247 |
return -1; |
248 | 248 |
} |
249 | 249 |
|
250 | 250 |
if(connect(wsockd, (struct sockaddr *) &server, sizeof(struct sockaddr_in)) < 0) { |
251 | 251 |
close(wsockd); |
252 | 252 |
perror("connect()"); |
253 |
- mprintf("@Can't connect to clamd [port: %d].\n", port); |
|
253 |
+ logg("^Can't connect to clamd [port: %d].\n", port); |
|
254 | 254 |
return -1; |
255 | 255 |
} |
256 | 256 |
|
257 | 257 |
while((bread = read(0, buff, sizeof(buff))) > 0) { |
258 | 258 |
if(write(wsockd, buff, bread) <= 0) { |
259 |
- mprintf("@Can't write to the socket.\n"); |
|
259 |
+ logg("^Can't write to the socket.\n"); |
|
260 | 260 |
close(wsockd); |
261 | 261 |
return -1; |
262 | 262 |
} |
... | ... |
@@ -265,10 +261,9 @@ int dsstream(int sockd, const struct optstruct *opt) |
265 | 265 |
|
266 | 266 |
memset(buff, 0, sizeof(buff)); |
267 | 267 |
while((bread = read(sockd, buff, sizeof(buff))) > 0) { |
268 |
- mprintf("%s", buff); |
|
268 |
+ logg("%s", buff); |
|
269 | 269 |
if(strstr(buff, "FOUND\n")) { |
270 | 270 |
infected++; |
271 |
- logg("%s", buff); |
|
272 | 271 |
|
273 | 272 |
} else if(strstr(buff, "ERROR\n")) { |
274 | 273 |
logg("%s", buff); |
... | ... |
@@ -286,7 +281,7 @@ char *abpath(const char *filename) |
286 | 286 |
char *fullpath, cwd[200]; |
287 | 287 |
|
288 | 288 |
if(stat(filename, &foo) == -1) { |
289 |
- mprintf("@Can't access file %s\n", filename); |
|
289 |
+ logg("^Can't access file %s\n", filename); |
|
290 | 290 |
perror(filename); |
291 | 291 |
return NULL; |
292 | 292 |
} else { |
... | ... |
@@ -295,7 +290,7 @@ char *abpath(const char *filename) |
295 | 295 |
sprintf(fullpath, "%s", filename); |
296 | 296 |
#else |
297 | 297 |
if(!getcwd(cwd, 200)) { |
298 |
- mprintf("@Can't get absolute pathname of current working directory.\n"); |
|
298 |
+ logg("^Can't get absolute pathname of current working directory.\n"); |
|
299 | 299 |
return NULL; |
300 | 300 |
} |
301 | 301 |
sprintf(fullpath, "%s/%s", cwd, filename); |
... | ... |
@@ -319,7 +314,7 @@ int dconnect(const struct optstruct *opt) |
319 | 319 |
clamav_conf = DEFAULT_CFG; |
320 | 320 |
|
321 | 321 |
if((copt = getcfg(clamav_conf, 1)) == NULL) { |
322 |
- mprintf("@Can't parse the configuration file.\n"); |
|
322 |
+ logg("^Can't parse the configuration file.\n"); |
|
323 | 323 |
return -1; |
324 | 324 |
} |
325 | 325 |
|
... | ... |
@@ -330,7 +325,7 @@ int dconnect(const struct optstruct *opt) |
330 | 330 |
server2.sin_addr.s_addr = inet_addr("127.0.0.1"); |
331 | 331 |
|
332 | 332 |
if(cfgopt(copt, "TCPSocket")->enabled && cfgopt(copt, "LocalSocket")->enabled) { |
333 |
- mprintf("@Clamd is not configured properly.\n"); |
|
333 |
+ logg("^Clamd is not configured properly.\n"); |
|
334 | 334 |
return -1; |
335 | 335 |
} else if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { |
336 | 336 |
|
... | ... |
@@ -339,14 +334,14 @@ int dconnect(const struct optstruct *opt) |
339 | 339 |
|
340 | 340 |
if((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
341 | 341 |
perror("socket()"); |
342 |
- mprintf("@Can't create the socket.\n"); |
|
342 |
+ logg("^Can't create the socket.\n"); |
|
343 | 343 |
return -1; |
344 | 344 |
} |
345 | 345 |
|
346 | 346 |
if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { |
347 | 347 |
close(sockd); |
348 | 348 |
perror("connect()"); |
349 |
- mprintf("@Can't connect to clamd.\n"); |
|
349 |
+ logg("^Can't connect to clamd.\n"); |
|
350 | 350 |
return -1; |
351 | 351 |
} |
352 | 352 |
|
... | ... |
@@ -354,7 +349,7 @@ int dconnect(const struct optstruct *opt) |
354 | 354 |
|
355 | 355 |
if((sockd = socket(SOCKET_INET, SOCK_STREAM, 0)) < 0) { |
356 | 356 |
perror("socket()"); |
357 |
- mprintf("@Can't create the socket.\n"); |
|
357 |
+ logg("^Can't create the socket.\n"); |
|
358 | 358 |
return -1; |
359 | 359 |
} |
360 | 360 |
|
... | ... |
@@ -365,7 +360,7 @@ int dconnect(const struct optstruct *opt) |
365 | 365 |
if ((he = gethostbyname(cpt->strarg)) == 0) { |
366 | 366 |
close(sockd); |
367 | 367 |
perror("gethostbyname()"); |
368 |
- mprintf("@Can't lookup clamd hostname.\n"); |
|
368 |
+ logg("^Can't lookup clamd hostname.\n"); |
|
369 | 369 |
return -1; |
370 | 370 |
} |
371 | 371 |
server2.sin_addr = *(struct in_addr *) he->h_addr_list[0]; |
... | ... |
@@ -374,12 +369,12 @@ int dconnect(const struct optstruct *opt) |
374 | 374 |
if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { |
375 | 375 |
close(sockd); |
376 | 376 |
perror("connect()"); |
377 |
- mprintf("@Can't connect to clamd.\n"); |
|
377 |
+ logg("^Can't connect to clamd.\n"); |
|
378 | 378 |
return -1; |
379 | 379 |
} |
380 | 380 |
|
381 | 381 |
} else { |
382 |
- mprintf("@Clamd is not configured properly.\n"); |
|
382 |
+ logg("^Clamd is not configured properly.\n"); |
|
383 | 383 |
return -1; |
384 | 384 |
} |
385 | 385 |
|
... | ... |
@@ -400,7 +395,7 @@ int client(const struct optstruct *opt, int *infected) |
400 | 400 |
if(opt->filename == NULL || strlen(opt->filename) == 0) { |
401 | 401 |
/* scan current directory */ |
402 | 402 |
if(!getcwd(cwd, 200)) { |
403 |
- mprintf("@Can't get absolute pathname of current working directory.\n"); |
|
403 |
+ logg("^Can't get absolute pathname of current working directory.\n"); |
|
404 | 404 |
return 2; |
405 | 405 |
} |
406 | 406 |
|
... | ... |
@@ -445,7 +440,7 @@ int client(const struct optstruct *opt, int *infected) |
445 | 445 |
fullpath = thefilename; |
446 | 446 |
|
447 | 447 |
if(stat(fullpath, &sb) == -1) { |
448 |
- mprintf("@Can't access file %s\n", fullpath); |
|
448 |
+ logg("^Can't access file %s\n", fullpath); |
|
449 | 449 |
perror(fullpath); |
450 | 450 |
errors++; |
451 | 451 |
} else { |
... | ... |
@@ -454,7 +449,7 @@ int client(const struct optstruct *opt, int *infected) |
454 | 454 |
free(thefilename); |
455 | 455 |
|
456 | 456 |
if(!fullpath) { |
457 |
- mprintf("@Can't determine absolute path.\n"); |
|
457 |
+ logg("^Can't determine absolute path.\n"); |
|
458 | 458 |
return 2; |
459 | 459 |
} |
460 | 460 |
} |
... | ... |
@@ -474,7 +469,7 @@ int client(const struct optstruct *opt, int *infected) |
474 | 474 |
break; |
475 | 475 |
|
476 | 476 |
default: |
477 |
- mprintf("@Not supported file type (%s)\n", fullpath); |
|
477 |
+ logg("^Not supported file type (%s)\n", fullpath); |
|
478 | 478 |
errors++; |
479 | 479 |
} |
480 | 480 |
} |
... | ... |
@@ -496,20 +491,20 @@ void move_infected(const char *filename, const struct optstruct *opt) |
496 | 496 |
|
497 | 497 |
if(!(movedir = getargl(opt, "move"))) { |
498 | 498 |
/* Should never reach here */ |
499 |
- mprintf("@getargc() returned NULL\n", filename); |
|
499 |
+ logg("^getargc() returned NULL\n"); |
|
500 | 500 |
notmoved++; |
501 | 501 |
return; |
502 | 502 |
} |
503 | 503 |
|
504 | 504 |
if(access(movedir, W_OK|X_OK) == -1) { |
505 |
- mprintf("@error moving file '%s': cannot write to '%s': %s\n", filename, movedir, strerror(errno)); |
|
505 |
+ logg("^error moving file '%s': cannot write to '%s': %s\n", filename, movedir, strerror(errno)); |
|
506 | 506 |
notmoved++; |
507 | 507 |
return; |
508 | 508 |
} |
509 | 509 |
|
510 | 510 |
if(stat(filename, &fstat) == -1) { |
511 |
- mprintf("@Can't stat file %s\n", filename); |
|
512 |
- mprintf("Try to run clamdscan with clamd privileges\n"); |
|
511 |
+ logg("^Can't stat file %s\n", filename); |
|
512 |
+ logg("Try to run clamdscan with clamd privileges\n"); |
|
513 | 513 |
notmoved++; |
514 | 514 |
return; |
515 | 515 |
} |
... | ... |
@@ -520,12 +515,12 @@ void move_infected(const char *filename, const struct optstruct *opt) |
520 | 520 |
movefilename_size = sizeof(char) * (strlen(movedir) + strlen(tmp) + sizeof(numext) + 2); |
521 | 521 |
|
522 | 522 |
if(!(movefilename = mmalloc(movefilename_size))) { |
523 |
- mprintf("@Memory allocation error\n"); |
|
523 |
+ logg("^Memory allocation error\n"); |
|
524 | 524 |
exit(2); |
525 | 525 |
} |
526 | 526 |
|
527 | 527 |
if(!(strrcpy(movefilename, movedir))) { |
528 |
- mprintf("@strrcpy() returned NULL\n"); |
|
528 |
+ logg("^strrcpy() returned NULL\n"); |
|
529 | 529 |
notmoved++; |
530 | 530 |
free(movefilename); |
531 | 531 |
return; |
... | ... |
@@ -534,7 +529,7 @@ void move_infected(const char *filename, const struct optstruct *opt) |
534 | 534 |
strcat(movefilename, "/"); |
535 | 535 |
|
536 | 536 |
if(!(strcat(movefilename, tmp))) { |
537 |
- mprintf("@strcat() returned NULL\n"); |
|
537 |
+ logg("^strcat() returned NULL\n"); |
|
538 | 538 |
notmoved++; |
539 | 539 |
free(movefilename); |
540 | 540 |
return; |
... | ... |
@@ -542,7 +537,6 @@ void move_infected(const char *filename, const struct optstruct *opt) |
542 | 542 |
|
543 | 543 |
if(!stat(movefilename, &mfstat)) { |
544 | 544 |
if(fstat.st_ino == mfstat.st_ino) { /* It's the same file*/ |
545 |
- mprintf("File excluded '%s'\n", filename); |
|
546 | 545 |
logg("File excluded '%s'\n", filename); |
547 | 546 |
notmoved++; |
548 | 547 |
free(movefilename); |
... | ... |
@@ -568,7 +562,7 @@ void move_infected(const char *filename, const struct optstruct *opt) |
568 | 568 |
|
569 | 569 |
if(rename(filename, movefilename) == -1) { |
570 | 570 |
if(filecopy(filename, movefilename) == -1) { |
571 |
- mprintf("@cannot move '%s' to '%s': %s\n", filename, movefilename, strerror(errno)); |
|
571 |
+ logg("^cannot move '%s' to '%s': %s\n", filename, movefilename, strerror(errno)); |
|
572 | 572 |
notmoved++; |
573 | 573 |
free(movefilename); |
574 | 574 |
return; |
... | ... |
@@ -582,14 +576,13 @@ void move_infected(const char *filename, const struct optstruct *opt) |
582 | 582 |
utime(movefilename, &ubuf); |
583 | 583 |
|
584 | 584 |
if(unlink(filename)) { |
585 |
- mprintf("@cannot unlink '%s': %s\n", filename, strerror(errno)); |
|
585 |
+ logg("^cannot unlink '%s': %s\n", filename, strerror(errno)); |
|
586 | 586 |
notremoved++; |
587 | 587 |
free(movefilename); |
588 | 588 |
return; |
589 | 589 |
} |
590 | 590 |
} |
591 | 591 |
|
592 |
- mprintf("%s: moved to '%s'\n", filename, movefilename); |
|
593 | 592 |
logg("%s: moved to '%s'\n", filename, movefilename); |
594 | 593 |
|
595 | 594 |
free(movefilename); |
... | ... |
@@ -52,7 +52,6 @@ int clamscan(struct optstruct *opt) |
52 | 52 |
double mb; |
53 | 53 |
struct timeval t1, t2; |
54 | 54 |
struct timezone tz; |
55 |
- time_t starttime; |
|
56 | 55 |
|
57 | 56 |
/* initialize some important variables */ |
58 | 57 |
|
... | ... |
@@ -121,27 +120,23 @@ int clamscan(struct optstruct *opt) |
121 | 121 |
if(optl(opt, "max-space")) |
122 | 122 |
if(!strchr(getargl(opt, "max-space"), 'M') && !strchr(getargl(opt, "max-space"), 'm')) |
123 | 123 |
if(!isnumb(getargl(opt, "max-space"))) { |
124 |
- mprintf("!--max-space requires natural number.\n"); |
|
124 |
+ logg("!--max-space requires natural number.\n"); |
|
125 | 125 |
return 40; |
126 | 126 |
} |
127 | 127 |
|
128 | 128 |
if(optl(opt, "max-files")) |
129 | 129 |
if(!isnumb(getargl(opt, "max-files"))) { |
130 |
- mprintf("!--max-files requires natural number.\n"); |
|
130 |
+ logg("!--max-files requires natural number.\n"); |
|
131 | 131 |
return 40; |
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
if(optl(opt, "max-recursion")) |
135 | 135 |
if(!isnumb(getargl(opt, "max-recursion"))) { |
136 |
- mprintf("!--max-recursion requires natural number.\n"); |
|
136 |
+ logg("!--max-recursion requires natural number.\n"); |
|
137 | 137 |
return 40; |
138 | 138 |
} |
139 | 139 |
|
140 | 140 |
|
141 |
- time(&starttime); |
|
142 |
- /* ctime() does \n, but I need it once more */ |
|
143 |
- logg("Scan started: %s\n", ctime(&starttime)); |
|
144 |
- |
|
145 | 141 |
memset(&claminfo, 0, sizeof(struct s_info)); |
146 | 142 |
|
147 | 143 |
gettimeofday(&t1, &tz); |
... | ... |
@@ -153,36 +148,26 @@ int clamscan(struct optstruct *opt) |
153 | 153 |
dms = t2.tv_usec - t1.tv_usec; |
154 | 154 |
ds -= (dms < 0) ? (1):(0); |
155 | 155 |
dms += (dms < 0) ? (1000000):(0); |
156 |
- mprintf("\n----------- SCAN SUMMARY -----------\n"); |
|
157 |
- logg("\n-- summary --\n"); |
|
158 |
- mprintf("Known viruses: %d\n", claminfo.signs); |
|
159 |
- logg("Known viruses: %d\n", claminfo.signs); |
|
160 |
- mprintf("Engine version: %s\n", cl_retver()); |
|
161 |
- logg("Engine version: %s\n", cl_retver()); |
|
162 |
- mprintf("Scanned directories: %d\n", claminfo.dirs); |
|
163 |
- logg("Scanned directories: %d\n", claminfo.dirs); |
|
164 |
- mprintf("Scanned files: %d\n", claminfo.files); |
|
165 |
- logg("Scanned files: %d\n", claminfo.files); |
|
166 |
- mprintf("Infected files: %d\n", claminfo.ifiles); |
|
167 |
- logg("Infected files: %d\n", claminfo.ifiles); |
|
156 |
+ logg("\n----------- SCAN SUMMARY -----------\n"); |
|
157 |
+ logg("Known viruses: %d\n", claminfo.signs); |
|
158 |
+ logg("Engine version: %s\n", cl_retver()); |
|
159 |
+ logg("Scanned directories: %d\n", claminfo.dirs); |
|
160 |
+ logg("Scanned files: %d\n", claminfo.files); |
|
161 |
+ logg("Infected files: %d\n", claminfo.ifiles); |
|
168 | 162 |
if(claminfo.notremoved) { |
169 |
- mprintf("Not removed: %d\n", claminfo.notremoved); |
|
170 |
- logg("Not removed: %d\n", claminfo.notremoved); |
|
163 |
+ logg("Not removed: %d\n", claminfo.notremoved); |
|
171 | 164 |
} |
172 | 165 |
if(claminfo.notmoved) { |
173 |
- mprintf("Not moved: %d\n", claminfo.notmoved); |
|
174 |
- logg("Not moved: %d\n", claminfo.notmoved); |
|
166 |
+ logg("Not moved: %d\n", claminfo.notmoved); |
|
175 | 167 |
} |
176 | 168 |
mb = claminfo.blocks * (CL_COUNT_PRECISION / 1024) / 1024.0; |
177 |
- mprintf("Data scanned: %2.2lf MB\n", mb); |
|
178 |
- logg("Data scanned: %2.2lf MB\n", mb); |
|
169 |
+ logg("Data scanned: %2.2lf MB\n", mb); |
|
179 | 170 |
/* |
180 | 171 |
mprintf("I/O buffer size: %d bytes\n", SCANBUFF); |
181 | 172 |
logg("I/O buffer size: %d bytes\n", SCANBUFF); |
182 | 173 |
*/ |
183 | 174 |
|
184 |
- mprintf("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
185 |
- logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
175 |
+ logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
|
186 | 176 |
} |
187 | 177 |
|
188 | 178 |
return ret; |
... | ... |
@@ -72,7 +72,7 @@ int scanmanager(const struct optstruct *opt) |
72 | 72 |
#if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS) |
73 | 73 |
if(!geteuid()) { |
74 | 74 |
if((user = getpwnam(UNPUSER)) == NULL) { |
75 |
- mprintf("@Can't get information about user "UNPUSER"\n"); |
|
75 |
+ logg("^Can't get information about user "UNPUSER"\n"); |
|
76 | 76 |
exit(60); /* this is critical problem, so we just exit here */ |
77 | 77 |
} |
78 | 78 |
} |
... | ... |
@@ -90,18 +90,18 @@ int scanmanager(const struct optstruct *opt) |
90 | 90 |
switch(sb.st_mode & S_IFMT) { |
91 | 91 |
case S_IFREG: |
92 | 92 |
if((ret = cl_loaddb(getargc(opt, 'd'), &trie, &claminfo.signs))) { |
93 |
- mprintf("@%s\n", cl_strerror(ret)); |
|
93 |
+ logg("^%s\n", cl_strerror(ret)); |
|
94 | 94 |
return 50; |
95 | 95 |
} |
96 | 96 |
break; |
97 | 97 |
case S_IFDIR: |
98 | 98 |
if((ret = cl_loaddbdir(getargc(opt, 'd'), &trie, &claminfo.signs))) { |
99 |
- mprintf("@%s\n", cl_strerror(ret)); |
|
99 |
+ logg("^%s\n", cl_strerror(ret)); |
|
100 | 100 |
return 50; |
101 | 101 |
} |
102 | 102 |
break; |
103 | 103 |
default: |
104 |
- mprintf("@%s: Not supported database file type\n", getargc(opt, 'd')); |
|
104 |
+ logg("^%s: Not supported database file type\n", getargc(opt, 'd')); |
|
105 | 105 |
return 50; |
106 | 106 |
} |
107 | 107 |
|
... | ... |
@@ -109,7 +109,7 @@ int scanmanager(const struct optstruct *opt) |
109 | 109 |
char *dbdir = freshdbdir(); |
110 | 110 |
|
111 | 111 |
if((ret = cl_loaddbdir(dbdir, &trie, &claminfo.signs))) { |
112 |
- mprintf("@%s\n", cl_strerror(ret)); |
|
112 |
+ logg("^%s\n", cl_strerror(ret)); |
|
113 | 113 |
free(dbdir); |
114 | 114 |
return 50; |
115 | 115 |
} |
... | ... |
@@ -118,12 +118,12 @@ int scanmanager(const struct optstruct *opt) |
118 | 118 |
} |
119 | 119 |
|
120 | 120 |
if(!trie) { |
121 |
- mprintf("@Can't initialize the virus database\n"); |
|
121 |
+ logg("^Can't initialize the virus database\n"); |
|
122 | 122 |
return 50; |
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
if((ret = cl_build(trie)) != 0) { |
126 |
- mprintf("@Database initialization error: %s\n", cl_strerror(ret));; |
|
126 |
+ logg("^Database initialization error: %s\n", cl_strerror(ret));; |
|
127 | 127 |
return 50; |
128 | 128 |
} |
129 | 129 |
|
... | ... |
@@ -210,7 +210,7 @@ int scanmanager(const struct optstruct *opt) |
210 | 210 |
|
211 | 211 |
/* we need full path for some reasons (eg. archive handling) */ |
212 | 212 |
if(!getcwd(cwd, sizeof(cwd))) { |
213 |
- mprintf("@Can't get absolute pathname of current working directory\n"); |
|
213 |
+ logg("^Can't get absolute pathname of current working directory\n"); |
|
214 | 214 |
ret = 57; |
215 | 215 |
} else |
216 | 216 |
ret = scandirs(cwd, trie, user, opt, limits, options); |
... | ... |
@@ -222,7 +222,7 @@ int scanmanager(const struct optstruct *opt) |
222 | 222 |
char *thefilename; |
223 | 223 |
for (x = 0; (thefilename = cli_strtok(opt->filename, x, "\t")) != NULL; x++) { |
224 | 224 |
if((fmodeint = fileinfo(thefilename, 2)) == -1) { |
225 |
- mprintf("@Can't access file %s\n", thefilename); |
|
225 |
+ logg("^Can't access file %s\n", thefilename); |
|
226 | 226 |
perror(thefilename); |
227 | 227 |
ret = 56; |
228 | 228 |
} else { |
... | ... |
@@ -239,7 +239,7 @@ int scanmanager(const struct optstruct *opt) |
239 | 239 |
if(compression && (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':')) { |
240 | 240 |
/* we need to complete the path */ |
241 | 241 |
if(!getcwd(cwd, sizeof(cwd))) { |
242 |
- mprintf("@Can't get absolute pathname of current working directory\n"); |
|
242 |
+ logg("^Can't get absolute pathname of current working directory\n"); |
|
243 | 243 |
free(limits); |
244 | 244 |
return 57; |
245 | 245 |
} else { |
... | ... |
@@ -249,7 +249,7 @@ int scanmanager(const struct optstruct *opt) |
249 | 249 |
#else |
250 | 250 |
snprintf(fullpath, 512, "%s/%s", cwd, thefilename); |
251 | 251 |
#endif |
252 |
- mprintf("*Full path: %s\n", fullpath); |
|
252 |
+ logg("*Full path: %s\n", fullpath); |
|
253 | 253 |
} |
254 | 254 |
} else |
255 | 255 |
fullpath = thefilename; |
... | ... |
@@ -264,7 +264,7 @@ int scanmanager(const struct optstruct *opt) |
264 | 264 |
break; |
265 | 265 |
|
266 | 266 |
default: |
267 |
- mprintf("@Not supported file type (%s)\n", thefilename); |
|
267 |
+ logg("^Not supported file type (%s)\n", thefilename); |
|
268 | 268 |
ret = 52; |
269 | 269 |
} |
270 | 270 |
|
... | ... |
@@ -304,7 +304,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
304 | 304 |
if(stat(filename, &sb) != -1) |
305 | 305 |
if(sb.st_dev == procdev) { |
306 | 306 |
if(!printinfected) |
307 |
- mprintf("%s: Excluded (/proc)\n", filename); |
|
307 |
+ logg("%s: Excluded (/proc)\n", filename); |
|
308 | 308 |
return 0; |
309 | 309 |
} |
310 | 310 |
#endif |
... | ... |
@@ -314,7 +314,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
314 | 314 |
while(argument) { |
315 | 315 |
if(match_regex(filename, argument) == 1) { |
316 | 316 |
if(!printinfected) |
317 |
- mprintf("%s: Excluded\n", filename); |
|
317 |
+ logg("%s: Excluded\n", filename); |
|
318 | 318 |
return 0; |
319 | 319 |
} |
320 | 320 |
argument = getnextargl(&optnode, "exclude"); |
... | ... |
@@ -334,21 +334,21 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
334 | 334 |
|
335 | 335 |
if(!included) { |
336 | 336 |
if(!printinfected) |
337 |
- mprintf("%s: Excluded\n", filename); |
|
337 |
+ logg("%s: Excluded\n", filename); |
|
338 | 338 |
return 0; |
339 | 339 |
} |
340 | 340 |
} |
341 | 341 |
|
342 | 342 |
if(fileinfo(filename, 1) == 0) { |
343 | 343 |
if(!printinfected) |
344 |
- mprintf("%s: Empty file\n", filename); |
|
344 |
+ logg("%s: Empty file\n", filename); |
|
345 | 345 |
return 0; |
346 | 346 |
} |
347 | 347 |
|
348 | 348 |
if(geteuid()) |
349 | 349 |
if(checkaccess(filename, NULL, R_OK) != 1) { |
350 | 350 |
if(!printinfected) |
351 |
- mprintf("%s: Access denied\n", filename); |
|
351 |
+ logg("%s: Access denied\n", filename); |
|
352 | 352 |
return 0; |
353 | 353 |
} |
354 | 354 |
|
... | ... |
@@ -366,11 +366,9 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
366 | 366 |
if((ret = checkfile(filename, root, limits, options)) == CL_VIRUS) { |
367 | 367 |
if(optl(opt, "remove")) { |
368 | 368 |
if(unlink(filename)) { |
369 |
- mprintf("%s: Can't remove\n", filename); |
|
370 | 369 |
logg("%s: Can't remove\n", filename); |
371 | 370 |
claminfo.notremoved++; |
372 | 371 |
} else { |
373 |
- mprintf("%s: Removed\n", filename); |
|
374 | 372 |
logg("%s: Removed\n", filename); |
375 | 373 |
} |
376 | 374 |
} else if (optl(opt, "move")) |
... | ... |
@@ -402,21 +400,21 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
402 | 402 |
/* check permissions */ |
403 | 403 |
switch(checkaccess(filename, UNPUSER, R_OK)) { |
404 | 404 |
case -1: |
405 |
- mprintf("@Can't get information about user "UNPUSER"\n"); |
|
405 |
+ logg("^Can't get information about user "UNPUSER"\n"); |
|
406 | 406 |
exit(60); /* this is a critical problem so we just exit here */ |
407 | 407 |
case -2: |
408 |
- mprintf("@Can't fork\n"); |
|
408 |
+ logg("^Can't fork\n"); |
|
409 | 409 |
exit(61); |
410 | 410 |
case 0: /* read access denied */ |
411 | 411 |
if(geteuid()) { |
412 | 412 |
if(!printinfected) |
413 |
- mprintf("%s: Access denied to archive\n", filename); |
|
413 |
+ logg("%s: Access denied to archive\n", filename); |
|
414 | 414 |
} else { |
415 | 415 |
|
416 | 416 |
if(limits && limits->maxfilesize) |
417 | 417 |
if(fileinfo(filename, 1) / 1024 > limits->maxfilesize) { |
418 | 418 |
if(!printinfected) |
419 |
- mprintf("%s: Archive too big\n", filename); |
|
419 |
+ logg("%s: Archive too big\n", filename); |
|
420 | 420 |
return 0; |
421 | 421 |
} |
422 | 422 |
|
... | ... |
@@ -432,11 +430,9 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
432 | 432 |
if((ret = checkfile(filename, root, limits, options)) == CL_VIRUS) { |
433 | 433 |
if(optl(opt, "remove")) { |
434 | 434 |
if(unlink(filename)) { |
435 |
- mprintf("%s: Can't remove\n", filename); |
|
436 | 435 |
logg("%s: Can't remove\n", filename); |
437 | 436 |
claminfo.notremoved++; |
438 | 437 |
} else { |
439 |
- mprintf("%s: Removed\n", filename); |
|
440 | 438 |
logg("%s: Removed\n", filename); |
441 | 439 |
} |
442 | 440 |
} else if (optl(opt, "move")) |
... | ... |
@@ -456,7 +452,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
456 | 456 |
stat(filename, &statbuf); |
457 | 457 |
|
458 | 458 |
if(!S_ISREG(statbuf.st_mode)) { |
459 |
- mprintf("^Suspected archive %s is not a regular file\n", filename); |
|
459 |
+ logg("^Suspected archive %s is not a regular file\n", filename); |
|
460 | 460 |
return 0; /* hmm ? */ |
461 | 461 |
} |
462 | 462 |
|
... | ... |
@@ -472,7 +468,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
472 | 472 |
#endif |
473 | 473 |
|
474 | 474 |
if(checkaccess(tmpdir, UNPUSER, W_OK) != 1) { |
475 |
- mprintf("@Can't write to the temporary directory\n"); |
|
475 |
+ logg("^Can't write to the temporary directory\n"); |
|
476 | 476 |
exit(64); |
477 | 477 |
} |
478 | 478 |
|
... | ... |
@@ -480,7 +476,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
480 | 480 |
|
481 | 481 |
gendir = cli_gentemp(tmpdir); |
482 | 482 |
if(mkdir(gendir, 0700)) { |
483 |
- mprintf("@Can't create the temporary directory %s\n", gendir); |
|
483 |
+ logg("^Can't create the temporary directory %s\n", gendir); |
|
484 | 484 |
exit(63); /* critical */ |
485 | 485 |
} |
486 | 486 |
|
... | ... |
@@ -587,24 +583,22 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
587 | 587 |
|
588 | 588 |
switch(ret) { |
589 | 589 |
case -1: |
590 |
- mprintf("@Can't fork()\n"); |
|
590 |
+ logg("^Can't fork()\n"); |
|
591 | 591 |
exit(61); /* this is critical problem, so we just exit here */ |
592 | 592 |
case -2: |
593 |
- mprintf("@Can't execute some unpacker. Check paths and permissions on the temporary directory\n"); |
|
593 |
+ logg("^Can't execute some unpacker. Check paths and permissions on the temporary directory\n"); |
|
594 | 594 |
/* This is no longer a critical error (since 0.24). We scan |
595 | 595 |
* raw archive. |
596 | 596 |
*/ |
597 | 597 |
if(!printinfected) |
598 |
- mprintf("(raw) "); |
|
598 |
+ logg("(raw) "); |
|
599 | 599 |
|
600 | 600 |
if((ret = checkfile(filename, root, limits, 0)) == CL_VIRUS) { |
601 | 601 |
if(optl(opt, "remove")) { |
602 | 602 |
if(unlink(filename)) { |
603 |
- mprintf("%s: Can't remove\n", filename); |
|
604 | 603 |
logg("%s: Can't remove\n", filename); |
605 | 604 |
claminfo.notremoved++; |
606 | 605 |
} else { |
607 |
- mprintf("%s: Removed\n", filename); |
|
608 | 606 |
logg("%s: Removed\n", filename); |
609 | 607 |
} |
610 | 608 |
} else if (optl(opt, "move")) |
... | ... |
@@ -619,11 +613,9 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
619 | 619 |
if((ret = checkfile(filename, root, limits, 0)) == CL_VIRUS) { |
620 | 620 |
if(optl(opt, "remove")) { |
621 | 621 |
if(unlink(filename)) { |
622 |
- mprintf("%s: Can't remove\n", filename); |
|
623 | 622 |
logg("%s: Can't remove\n", filename); |
624 | 623 |
claminfo.notremoved++; |
625 | 624 |
} else { |
626 |
- mprintf("%s: Removed\n", filename); |
|
627 | 625 |
logg("%s: Removed\n", filename); |
628 | 626 |
} |
629 | 627 |
} else if (optl(opt, "move")) |
... | ... |
@@ -632,18 +624,15 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
632 | 632 |
return ret; |
633 | 633 |
case 1: |
634 | 634 |
logg("%s: Infected.Archive FOUND\n", filename); |
635 |
- mprintf("%s: Infected.Archive FOUND\n", filename); |
|
636 | 635 |
|
637 | 636 |
if(bell) |
638 | 637 |
fprintf(stderr, "\007"); |
639 | 638 |
|
640 | 639 |
if(optl(opt, "remove")) { |
641 | 640 |
if(unlink(filename)) { |
642 |
- mprintf("%s: Can't remove\n", filename); |
|
643 | 641 |
logg("%s: Can't remove\n", filename); |
644 | 642 |
claminfo.notremoved++; |
645 | 643 |
} else { |
646 |
- mprintf("%s: Removed\n", filename); |
|
647 | 644 |
logg("%s: Removed\n", filename); |
648 | 645 |
} |
649 | 646 |
} else if (optl(opt, "move")) |
... | ... |
@@ -651,7 +640,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
651 | 651 |
|
652 | 652 |
return 1; |
653 | 653 |
default: |
654 |
- mprintf("@Strange value (%d) returned in scancompressed()\n", ret); |
|
654 |
+ logg("^Strange value (%d) returned in scancompressed()\n", ret); |
|
655 | 655 |
return 0; |
656 | 656 |
} |
657 | 657 |
} |
... | ... |
@@ -664,7 +653,7 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * |
664 | 664 |
|
665 | 665 |
stat(filename, &statbuf); |
666 | 666 |
if(!S_ISREG(statbuf.st_mode)) { |
667 |
- mprintf("^Suspected archive %s is not a regular file\n", filename); |
|
667 |
+ logg("^Suspected archive %s is not a regular file\n", filename); |
|
668 | 668 |
return 0; |
669 | 669 |
} |
670 | 670 |
|
... | ... |
@@ -681,14 +670,14 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * |
681 | 681 |
|
682 | 682 |
|
683 | 683 |
if(checkaccess(tmpdir, UNPUSER, W_OK) != 1) { |
684 |
- mprintf("@Can't write to the temporary directory %s\n", tmpdir); |
|
684 |
+ logg("^Can't write to the temporary directory %s\n", tmpdir); |
|
685 | 685 |
exit(64); |
686 | 686 |
} |
687 | 687 |
|
688 | 688 |
/* generate the temporary directory */ |
689 | 689 |
gendir = cli_gentemp(tmpdir); |
690 | 690 |
if(mkdir(gendir, 0700)) { |
691 |
- mprintf("@Can't create the temporary directory %s\n", gendir); |
|
691 |
+ logg("^Can't create the temporary directory %s\n", gendir); |
|
692 | 692 |
exit(63); /* critical */ |
693 | 693 |
} |
694 | 694 |
|
... | ... |
@@ -702,7 +691,7 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * |
702 | 702 |
sprintf(tmpfile, "%s/%s", gendir, pt); |
703 | 703 |
|
704 | 704 |
if(filecopy(filename, tmpfile) == -1) { |
705 |
- mprintf("!I/O error\n"); |
|
705 |
+ logg("!I/O error\n"); |
|
706 | 706 |
perror("copyfile()"); |
707 | 707 |
exit(58); |
708 | 708 |
} |
... | ... |
@@ -718,15 +707,12 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * |
718 | 718 |
|
719 | 719 |
if((ret = treewalk(gendir, root, user, opt, limits, options, 1)) == 1) { |
720 | 720 |
logg("(Real infected archive: %s)\n", filename); |
721 |
- mprintf("(Real infected archive: %s)\n", filename); |
|
722 | 721 |
|
723 | 722 |
if(optl(opt, "remove")) { |
724 | 723 |
if(unlink(filename)) { |
725 |
- mprintf("%s: Can't remove\n", filename); |
|
726 | 724 |
logg("%s: Can't remove\n", filename); |
727 | 725 |
claminfo.notremoved++; |
728 | 726 |
} else { |
729 |
- mprintf("%s: Removed\n", filename); |
|
730 | 727 |
logg("%s: Removed\n", filename); |
731 | 728 |
} |
732 | 729 |
} else if (optl(opt, "move")) |
... | ... |
@@ -753,15 +739,14 @@ int checkfile(const char *filename, const struct cl_node *root, const struct cl_ |
753 | 753 |
const char *virname; |
754 | 754 |
|
755 | 755 |
|
756 |
- mprintf("*Scanning %s\n", filename); |
|
756 |
+ logg("*Scanning %s\n", filename); |
|
757 | 757 |
|
758 | 758 |
if((fd = open(filename, O_RDONLY)) == -1) { |
759 |
- mprintf("@Can't open file %s\n", filename); |
|
759 |
+ logg("^Can't open file %s\n", filename); |
|
760 | 760 |
return 54; |
761 | 761 |
} |
762 | 762 |
|
763 | 763 |
if((ret = cl_scandesc(fd, &virname, &claminfo.blocks, root, limits, options)) == CL_VIRUS) { |
764 |
- mprintf("%s: %s FOUND\n", filename, virname); |
|
765 | 764 |
logg("%s: %s FOUND\n", filename, virname); |
766 | 765 |
claminfo.ifiles++; |
767 | 766 |
|
... | ... |
@@ -770,10 +755,10 @@ int checkfile(const char *filename, const struct cl_node *root, const struct cl_ |
770 | 770 |
|
771 | 771 |
} else if(ret == CL_CLEAN) { |
772 | 772 |
if(!printinfected) |
773 |
- mprintf("%s: OK\n", filename); |
|
773 |
+ logg("%s: OK\n", filename); |
|
774 | 774 |
} else |
775 | 775 |
if(!printinfected) |
776 |
- mprintf("%s: %s\n", filename, cl_strerror(ret)); |
|
776 |
+ logg("%s: %s\n", filename, cl_strerror(ret)); |
|
777 | 777 |
|
778 | 778 |
close(fd); |
779 | 779 |
return ret; |
... | ... |
@@ -798,14 +783,14 @@ int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int o |
798 | 798 |
#endif |
799 | 799 |
|
800 | 800 |
if(checkaccess(tmpdir, UNPUSER, W_OK) != 1) { |
801 |
- mprintf("@Can't write to temporary directory\n"); |
|
801 |
+ logg("^Can't write to temporary directory\n"); |
|
802 | 802 |
return 64; |
803 | 803 |
} |
804 | 804 |
|
805 | 805 |
file = cli_gentemp(tmpdir); |
806 | 806 |
|
807 | 807 |
if(!(fs = fopen(file, "wb"))) { |
808 |
- mprintf("@Can't open %s for writing\n", file); |
|
808 |
+ logg("^Can't open %s for writing\n", file); |
|
809 | 809 |
return 63; |
810 | 810 |
} |
811 | 811 |
|
... | ... |
@@ -814,11 +799,11 @@ int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int o |
814 | 814 |
|
815 | 815 |
fclose(fs); |
816 | 816 |
|
817 |
- mprintf("*Checking %s\n", file); |
|
817 |
+ logg("*Checking %s\n", file); |
|
818 | 818 |
claminfo.files++; |
819 | 819 |
|
820 | 820 |
if((ret = cl_scanfile(file, &virname, &claminfo.blocks, root, limits, options)) == CL_VIRUS) { |
821 |
- mprintf("stdin: %s FOUND\n", virname); |
|
821 |
+ logg("stdin: %s FOUND\n", virname); |
|
822 | 822 |
claminfo.ifiles++; |
823 | 823 |
|
824 | 824 |
if(bell) |
... | ... |
@@ -826,10 +811,10 @@ int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int o |
826 | 826 |
|
827 | 827 |
} else if(ret == CL_CLEAN) { |
828 | 828 |
if(!printinfected) |
829 |
- mprintf("stdin: OK\n"); |
|
829 |
+ logg("stdin: OK\n"); |
|
830 | 830 |
} else |
831 | 831 |
if(!printinfected) |
832 |
- mprintf("stdin: %s\n", cl_strerror(ret)); |
|
832 |
+ logg("stdin: %s\n", cl_strerror(ret)); |
|
833 | 833 |
|
834 | 834 |
unlink(file); |
835 | 835 |
free(file); |
... | ... |
@@ -899,7 +884,7 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc |
899 | 899 |
if(printinfected) { |
900 | 900 |
fdevnull = open("/dev/null", O_WRONLY); |
901 | 901 |
if(fdevnull == -1) { |
902 |
- mprintf("Non fatal error: cannot open /dev/null. Continuing with full output\n"); |
|
902 |
+ logg("Non fatal error: cannot open /dev/null. Continuing with full output\n"); |
|
903 | 903 |
printinfected = 0; |
904 | 904 |
} else { |
905 | 905 |
dup2(fdevnull,1); |
... | ... |
@@ -922,7 +907,7 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc |
922 | 922 |
|
923 | 923 |
if(!du(tmpdir, &n)) |
924 | 924 |
if((maxfiles && n.files > maxfiles) || (maxspace && n.space > maxspace)) { |
925 |
- mprintf("*n.files: %d, n.space: %d\n", n.files, n.space); |
|
925 |
+ logg("*n.files: %d, n.space: %d\n", n.files, n.space); |
|
926 | 926 |
kill(pid, 9); /* stop it immediately */ |
927 | 927 |
} |
928 | 928 |
} |
... | ... |
@@ -934,13 +919,13 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc |
934 | 934 |
switch(WTERMSIG(status)) { |
935 | 935 |
|
936 | 936 |
case 9: |
937 |
- mprintf("\nUnpacker process %d stopped due to exceeded limits\n", pid); |
|
937 |
+ logg("\nUnpacker process %d stopped due to exceeded limits\n", pid); |
|
938 | 938 |
return 0; |
939 | 939 |
case 6: /* abort */ |
940 |
- mprintf("@Can't run %s\n", prog); |
|
940 |
+ logg("^Can't run %s\n", prog); |
|
941 | 941 |
return -2; |
942 | 942 |
default: |
943 |
- mprintf("@\nUnpacker stopped with external signal %d\n", WTERMSIG(status)); |
|
943 |
+ logg("^\nUnpacker stopped with external signal %d\n", WTERMSIG(status)); |
|
944 | 944 |
return -3; |
945 | 945 |
} |
946 | 946 |
} else if(WIFEXITED(status)) |
... | ... |
@@ -960,13 +945,13 @@ void move_infected(const char *filename, const struct optstruct *opt) |
960 | 960 |
|
961 | 961 |
if(!(movedir = getargl(opt, "move"))) { |
962 | 962 |
/* Should never reach here */ |
963 |
- mprintf("@getargc() returned NULL\n", filename); |
|
963 |
+ logg("^getargc() returned NULL\n", filename); |
|
964 | 964 |
claminfo.notmoved++; |
965 | 965 |
return; |
966 | 966 |
} |
967 | 967 |
|
968 | 968 |
if(access(movedir, W_OK|X_OK) == -1) { |
969 |
- mprintf("@error moving file '%s': cannot write to '%s': %s\n", filename, movedir, strerror(errno)); |
|
969 |
+ logg("^error moving file '%s': cannot write to '%s': %s\n", filename, movedir, strerror(errno)); |
|
970 | 970 |
claminfo.notmoved++; |
971 | 971 |
return; |
972 | 972 |
} |
... | ... |
@@ -977,12 +962,12 @@ void move_infected(const char *filename, const struct optstruct *opt) |
977 | 977 |
movefilename_size = sizeof(char) * (strlen(movedir) + strlen(tmp) + sizeof(numext) + 2); |
978 | 978 |
|
979 | 979 |
if(!(movefilename = mmalloc(movefilename_size))) { |
980 |
- mprintf("@Memory allocation error\n"); |
|
980 |
+ logg("^Memory allocation error\n"); |
|
981 | 981 |
exit(71); |
982 | 982 |
} |
983 | 983 |
|
984 | 984 |
if(!(strrcpy(movefilename, movedir))) { |
985 |
- mprintf("@strrcpy() returned NULL\n"); |
|
985 |
+ logg("^strrcpy() returned NULL\n"); |
|
986 | 986 |
claminfo.notmoved++; |
987 | 987 |
free(movefilename); |
988 | 988 |
return; |
... | ... |
@@ -991,7 +976,7 @@ void move_infected(const char *filename, const struct optstruct *opt) |
991 | 991 |
strcat(movefilename, "/"); |
992 | 992 |
|
993 | 993 |
if(!(strcat(movefilename, tmp))) { |
994 |
- mprintf("@strcat() returned NULL\n"); |
|
994 |
+ logg("^strcat() returned NULL\n"); |
|
995 | 995 |
claminfo.notmoved++; |
996 | 996 |
free(movefilename); |
997 | 997 |
return; |
... | ... |
@@ -1001,7 +986,6 @@ void move_infected(const char *filename, const struct optstruct *opt) |
1001 | 1001 |
|
1002 | 1002 |
if(!stat(movefilename, &mfstat)) { |
1003 | 1003 |
if(fstat.st_ino == mfstat.st_ino) { /* It's the same file*/ |
1004 |
- mprintf("File excluded '%s'\n", filename); |
|
1005 | 1004 |
logg("File excluded '%s'\n", filename); |
1006 | 1005 |
claminfo.notmoved++; |
1007 | 1006 |
free(movefilename); |
... | ... |
@@ -1027,7 +1011,7 @@ void move_infected(const char *filename, const struct optstruct *opt) |
1027 | 1027 |
|
1028 | 1028 |
if(rename(filename, movefilename) == -1) { |
1029 | 1029 |
if(filecopy(filename, movefilename) == -1) { |
1030 |
- mprintf("@cannot move '%s' to '%s': %s\n", filename, movefilename, strerror(errno)); |
|
1030 |
+ logg("^cannot move '%s' to '%s': %s\n", filename, movefilename, strerror(errno)); |
|
1031 | 1031 |
claminfo.notmoved++; |
1032 | 1032 |
free(movefilename); |
1033 | 1033 |
return; |
... | ... |
@@ -1043,14 +1027,13 @@ void move_infected(const char *filename, const struct optstruct *opt) |
1043 | 1043 |
utime(movefilename, &ubuf); |
1044 | 1044 |
|
1045 | 1045 |
if(unlink(filename)) { |
1046 |
- mprintf("@cannot unlink '%s': %s\n", filename, strerror(errno)); |
|
1046 |
+ logg("^cannot unlink '%s': %s\n", filename, strerror(errno)); |
|
1047 | 1047 |
claminfo.notremoved++; |
1048 | 1048 |
free(movefilename); |
1049 | 1049 |
return; |
1050 | 1050 |
} |
1051 | 1051 |
} |
1052 | 1052 |
|
1053 |
- mprintf("%s: moved to '%s'\n", filename, movefilename); |
|
1054 | 1053 |
logg("%s: moved to '%s'\n", filename, movefilename); |
1055 | 1054 |
|
1056 | 1055 |
free(movefilename); |
... | ... |
@@ -47,6 +47,8 @@ static char clamdscan_short[] = { 'h', 'V', 'v', 'l', 0 }; |
47 | 47 |
|
48 | 48 |
int clamdscan_mode = 0; |
49 | 49 |
|
50 |
+short foreground = 1; |
|
51 |
+ |
|
50 | 52 |
int main(int argc, char **argv) |
51 | 53 |
{ |
52 | 54 |
int ret, opt_index, i, len; |
... | ... |
@@ -145,7 +147,7 @@ int main(int argc, char **argv) |
145 | 145 |
register_char_option(opt, ret, NULL); |
146 | 146 |
|
147 | 147 |
} else { |
148 |
- mprintf("!Unknown option passed.\n"); |
|
148 |
+ logg("!Unknown option passed.\n"); |
|
149 | 149 |
free_opt(opt); |
150 | 150 |
if(clamdscan_mode) |
151 | 151 |
exit(2); |
... | ... |
@@ -194,9 +196,9 @@ void register_char_option(struct optstruct *opt, char ch, const char *longname) |
194 | 194 |
|
195 | 195 |
if(!found) { |
196 | 196 |
if(longname) |
197 |
- mprintf("WARNING: Ignoring option -%c (--%s): please edit clamd.conf instead.\n", ch, longname); |
|
197 |
+ logg("WARNING: Ignoring option -%c (--%s): please edit clamd.conf instead.\n", ch, longname); |
|
198 | 198 |
else |
199 |
- mprintf("WARNING: Ignoring option -%c: please edit clamd.conf instead.\n", ch); |
|
199 |
+ logg("WARNING: Ignoring option -%c: please edit clamd.conf instead.\n", ch); |
|
200 | 200 |
|
201 | 201 |
return; |
202 | 202 |
} |
... | ... |
@@ -226,7 +228,7 @@ void register_long_option(struct optstruct *opt, const char *optname) |
226 | 226 |
found = 1; |
227 | 227 |
|
228 | 228 |
if(!found) { |
229 |
- mprintf("WARNING: Ignoring option --%s: please edit clamd.conf instead.\n", optname); |
|
229 |
+ logg("WARNING: Ignoring option --%s: please edit clamd.conf instead.\n", optname); |
|
230 | 230 |
return; |
231 | 231 |
} |
232 | 232 |
} |
... | ... |
@@ -67,7 +67,7 @@ int fileinfo(const char *filename, short i) |
67 | 67 |
case 5: /* GID */ |
68 | 68 |
return infostruct.st_gid; |
69 | 69 |
default: |
70 |
- mprintf("!fileinfo(): Unknown option.\n"); |
|
70 |
+ logg("!fileinfo(): Unknown option.\n"); |
|
71 | 71 |
exit(1); |
72 | 72 |
} |
73 | 73 |
} |
... | ... |
@@ -128,7 +128,6 @@ int match_regex(const char *filename, const char *pattern) |
128 | 128 |
flags = REG_EXTENDED | REG_ICASE; /* case insensitive on Windows */ |
129 | 129 |
#endif |
130 | 130 |
if(regcomp(®, pattern, flags) != 0) { |
131 |
- mprintf("!%s: Could not parse regular expression %s.\n", filename, pattern); |
|
132 | 131 |
logg("!%s: Could not parse regular expression %s.\n", filename, pattern); |
133 | 132 |
return 2; |
134 | 133 |
} |
... | ... |
@@ -57,7 +57,7 @@ int treewalk(const char *dirname, struct cl_node *root, const struct passwd *use |
57 | 57 |
while(argument) { |
58 | 58 |
if(match_regex(dirname, argument) == 1) { |
59 | 59 |
if(!printinfected) |
60 |
- mprintf("%s: Excluded\n", dirname); |
|
60 |
+ logg("%s: Excluded\n", dirname); |
|
61 | 61 |
return 0; |
62 | 62 |
} |
63 | 63 |
argument = getnextargl(&optnode, "exclude"); |
... | ... |
@@ -77,7 +77,7 @@ int treewalk(const char *dirname, struct cl_node *root, const struct passwd *use |
77 | 77 |
|
78 | 78 |
if(!included) { |
79 | 79 |
if(!printinfected) |
80 |
- mprintf("%s: Excluded\n", dirname); |
|
80 |
+ logg("%s: Excluded\n", dirname); |
|
81 | 81 |
return 0; |
82 | 82 |
} |
83 | 83 |
} |
... | ... |
@@ -121,7 +121,7 @@ int treewalk(const char *dirname, struct cl_node *root, const struct passwd *use |
121 | 121 |
} |
122 | 122 |
} else { |
123 | 123 |
if(!printinfected) |
124 |
- mprintf("%s: Can't open directory.\n", dirname); |
|
124 |
+ logg("%s: Can't open directory.\n", dirname); |
|
125 | 125 |
return 53; |
126 | 126 |
} |
127 | 127 |
|
... | ... |
@@ -159,7 +159,7 @@ int rmdirs(const char *dirname) |
159 | 159 |
if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) { |
160 | 160 |
if(rmdir(fname) == -1) { /* can't be deleted */ |
161 | 161 |
if(errno == EACCES) { |
162 |
- mprintf("@Can't remove some temporary directories due to access problem.\n"); |
|
162 |
+ logg("^Can't remove some temporary directories due to access problem.\n"); |
|
163 | 163 |
closedir(dd); |
164 | 164 |
return 0; |
165 | 165 |
} |
... | ... |
@@ -180,7 +180,7 @@ int rmdirs(const char *dirname) |
180 | 180 |
|
181 | 181 |
} else { |
182 | 182 |
if(!printinfected) |
183 |
- mprintf("%s: Can't open directory.\n", dirname); |
|
183 |
+ logg("%s: Can't open directory.\n", dirname); |
|
184 | 184 |
return 53; |
185 | 185 |
} |
186 | 186 |
|
... | ... |
@@ -271,7 +271,7 @@ int fixperms(const char *dirname) |
271 | 271 |
} |
272 | 272 |
} else { |
273 | 273 |
if(!printinfected) |
274 |
- mprintf("%s: Can't open directory.\n", dirname); |
|
274 |
+ logg("%s: Can't open directory.\n", dirname); |
|
275 | 275 |
return 53; |
276 | 276 |
} |
277 | 277 |
|
... | ... |
@@ -319,7 +319,7 @@ int du(const char *dirname, struct s_du *n) |
319 | 319 |
} |
320 | 320 |
} else { |
321 | 321 |
if(!printinfected) |
322 |
- mprintf("%s: Can't open directory.\n", dirname); |
|
322 |
+ logg("%s: Can't open directory.\n", dirname); |
|
323 | 323 |
return 53; |
324 | 324 |
} |
325 | 325 |
|
... | ... |
@@ -45,22 +45,22 @@ char *txtquery(const char *domain, unsigned int *ttl) |
45 | 45 |
|
46 | 46 |
|
47 | 47 |
if(res_init() < 0) { |
48 |
- mprintf("@res_init failed\n"); |
|
48 |
+ logg("^res_init failed\n"); |
|
49 | 49 |
return NULL; |
50 | 50 |
} |
51 | 51 |
|
52 |
- mprintf("*Querying %s\n", domain); |
|
52 |
+ logg("*Querying %s\n", domain); |
|
53 | 53 |
|
54 | 54 |
memset(answer, 0, PACKETSZ); |
55 | 55 |
if((len = res_query(domain, C_IN, T_TXT, answer, PACKETSZ)) < 0) { |
56 |
- mprintf("@Can't query %s\n", domain); |
|
56 |
+ logg("^Can't query %s\n", domain); |
|
57 | 57 |
return NULL; |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
pt = answer + sizeof(HEADER); |
61 | 61 |
|
62 | 62 |
if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0) { |
63 |
- mprintf("@dn_expand failed\n"); |
|
63 |
+ logg("^dn_expand failed\n"); |
|
64 | 64 |
return NULL; |
65 | 65 |
} |
66 | 66 |
|
... | ... |
@@ -68,21 +68,21 @@ char *txtquery(const char *domain, unsigned int *ttl) |
68 | 68 |
|
69 | 69 |
GETSHORT(type, pt); |
70 | 70 |
if(type != T_TXT) { |
71 |
- mprintf("@Broken DNS reply.\n"); |
|
71 |
+ logg("^Broken DNS reply.\n"); |
|
72 | 72 |
return NULL; |
73 | 73 |
} |
74 | 74 |
|
75 | 75 |
pt += INT16SZ; /* class */ |
76 | 76 |
|
77 | 77 |
if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0) { |
78 |
- mprintf("@second dn_expand failed\n"); |
|
78 |
+ logg("^second dn_expand failed\n"); |
|
79 | 79 |
return NULL; |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
pt += exp; |
83 | 83 |
GETSHORT(type, pt); |
84 | 84 |
if(type != T_TXT) { |
85 |
- mprintf("@Not a TXT record\n"); |
|
85 |
+ logg("^Not a TXT record\n"); |
|
86 | 86 |
return NULL; |
87 | 87 |
} |
88 | 88 |
|
... | ... |
@@ -93,7 +93,7 @@ char *txtquery(const char *domain, unsigned int *ttl) |
93 | 93 |
txtlen = *pt; |
94 | 94 |
|
95 | 95 |
if(txtlen >= size || !txtlen) { |
96 |
- mprintf("@Broken TXT record (txtlen = %d, size = %d)\n", txtlen, size); |
|
96 |
+ logg("^Broken TXT record (txtlen = %d, size = %d)\n", txtlen, size); |
|
97 | 97 |
return NULL; |
98 | 98 |
} |
99 | 99 |
|
... | ... |
@@ -41,17 +41,17 @@ void execute( const char *type, const char *text ) |
41 | 41 |
case 0: |
42 | 42 |
if ( -1==system(text) ) |
43 | 43 |
{ |
44 |
- mprintf("@%s: couldn't execute \"%s\".\n", type, text); |
|
44 |
+ logg("^%s: couldn't execute \"%s\".\n", type, text); |
|
45 | 45 |
} |
46 | 46 |
exit(0); |
47 | 47 |
case -1: |
48 |
- mprintf("@%s::fork() failed, %s.\n", type, strerror(errno)); |
|
48 |
+ logg("^%s::fork() failed, %s.\n", type, strerror(errno)); |
|
49 | 49 |
break; |
50 | 50 |
default: |
51 | 51 |
active_children++; |
52 | 52 |
} |
53 | 53 |
else |
54 | 54 |
{ |
55 |
- mprintf("@%s: already %d processes active.\n", type, active_children); |
|
55 |
+ logg("^%s: already %d processes active.\n", type, active_children); |
|
56 | 56 |
} |
57 | 57 |
} |
... | ... |
@@ -51,6 +51,8 @@ |
51 | 51 |
static short terminate = 0; |
52 | 52 |
extern int active_children; |
53 | 53 |
|
54 |
+short foreground = 1; |
|
55 |
+ |
|
54 | 56 |
static void daemon_sighandler(int sig) { |
55 | 57 |
|
56 | 58 |
switch(sig) { |
... | ... |
@@ -120,21 +122,21 @@ int freshclam(struct optstruct *opt) |
120 | 120 |
} |
121 | 121 |
|
122 | 122 |
if(!copt) { |
123 |
- mprintf("!Can't parse the config file %s\n", cfgfile); |
|
123 |
+ logg("!Can't parse the config file %s\n", cfgfile); |
|
124 | 124 |
return 56; |
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
if(optl(opt, "http-proxy") || optl(opt, "proxy-user")) |
128 |
- mprintf("WARNING: Proxy settings are now only configurable in the config file.\n"); |
|
128 |
+ logg("WARNING: Proxy settings are now only configurable in the config file.\n"); |
|
129 | 129 |
|
130 | 130 |
if(cfgopt(copt, "HTTPProxyPassword")->enabled) { |
131 | 131 |
if(stat(cfgfile, &statbuf) == -1) { |
132 |
- mprintf("@Can't stat %s (critical error)\n", cfgfile); |
|
132 |
+ logg("^Can't stat %s (critical error)\n", cfgfile); |
|
133 | 133 |
return 56; |
134 | 134 |
} |
135 | 135 |
#ifndef C_CYGWIN |
136 | 136 |
if(statbuf.st_mode & (S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)) { |
137 |
- mprintf("@Insecure permissions (for HTTPProxyPassword): %s must have no more than 0700 permissions.\n", cfgfile); |
|
137 |
+ logg("^Insecure permissions (for HTTPProxyPassword): %s must have no more than 0700 permissions.\n", cfgfile); |
|
138 | 138 |
return 56; |
139 | 139 |
} |
140 | 140 |
#endif |
... | ... |
@@ -152,33 +154,33 @@ int freshclam(struct optstruct *opt) |
152 | 152 |
|
153 | 153 |
if(!geteuid()) { |
154 | 154 |
if((user = getpwnam(unpuser)) == NULL) { |
155 |
- mprintf("@Can't get information about user %s.\n", unpuser); |
|
155 |
+ logg("^Can't get information about user %s.\n", unpuser); |
|
156 | 156 |
exit(60); /* this is critical problem, so we just exit here */ |
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
if(cfgopt(copt, "AllowSupplementaryGroups")->enabled) { |
160 | 160 |
#ifdef HAVE_INITGROUPS |
161 | 161 |
if(initgroups(unpuser, user->pw_gid)) { |
162 |
- mprintf("@initgroups() failed.\n"); |
|
162 |
+ logg("^initgroups() failed.\n"); |
|
163 | 163 |
exit(61); |
164 | 164 |
} |
165 | 165 |
#endif |
166 | 166 |
} else { |
167 | 167 |
#ifdef HAVE_SETGROUPS |
168 | 168 |
if(setgroups(1, &user->pw_gid)) { |
169 |
- mprintf("@setgroups() failed.\n"); |
|
169 |
+ logg("^setgroups() failed.\n"); |
|
170 | 170 |
exit(61); |
171 | 171 |
} |
172 | 172 |
#endif |
173 | 173 |
} |
174 | 174 |
|
175 | 175 |
if(setgid(user->pw_gid)) { |
176 |
- mprintf("@setgid(%d) failed.\n", (int) user->pw_gid); |
|
176 |
+ logg("^setgid(%d) failed.\n", (int) user->pw_gid); |
|
177 | 177 |
exit(61); |
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
if(setuid(user->pw_uid)) { |
181 |
- mprintf("@setuid(%d) failed.\n", (int) user->pw_uid); |
|
181 |
+ logg("^setuid(%d) failed.\n", (int) user->pw_uid); |
|
182 | 182 |
exit(61); |
183 | 183 |
} |
184 | 184 |
} |
... | ... |
@@ -236,7 +238,6 @@ int freshclam(struct optstruct *opt) |
236 | 236 |
|
237 | 237 |
openlog("freshclam", LOG_PID, fac); |
238 | 238 |
logg_syslog = 1; |
239 |
- syslog(LOG_INFO, "Daemon started.\n"); |
|
240 | 239 |
} |
241 | 240 |
#endif |
242 | 241 |
|
... | ... |
@@ -247,10 +248,10 @@ int freshclam(struct optstruct *opt) |
247 | 247 |
newdir = cfgopt(copt, "DatabaseDirectory")->strarg; |
248 | 248 |
|
249 | 249 |
if(chdir(newdir)) { |
250 |
- mprintf("Can't change dir to %s\n", newdir); |
|
250 |
+ logg("Can't change dir to %s\n", newdir); |
|
251 | 251 |
exit(50); |
252 | 252 |
} else |
253 |
- mprintf("*Current working dir is %s\n", newdir); |
|
253 |
+ logg("*Current working dir is %s\n", newdir); |
|
254 | 254 |
|
255 | 255 |
|
256 | 256 |
if(optc(opt, 'd')) { |
... | ... |
@@ -266,21 +267,23 @@ int freshclam(struct optstruct *opt) |
266 | 266 |
checks = cfgopt(copt, "Checks")->numarg; |
267 | 267 |
|
268 | 268 |
if(checks <= 0) { |
269 |
- mprintf("@Number of checks must be a positive integer.\n"); |
|
269 |
+ logg("^Number of checks must be a positive integer.\n"); |
|
270 | 270 |
exit(41); |
271 | 271 |
} |
272 | 272 |
|
273 | 273 |
if(!cfgopt(copt, "DNSDatabaseInfo")->enabled || optl(opt, "no-dns")) { |
274 | 274 |
if(checks > 50) { |
275 |
- mprintf("@Number of checks must be between 1 and 50.\n"); |
|
275 |
+ logg("^Number of checks must be between 1 and 50.\n"); |
|
276 | 276 |
exit(41); |
277 | 277 |
} |
278 | 278 |
} |
279 | 279 |
|
280 | 280 |
bigsleep = 24 * 3600 / checks; |
281 | 281 |
|
282 |
- if(!cfgopt(copt, "Foreground")->enabled) |
|
282 |
+ if(!cfgopt(copt, "Foreground")->enabled) { |
|
283 |
+ foreground = 0; |
|
283 | 284 |
daemonize(); |
285 |
+ } |
|
284 | 286 |
|
285 | 287 |
if (optc(opt, 'p')) { |
286 | 288 |
pidfile = getargc(opt, 'p'); |
... | ... |
@@ -364,10 +367,10 @@ int download(const struct cfgstruct *copt, const struct optstruct *opt) |
364 | 364 |
|
365 | 365 |
|
366 | 366 |
maxattempts = cfgopt(copt, "MaxAttempts")->numarg; |
367 |
- mprintf("*Max retries == %d\n", maxattempts); |
|
367 |
+ logg("*Max retries == %d\n", maxattempts); |
|
368 | 368 |
|
369 | 369 |
if(!(cpt = cfgopt(copt, "DatabaseMirror"))->enabled) { |
370 |
- mprintf("@You must specify at least one database mirror.\n"); |
|
370 |
+ logg("^You must specify at least one database mirror.\n"); |
|
371 | 371 |
return 56; |
372 | 372 |
} else { |
373 | 373 |
|
... | ... |
@@ -377,18 +380,15 @@ int download(const struct cfgstruct *copt, const struct optstruct *opt) |
377 | 377 |
|
378 | 378 |
if(ret == 52 || ret == 54 || ret == 58 || ret == 59) { |
379 | 379 |
if(try < maxattempts - 1) { |
380 |
- mprintf("Trying again in 5 secs...\n"); |
|
381 | 380 |
logg("Trying again in 5 secs...\n"); |
382 | 381 |
try++; |
383 | 382 |
sleep(5); |
384 | 383 |
continue; |
385 | 384 |
} else { |
386 |
- mprintf("Giving up on %s...\n", cpt->strarg); |
|
387 | 385 |
logg("Giving up on %s...\n", cpt->strarg); |
388 | 386 |
cpt = (struct cfgstruct *) cpt->nextarg; |
389 | 387 |
if(!cpt) { |
390 |
- mprintf("@Update failed. Your network may be down or none of the mirrors listed in freshclam.conf is working.\n"); |
|
391 |
- logg("ERROR: Update failed. Your network may be down or none of the mirrors listed in freshclam.conf is working.\n"); |
|
388 |
+ logg("^Update failed. Your network may be down or none of the mirrors listed in freshclam.conf is working.\n"); |
|
392 | 389 |
} |
393 | 390 |
try = 0; |
394 | 391 |
} |
... | ... |
@@ -65,12 +65,9 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
65 | 65 |
#endif |
66 | 66 |
|
67 | 67 |
time(&currtime); |
68 |
- mprintf("ClamAV update process started at %s", ctime(&currtime)); |
|
69 | 68 |
logg("ClamAV update process started at %s", ctime(&currtime)); |
70 | 69 |
|
71 | 70 |
#ifndef HAVE_GMP |
72 |
- mprintf("SECURITY WARNING: NO SUPPORT FOR DIGITAL SIGNATURES\n"); |
|
73 |
- mprintf("See the FAQ at http://www.clamav.net/faq.html for an explanation.\n"); |
|
74 | 71 |
logg("SECURITY WARNING: NO SUPPORT FOR DIGITAL SIGNATURES\n"); |
75 | 72 |
logg("See the FAQ at http://www.clamav.net/faq.html for an explanation.\n"); |
76 | 73 |
#endif |
... | ... |
@@ -82,7 +79,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
82 | 82 |
dnsreply = NULL; |
83 | 83 |
} else { |
84 | 84 |
if((dnsreply = txtquery(dnsdbinfo, &ttl))) { |
85 |
- mprintf("*TTL: %d\n", ttl); |
|
85 |
+ logg("*TTL: %d\n", ttl); |
|
86 | 86 |
|
87 | 87 |
if((pt = cli_strtok(dnsreply, 3, ":"))) { |
88 | 88 |
int rt; |
... | ... |
@@ -92,8 +89,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
92 | 92 |
free(pt); |
93 | 93 |
time(&ct); |
94 | 94 |
if((int) ct - rt > 10800) { |
95 |
- mprintf("WARNING: DNS record is older than 3 hours.\n"); |
|
96 |
- logg("WARNING: DNS record is older than 3 hours.\n"); |
|
95 |
+ logg("^DNS record is older than 3 hours.\n"); |
|
97 | 96 |
free(dnsreply); |
98 | 97 |
dnsreply = NULL; |
99 | 98 |
} |
... | ... |
@@ -115,15 +111,12 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
115 | 115 |
|
116 | 116 |
if((pt = cli_strtok(dnsreply, 0, ":"))) { |
117 | 117 |
|
118 |
- mprintf("*Software version from DNS: %s\n", pt); |
|
118 |
+ logg("*Software version from DNS: %s\n", pt); |
|
119 | 119 |
|
120 | 120 |
if(vwarning && !strstr(cl_retver(), "devel") && !strstr(cl_retver(), "rc")) { |
121 | 121 |
if(strcmp(cl_retver(), pt)) { |
122 |
- mprintf("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
123 |
- mprintf("WARNING: Local version: %s Recommended version: %s\n", cl_retver(), pt); |
|
124 |
- mprintf("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
|
125 |
- logg("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
126 |
- logg("WARNING: Local version: %s Recommended version: %s\n", cl_retver(), pt); |
|
122 |
+ logg("^Your ClamAV installation is OUTDATED!\n"); |
|
123 |
+ logg("^Local version: %s Recommended version: %s\n", cl_retver(), pt); |
|
127 | 124 |
logg("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
128 | 125 |
} |
129 | 126 |
} |
... | ... |
@@ -139,8 +132,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
if(!dnsreply) { |
142 |
- mprintf("WARNING: Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
143 |
- logg("WARNING: Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
142 |
+ logg("^Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
144 | 143 |
} |
145 | 144 |
} |
146 | 145 |
#endif /* HAVE_RESOLV_H */ |
... | ... |
@@ -177,10 +169,8 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c |
177 | 177 |
|
178 | 178 |
if(updated) { |
179 | 179 |
if(cfgopt(copt, "HTTPProxyServer")->enabled) { |
180 |
- mprintf("Database updated (%d signatures) from %s\n", signo, hostname); |
|
181 | 180 |
logg("Database updated (%d signatures) from %s\n", signo, hostname); |
182 | 181 |
} else { |
183 |
- mprintf("Database updated (%d signatures) from %s (IP: %s)\n", signo, hostname, ipaddr); |
|
184 | 182 |
logg("Database updated (%d signatures) from %s (IP: %s)\n", signo, hostname, ipaddr); |
185 | 183 |
} |
186 | 184 |
|
... | ... |
@@ -235,22 +225,19 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
235 | 235 |
} else if(!strcmp(remotename, "daily.cvd")) { |
236 | 236 |
field = 2; |
237 | 237 |
} else { |
238 |
- mprintf("WARNING: Unknown database name (%s) passed.\n", remotename); |
|
239 |
- logg("WARNING: Unknown database name (%s) passed.\n", remotename); |
|
238 |
+ logg("^Unknown database name (%s) passed.\n", remotename); |
|
240 | 239 |
} |
241 | 240 |
|
242 | 241 |
if(field && (pt = cli_strtok(dnsreply, field, ":"))) { |
243 | 242 |
if(!isnumb(pt)) { |
244 |
- mprintf("WARNING: Broken database version in TXT record.\n"); |
|
245 |
- logg("WARNING: Broken database version in TXT record.\n"); |
|
243 |
+ logg("^Broken database version in TXT record.\n"); |
|
246 | 244 |
} else { |
247 | 245 |
dbver = atoi(pt); |
248 |
- mprintf("*%s version from DNS: %d\n", remotename, dbver); |
|
246 |
+ logg("*%s version from DNS: %d\n", remotename, dbver); |
|
249 | 247 |
} |
250 | 248 |
free(pt); |
251 | 249 |
} else { |
252 |
- mprintf("WARNING: Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
253 |
- logg("WARNING: Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
250 |
+ logg("^Invalid DNS reply. Falling back to HTTP mode.\n"); |
|
254 | 251 |
} |
255 | 252 |
|
256 | 253 |
} |
... | ... |
@@ -266,7 +253,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
266 | 266 |
if((cpt = cfgopt(copt, "HTTPProxyPassword"))->enabled) { |
267 | 267 |
pass = cpt->strarg; |
268 | 268 |
} else { |
269 |
- mprintf("HTTPProxyUsername requires HTTPProxyPassword\n"); |
|
269 |
+ logg("HTTPProxyUsername requires HTTPProxyPassword\n"); |
|
270 | 270 |
if(current) |
271 | 271 |
cl_cvdfree(current); |
272 | 272 |
return 56; |
... | ... |
@@ -276,7 +263,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
276 | 276 |
if((cpt = cfgopt(copt, "HTTPProxyPort"))->enabled) |
277 | 277 |
port = cpt->numarg; |
278 | 278 |
|
279 |
- mprintf("Connecting via %s\n", proxy); |
|
279 |
+ logg("Connecting via %s\n", proxy); |
|
280 | 280 |
} |
281 | 281 |
|
282 | 282 |
memset(ipaddr, 0, sizeof(ipaddr)); |
... | ... |
@@ -292,8 +279,8 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
292 | 292 |
cl_cvdfree(current); |
293 | 293 |
return 52; |
294 | 294 |
} else { |
295 |
- mprintf("*Connected to %s (IP: %s).\n", hostname, ipaddr); |
|
296 |
- mprintf("*Trying to retrieve http://%s/%s\n", hostname, remotename); |
|
295 |
+ logg("*Connected to %s (IP: %s).\n", hostname, ipaddr); |
|
296 |
+ logg("*Trying to retrieve http://%s/%s\n", hostname, remotename); |
|
297 | 297 |
} |
298 | 298 |
|
299 | 299 |
if(!ip[0]) |
... | ... |
@@ -302,7 +289,6 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
302 | 302 |
remote = remote_cvdhead(remotename, hostfd, hostname, proxy, user, pass, &ims); |
303 | 303 |
|
304 | 304 |
if(!nodb && !ims) { |
305 |
- mprintf("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
|
306 | 305 |
logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
307 | 306 |
*signo += current->sigs; |
308 | 307 |
close(hostfd); |
... | ... |
@@ -311,7 +297,7 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
if(!remote) { |
314 |
- mprintf("@Can't read %s header from %s (IP: %s)\n", remotename, hostname, ipaddr); |
|
314 |
+ logg("^Can't read %s header from %s (IP: %s)\n", remotename, hostname, ipaddr); |
|
315 | 315 |
close(hostfd); |
316 | 316 |
if(current) |
317 | 317 |
cl_cvdfree(current); |
... | ... |
@@ -324,16 +310,12 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
if(!nodb && (current->version >= dbver)) { |
327 |
- mprintf("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
|
328 | 327 |
logg("%s is up to date (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
329 | 328 |
|
330 | 329 |
if(flevel < current->fl) { |
331 | 330 |
/* display warning even for already installed database */ |
332 |
- mprintf("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
333 |
- mprintf("WARNING: Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
334 |
- mprintf("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
|
335 |
- logg("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
336 |
- logg("WARNING: Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
331 |
+ logg("^Your ClamAV installation is OUTDATED!\n"); |
|
332 |
+ logg("^Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
337 | 333 |
logg("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
338 | 334 |
} |
339 | 335 |
|
... | ... |
@@ -356,9 +338,9 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
356 | 356 |
|
357 | 357 |
if(hostfd < 0) { |
358 | 358 |
if(ipaddr[0]) |
359 |
- mprintf("Connection with %s (IP: %s) failed.\n", hostname, ipaddr); |
|
359 |
+ logg("Connection with %s (IP: %s) failed.\n", hostname, ipaddr); |
|
360 | 360 |
else |
361 |
- mprintf("Connection with %s failed.\n", hostname); |
|
361 |
+ logg("Connection with %s failed.\n", hostname); |
|
362 | 362 |
return 52; |
363 | 363 |
}; |
364 | 364 |
|
... | ... |
@@ -367,9 +349,9 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
367 | 367 |
*/ |
368 | 368 |
tempname = cli_gentemp("."); |
369 | 369 |
|
370 |
- mprintf("*Retrieving http://%s/%s\n", hostname, remotename); |
|
370 |
+ logg("*Retrieving http://%s/%s\n", hostname, remotename); |
|
371 | 371 |
if((ret = get_database(remotename, hostfd, tempname, hostname, proxy, user, pass))) { |
372 |
- mprintf("@Can't download %s from %s (IP: %s)\n", remotename, hostname, ipaddr); |
|
372 |
+ logg("^Can't download %s from %s (IP: %s)\n", remotename, hostname, ipaddr); |
|
373 | 373 |
unlink(tempname); |
374 | 374 |
free(tempname); |
375 | 375 |
close(hostfd); |
... | ... |
@@ -379,21 +361,21 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
379 | 379 |
close(hostfd); |
380 | 380 |
|
381 | 381 |
if((ret = cl_cvdverify(tempname))) { |
382 |
- mprintf("@Verification: %s\n", cl_strerror(ret)); |
|
382 |
+ logg("^Verification: %s\n", cl_strerror(ret)); |
|
383 | 383 |
unlink(tempname); |
384 | 384 |
free(tempname); |
385 | 385 |
return 54; |
386 | 386 |
} |
387 | 387 |
|
388 | 388 |
if((current = cl_cvdhead(tempname)) == NULL) { |
389 |
- mprintf("@Can't read CVD header of new %s database.\n", localname); |
|
389 |
+ logg("^Can't read CVD header of new %s database.\n", localname); |
|
390 | 390 |
unlink(tempname); |
391 | 391 |
free(tempname); |
392 | 392 |
return 54; |
393 | 393 |
} |
394 | 394 |
|
395 | 395 |
if(current->version < dbver) { |
396 |
- mprintf("@Mirrors are not fully synchronized. Please try again later.\n"); |
|
396 |
+ logg("^Mirrors are not fully synchronized. Please try again later.\n"); |
|
397 | 397 |
cl_cvdfree(current); |
398 | 398 |
unlink(tempname); |
399 | 399 |
free(tempname); |
... | ... |
@@ -401,31 +383,27 @@ int downloaddb(const char *localname, const char *remotename, const char *hostna |
401 | 401 |
} |
402 | 402 |
|
403 | 403 |
if(!nodb && unlink(localname)) { |
404 |
- mprintf("@Can't unlink %s. Please fix it and try again.\n", localname); |
|
404 |
+ logg("^Can't unlink %s. Please fix it and try again.\n", localname); |
|
405 | 405 |
cl_cvdfree(current); |
406 | 406 |
unlink(tempname); |
407 | 407 |
free(tempname); |
408 | 408 |
return 53; |
409 | 409 |
} else { |
410 | 410 |
if(rename(tempname, localname) == -1) { |
411 |
- mprintf("@Can't rename %s to %s: %s\n", tempname, localname, strerror(errno)); |
|
411 |
+ logg("^Can't rename %s to %s: %s\n", tempname, localname, strerror(errno)); |
|
412 | 412 |
if(errno == EEXIST) { |
413 | 413 |
unlink(localname); |
414 | 414 |
if(rename(tempname, localname) == -1) |
415 |
- mprintf("@All attempts to rename the temporary file failed: %s\n", strerror(errno)); |
|
415 |
+ logg("^All attempts to rename the temporary file failed: %s\n", strerror(errno)); |
|
416 | 416 |
} |
417 | 417 |
} |
418 | 418 |
} |
419 | 419 |
|
420 |
- mprintf("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
|
421 | 420 |
logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
422 | 421 |
|
423 | 422 |
if(flevel < current->fl) { |
424 |
- mprintf("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
425 |
- mprintf("WARNING: Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
426 |
- mprintf("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
|
427 |
- logg("WARNING: Your ClamAV installation is OUTDATED!\n"); |
|
428 |
- logg("WARNING: Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
423 |
+ logg("^Your ClamAV installation is OUTDATED!\n"); |
|
424 |
+ logg("^Current functionality level = %d, recommended = %d\n", flevel, current->fl); |
|
429 | 425 |
logg("DON'T PANIC! Read http://www.clamav.net/faq.html\n"); |
430 | 426 |
} |
431 | 427 |
|
... | ... |
@@ -476,20 +454,20 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char |
476 | 476 |
herr = "Unknown error"; |
477 | 477 |
break; |
478 | 478 |
} |
479 |
- mprintf("!Could not resolve local ip address '%s': %s\n", localip, herr); |
|
480 |
- mprintf("^Using standard local ip address and port for fetching.\n"); |
|
479 |
+ logg("!Could not resolve local ip address '%s': %s\n", localip, herr); |
|
480 |
+ logg("^Using standard local ip address and port for fetching.\n"); |
|
481 | 481 |
} else { |
482 | 482 |
struct sockaddr_in client; |
483 | 483 |
memset ((char *) &client, 0, sizeof(struct sockaddr_in)); |
484 | 484 |
client.sin_family = AF_INET; |
485 | 485 |
client.sin_addr = *(struct in_addr *) he->h_addr_list[0]; |
486 | 486 |
if (bind(socketfd, (struct sockaddr *) &client, sizeof(struct sockaddr_in)) != 0) { |
487 |
- mprintf("!Could not bind to local ip address '%s': %s\n", localip, strerror(errno)); |
|
488 |
- mprintf("^Using default client ip.\n"); |
|
487 |
+ logg("!Could not bind to local ip address '%s': %s\n", localip, strerror(errno)); |
|
488 |
+ logg("^Using default client ip.\n"); |
|
489 | 489 |
} else { |
490 | 490 |
ia = (unsigned char *) he->h_addr_list[0]; |
491 | 491 |
sprintf(ipaddr, "%u.%u.%u.%u", ia[0], ia[1], ia[2], ia[3]); |
492 |
- mprintf("*Using ip '%s' for fetching.\n", ipaddr); |
|
492 |
+ logg("*Using ip '%s' for fetching.\n", ipaddr); |
|
493 | 493 |
} |
494 | 494 |
} |
495 | 495 |
} |
... | ... |
@@ -539,7 +517,7 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char |
539 | 539 |
herr = "Unknown error"; |
540 | 540 |
break; |
541 | 541 |
} |
542 |
- mprintf("@Can't get information about %s: %s\n", hostpt, herr); |
|
542 |
+ logg("^Can't get information about %s: %s\n", hostpt, herr); |
|
543 | 543 |
return -1; |
544 | 544 |
} |
545 | 545 |
|
... | ... |
@@ -552,7 +530,7 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char |
552 | 552 |
strcpy(ip, ipaddr); |
553 | 553 |
|
554 | 554 |
if(i > 0) |
555 |
- mprintf("Trying host %s (%s)...\n", hostpt, ipaddr); |
|
555 |
+ logg("Trying host %s (%s)...\n", hostpt, ipaddr); |
|
556 | 556 |
|
557 | 557 |
name.sin_addr = *((struct in_addr *) host->h_addr_list[i]); |
558 | 558 |
name.sin_port = htons(port); |
... | ... |
@@ -564,7 +542,7 @@ int wwwconnect(const char *server, const char *proxy, int pport, char *ip, char |
564 | 564 |
#endif |
565 | 565 |
|
566 | 566 |
if(connect(socketfd, (struct sockaddr *) &name, sizeof(struct sockaddr_in)) == -1) { |
567 |
- mprintf("Can't connect to port %d of host %s (IP: %s)\n", port, hostpt, ipaddr); |
|
567 |
+ logg("Can't connect to port %d of host %s (IP: %s)\n", port, hostpt, ipaddr); |
|
568 | 568 |
close(socketfd); |
569 | 569 |
continue; |
570 | 570 |
} |
... | ... |
@@ -616,12 +594,12 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
616 | 616 |
} else { |
617 | 617 |
time_t mtime = 1104119530; |
618 | 618 |
Rfc2822DateTime(last_modified, mtime); |
619 |
- mprintf("*Assuming modification time in the past\n"); |
|
619 |
+ logg("*Assuming modification time in the past\n"); |
|
620 | 620 |
} |
621 | 621 |
|
622 |
- mprintf("*If-Modified-Since: %s\n", last_modified); |
|
622 |
+ logg("*If-Modified-Since: %s\n", last_modified); |
|
623 | 623 |
|
624 |
- mprintf("Reading CVD header (%s): ", file); |
|
624 |
+ logg("Reading CVD header (%s): ", file); |
|
625 | 625 |
#ifdef NO_SNPRINTF |
626 | 626 |
sprintf(cmd, "GET %s/%s HTTP/1.1\r\n" |
627 | 627 |
"Host: %s\r\n%s" |
... | ... |
@@ -653,12 +631,12 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
653 | 653 |
} |
654 | 654 |
|
655 | 655 |
if(bread == -1) { |
656 |
- mprintf("@Error while reading CVD header of database from %s\n", hostname); |
|
656 |
+ logg("^Error while reading CVD header of database from %s\n", hostname); |
|
657 | 657 |
return NULL; |
658 | 658 |
} |
659 | 659 |
|
660 | 660 |
if((strstr(buffer, "HTTP/1.1 404")) != NULL || (strstr(buffer, "HTTP/1.0 404")) != NULL) { |
661 |
- mprintf("@CVD file not found on remote server\n"); |
|
661 |
+ logg("^CVD file not found on remote server\n"); |
|
662 | 662 |
return NULL; |
663 | 663 |
} |
664 | 664 |
|
... | ... |
@@ -666,7 +644,7 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
666 | 666 |
if((strstr(buffer, "HTTP/1.1 304")) != NULL || (strstr(buffer, "HTTP/1.0 304")) != NULL) { |
667 | 667 |
|
668 | 668 |
*ims = 0; |
669 |
- mprintf("OK (IMS)\n"); |
|
669 |
+ logg("OK (IMS)\n"); |
|
670 | 670 |
return NULL; |
671 | 671 |
} else { |
672 | 672 |
*ims = 1; |
... | ... |
@@ -688,16 +666,16 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
688 | 688 |
|
689 | 689 |
for (j=0; j<512; j++) { |
690 | 690 |
if (!ch || (ch && !*ch) || (ch && !isprint(ch[j]))) { |
691 |
- mprintf("@Malformed CVD header detected.\n"); |
|
691 |
+ logg("^Malformed CVD header detected.\n"); |
|
692 | 692 |
return NULL; |
693 | 693 |
} |
694 | 694 |
head[j] = ch[j]; |
695 | 695 |
} |
696 | 696 |
|
697 | 697 |
if((cvd = cl_cvdparse(head)) == NULL) |
698 |
- mprintf("@Broken CVD header.\n"); |
|
698 |
+ logg("^Broken CVD header.\n"); |
|
699 | 699 |
else |
700 |
- mprintf("OK\n"); |
|
700 |
+ logg("OK\n"); |
|
701 | 701 |
|
702 | 702 |
return cvd; |
703 | 703 |
} |
... | ... |
@@ -736,8 +714,8 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
736 | 736 |
char currdir[512]; |
737 | 737 |
|
738 | 738 |
getcwd(currdir, sizeof(currdir)); |
739 |
- mprintf("@Can't create new file %s in %s\n", file, currdir); |
|
740 |
- mprintf("@The database directory must be writable for UID %d or GID %d\n", getuid(), getgid()); |
|
739 |
+ logg("^Can't create new file %s in %s\n", file, currdir); |
|
740 |
+ logg("^The database directory must be writable for UID %d or GID %d\n", getuid(), getgid()); |
|
741 | 741 |
return 57; |
742 | 742 |
} |
743 | 743 |
|
... | ... |
@@ -769,7 +747,7 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
769 | 769 |
/* recv one byte at a time, until we reach \r\n\r\n */ |
770 | 770 |
|
771 | 771 |
if(recv(socketfd, buffer + i, 1, 0) == -1) { |
772 |
- mprintf("@Error while reading database from %s\n", hostname); |
|
772 |
+ logg("^Error while reading database from %s\n", hostname); |
|
773 | 773 |
close(fd); |
774 | 774 |
unlink(file); |
775 | 775 |
return 52; |
... | ... |
@@ -788,7 +766,7 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
788 | 788 |
/* check whether the resource actually existed or not */ |
789 | 789 |
|
790 | 790 |
if ((strstr(buffer, "HTTP/1.1 404")) != NULL) { |
791 |
- mprintf("@%s not found on remote server\n", dbfile); |
|
791 |
+ logg("^%s not found on remote server\n", dbfile); |
|
792 | 792 |
close(fd); |
793 | 793 |
unlink(file); |
794 | 794 |
return 58; |
... | ... |
@@ -798,13 +776,13 @@ int get_database(const char *dbfile, int socketfd, const char *file, const char |
798 | 798 |
|
799 | 799 |
while((bread = read(socketfd, buffer, FILEBUFF))) { |
800 | 800 |
write(fd, buffer, bread); |
801 |
- mprintf("Downloading %s [%c]\r", dbfile, rotation[rot]); |
|
801 |
+ logg("Downloading %s [%c]\r", dbfile, rotation[rot]); |
|
802 | 802 |
fflush(stdout); |
803 | 803 |
rot++; |
804 | 804 |
rot %= 4; |
805 | 805 |
} |
806 | 806 |
|
807 |
- mprintf("Downloading %s [*]\n", dbfile); |
|
807 |
+ logg("Downloading %s [*]\n", dbfile); |
|
808 | 808 |
close(fd); |
809 | 809 |
return 0; |
810 | 810 |
} |
... | ... |
@@ -48,12 +48,12 @@ int notify(const char *cfgfile) |
48 | 48 |
|
49 | 49 |
|
50 | 50 |
if((copt = getcfg(cfgfile, 1)) == NULL) { |
51 |
- mprintf("@Clamd was NOT notified: Can't find or parse configuration file %s\n", cfgfile); |
|
51 |
+ logg("^Clamd was NOT notified: Can't find or parse configuration file %s\n", cfgfile); |
|
52 | 52 |
return 1; |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
if(cfgopt(copt, "TCPSocket")->enabled && cfgopt(copt, "LocalSocket")->enabled) { |
56 |
- mprintf("@Clamd was NOT notified: Both socket types (TCP and local) declared in %s\n", cfgfile); |
|
56 |
+ logg("^Clamd was NOT notified: Both socket types (TCP and local) declared in %s\n", cfgfile); |
|
57 | 57 |
return 1; |
58 | 58 |
} else if((cpt = cfgopt(copt, "LocalSocket"))->enabled) { |
59 | 59 |
socktype = "UNIX"; |
... | ... |
@@ -61,14 +61,14 @@ int notify(const char *cfgfile) |
61 | 61 |
strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
62 | 62 |
|
63 | 63 |
if((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
64 |
- mprintf("@Clamd was NOT notified: Can't create socket endpoint for %s\n", cpt->strarg); |
|
64 |
+ logg("^Clamd was NOT notified: Can't create socket endpoint for %s\n", cpt->strarg); |
|
65 | 65 |
perror("socket()"); |
66 | 66 |
return 1; |
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { |
70 | 70 |
close(sockd); |
71 |
- mprintf("@Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg); |
|
71 |
+ logg("^Clamd was NOT notified: Can't connect to clamd through %s\n", cpt->strarg); |
|
72 | 72 |
perror("connect()"); |
73 | 73 |
return 1; |
74 | 74 |
} |
... | ... |
@@ -81,7 +81,7 @@ int notify(const char *cfgfile) |
81 | 81 |
#else |
82 | 82 |
if((sockd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
83 | 83 |
#endif |
84 |
- mprintf("@Clamd was NOT notified: Can't create TCP socket\n"); |
|
84 |
+ logg("^Clamd was NOT notified: Can't create TCP socket\n"); |
|
85 | 85 |
perror("socket()"); |
86 | 86 |
return 1; |
87 | 87 |
} |
... | ... |
@@ -92,7 +92,7 @@ int notify(const char *cfgfile) |
92 | 92 |
if((cpt = cfgopt(copt, "TCPAddr"))->enabled) { |
93 | 93 |
if ((he = gethostbyname(cpt->strarg)) == 0) { |
94 | 94 |
perror("gethostbyname()"); |
95 |
- mprintf("@Clamd was NOT notified: Can't resolve hostname '%s'\n", cpt->strarg); |
|
95 |
+ logg("^Clamd was NOT notified: Can't resolve hostname '%s'\n", cpt->strarg); |
|
96 | 96 |
return 1; |
97 | 97 |
} |
98 | 98 |
server2.sin_addr = *(struct in_addr *) he->h_addr_list[0]; |
... | ... |
@@ -102,19 +102,19 @@ int notify(const char *cfgfile) |
102 | 102 |
|
103 | 103 |
if(connect(sockd, (struct sockaddr *) &server2, sizeof(struct sockaddr_in)) < 0) { |
104 | 104 |
close(sockd); |
105 |
- mprintf("@Clamd was NOT notified: Can't connect to clamd on %s:%d\n", |
|
105 |
+ logg("^Clamd was NOT notified: Can't connect to clamd on %s:%d\n", |
|
106 | 106 |
inet_ntoa(server2.sin_addr), ntohs(server2.sin_port)); |
107 | 107 |
perror("connect()"); |
108 | 108 |
return 1; |
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
} else { |
112 |
- mprintf("@Clamd was NOT notified: No socket specified in %s\n", cfgfile); |
|
112 |
+ logg("^Clamd was NOT notified: No socket specified in %s\n", cfgfile); |
|
113 | 113 |
return 1; |
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
if(write(sockd, "RELOAD", 6) < 0) { |
117 |
- mprintf("@Clamd was NOT notified: Could not write to %s socket\n", socktype); |
|
117 |
+ logg("^Clamd was NOT notified: Could not write to %s socket\n", socktype); |
|
118 | 118 |
perror("write()"); |
119 | 119 |
close(sockd); |
120 | 120 |
return 1; |
... | ... |
@@ -124,13 +124,12 @@ int notify(const char *cfgfile) |
124 | 124 |
memset(buff, 0, sizeof(buff)); |
125 | 125 |
if((bread = read(sockd, buff, sizeof(buff))) > 0) |
126 | 126 |
if(!strstr(buff, "RELOADING")) { |
127 |
- mprintf("@Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff); |
|
127 |
+ logg("^Clamd was NOT notified: Unknown answer from clamd: '%s'\n", buff); |
|
128 | 128 |
close(sockd); |
129 | 129 |
return 1; |
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
close(sockd); |
133 |
- mprintf("Clamd successfully notified about the update.\n"); |
|
134 | 133 |
logg("Clamd successfully notified about the update.\n"); |
135 | 134 |
return 0; |
136 | 135 |
} |
... | ... |
@@ -32,7 +32,6 @@ int freshclam(struct optstruct *opt); |
32 | 32 |
static void register_char_opt(struct optstruct *opt, char ch, struct option* longopts); |
33 | 33 |
static void register_long_opt(struct optstruct *opt, const char *optname, struct option* longopts); |
34 | 34 |
|
35 |
- |
|
36 | 35 |
int main(int argc, char **argv) |
37 | 36 |
{ |
38 | 37 |
int ret, opt_index, i, len; |
... | ... |
@@ -265,7 +264,7 @@ void free_opt(struct optstruct *opt) |
265 | 265 |
if(!opt) |
266 | 266 |
return; |
267 | 267 |
|
268 |
- mprintf("*Freeing option list..."); |
|
268 |
+ logg("*Freeing option list..."); |
|
269 | 269 |
handler = opt->optlist; |
270 | 270 |
|
271 | 271 |
while(handler != NULL) { |
... | ... |
@@ -280,5 +279,5 @@ void free_opt(struct optstruct *opt) |
280 | 280 |
if (opt->filename) |
281 | 281 |
free(opt->filename); |
282 | 282 |
free(opt); |
283 |
- mprintf("*done\n"); |
|
283 |
+ logg("*done\n"); |
|
284 | 284 |
} |
... | ... |
@@ -52,15 +52,33 @@ |
52 | 52 |
pthread_mutex_t logg_mutex = PTHREAD_MUTEX_INITIALIZER; |
53 | 53 |
#endif |
54 | 54 |
|
55 |
+#ifdef C_LINUX |
|
56 |
+#include <sys/sendfile.h> |
|
57 |
+#include <libintl.h> |
|
58 |
+#include <locale.h> |
|
59 |
+ |
|
60 |
+#define gettext_noop(s) s |
|
61 |
+#define _(s) gettext(s) |
|
62 |
+#define N_(s) gettext_noop(s) |
|
63 |
+ |
|
64 |
+#else |
|
65 |
+ |
|
66 |
+#define _(s) s |
|
67 |
+#define N_(s) s |
|
68 |
+ |
|
69 |
+#endif |
|
70 |
+ |
|
55 | 71 |
FILE *logg_fd = NULL; |
56 | 72 |
|
57 | 73 |
short int logg_verbose = 0, logg_lock = 0, logg_time = 0; |
58 | 74 |
int logg_size = 0; |
59 | 75 |
const char *logg_file = NULL; |
60 | 76 |
#if defined(USE_SYSLOG) && !defined(C_AIX) |
61 |
-short logg_syslog = 0; |
|
77 |
+short logg_syslog; |
|
62 | 78 |
#endif |
63 | 79 |
|
80 |
+short foreground; |
|
81 |
+ |
|
64 | 82 |
short int mprintf_disabled = 0, mprintf_verbose = 0, mprintf_quiet = 0, |
65 | 83 |
mprintf_stdout = 0; |
66 | 84 |
|
... | ... |
@@ -98,7 +116,7 @@ void logg_close(void) { |
98 | 98 |
|
99 | 99 |
int logg(const char *str, ...) |
100 | 100 |
{ |
101 |
- va_list args, argscpy; |
|
101 |
+ va_list args, argscpy, argsout; |
|
102 | 102 |
struct flock fl; |
103 | 103 |
char *pt, *timestr, vbuff[1025]; |
104 | 104 |
time_t currtime; |
... | ... |
@@ -109,6 +127,7 @@ int logg(const char *str, ...) |
109 | 109 |
va_start(args, str); |
110 | 110 |
/* va_copy is less portable so we just use va_start once more */ |
111 | 111 |
va_start(argscpy, str); |
112 |
+ va_start(argsout, str); |
|
112 | 113 |
|
113 | 114 |
if(logg_file) { |
114 | 115 |
#ifdef CL_THREAD_SAFE |
... | ... |
@@ -137,18 +156,6 @@ int logg(const char *str, ...) |
137 | 137 |
} |
138 | 138 |
} |
139 | 139 |
|
140 |
- /* Need to avoid logging time for verbose messages when logverbose |
|
141 |
- is not set or we get a bunch of timestamps in the log without |
|
142 |
- newlines... */ |
|
143 |
- if(logg_time && ((*str != '*') || logg_verbose)) { |
|
144 |
- time(&currtime); |
|
145 |
- pt = ctime(&currtime); |
|
146 |
- timestr = mcalloc(strlen(pt), sizeof(char)); |
|
147 |
- strncpy(timestr, pt, strlen(pt) - 1); |
|
148 |
- fprintf(logg_fd, "%s -> ", timestr); |
|
149 |
- free(timestr); |
|
150 |
- } |
|
151 |
- |
|
152 | 140 |
if(logg_size) { |
153 | 141 |
if(stat(logg_file, &sb) != -1) { |
154 | 142 |
if(sb.st_size > logg_size) { |
... | ... |
@@ -160,12 +167,23 @@ int logg(const char *str, ...) |
160 | 160 |
#ifdef CL_THREAD_SAFE |
161 | 161 |
pthread_mutex_unlock(&logg_mutex); |
162 | 162 |
#endif |
163 |
- return 0; |
|
164 | 163 |
} |
165 | 164 |
} |
166 | 165 |
} |
167 | 166 |
|
167 |
+ /* Need to avoid logging time for verbose messages when logverbose |
|
168 |
+ is not set or we get a bunch of timestamps in the log without |
|
169 |
+ newlines... */ |
|
170 |
+ if(logg_time && ((*str != '*') || logg_verbose)) { |
|
171 |
+ time(&currtime); |
|
172 |
+ pt = ctime(&currtime); |
|
173 |
+ timestr = mcalloc(strlen(pt), sizeof(char)); |
|
174 |
+ strncpy(timestr, pt, strlen(pt) - 1); |
|
175 |
+ fprintf(logg_fd, "%s -> ", timestr); |
|
176 |
+ free(timestr); |
|
177 |
+ } |
|
168 | 178 |
|
179 |
+ _(str); |
|
169 | 180 |
if(*str == '!') { |
170 | 181 |
fprintf(logg_fd, "ERROR: "); |
171 | 182 |
vfprintf(logg_fd, str + 1, args); |
... | ... |
@@ -194,6 +212,7 @@ int logg(const char *str, ...) |
194 | 194 |
* |
195 | 195 |
* FIXME: substitute %% instead of _ |
196 | 196 |
*/ |
197 |
+ _(str); |
|
197 | 198 |
vsnprintf(vbuff, 1024, str, argscpy); |
198 | 199 |
vbuff[1024] = 0; |
199 | 200 |
|
... | ... |
@@ -213,31 +232,26 @@ int logg(const char *str, ...) |
213 | 213 |
} |
214 | 214 |
#endif |
215 | 215 |
|
216 |
+ if(foreground) { |
|
217 |
+ _(str); |
|
218 |
+ vsnprintf(vbuff, 1024, str, argsout); |
|
219 |
+ mprintf(vbuff, str); |
|
220 |
+ } |
|
221 |
+ |
|
216 | 222 |
va_end(args); |
217 | 223 |
va_end(argscpy); |
224 |
+ va_end(argsout); |
|
218 | 225 |
return 0; |
219 | 226 |
} |
220 | 227 |
|
221 | 228 |
void mprintf(const char *str, ...) |
222 | 229 |
{ |
223 |
- va_list args, argscpy; |
|
230 |
+ va_list args; |
|
224 | 231 |
FILE *fd; |
225 |
- char logbuf[512]; |
|
226 | 232 |
|
227 | 233 |
|
228 |
- if(mprintf_disabled) { |
|
229 |
- if(*str == '@') { |
|
230 |
- va_start(args, str); |
|
231 |
-#ifdef NO_SNPRINTF |
|
232 |
- vsprintf(logbuf, ++str, args); |
|
233 |
-#else |
|
234 |
- vsnprintf(logbuf, sizeof(logbuf), ++str, args); |
|
235 |
-#endif |
|
236 |
- va_end(args); |
|
237 |
- logg("ERROR: %s", logbuf); |
|
238 |
- } |
|
234 |
+ if(mprintf_disabled) |
|
239 | 235 |
return; |
240 |
- } |
|
241 | 236 |
|
242 | 237 |
fd = stdout; |
243 | 238 |
|
... | ... |
@@ -258,8 +272,6 @@ void mprintf(const char *str, ...) |
258 | 258 |
|
259 | 259 |
|
260 | 260 |
va_start(args, str); |
261 |
- /* va_copy is less portable so we just use va_start once more */ |
|
262 |
- va_start(argscpy, str); |
|
263 | 261 |
|
264 | 262 |
if(*str == '!') { |
265 | 263 |
if(!mprintf_stdout) |
... | ... |
@@ -271,12 +283,6 @@ void mprintf(const char *str, ...) |
271 | 271 |
fd = stderr; |
272 | 272 |
fprintf(fd, "ERROR: "); |
273 | 273 |
vfprintf(fd, ++str, args); |
274 |
-#ifdef NO_SNPRINTF |
|
275 |
- vsprintf(logbuf, str, argscpy); |
|
276 |
-#else |
|
277 |
- vsnprintf(logbuf, sizeof(logbuf), str, argscpy); |
|
278 |
-#endif |
|
279 |
- logg("ERROR: %s", logbuf); |
|
280 | 274 |
} else if(!mprintf_quiet) { |
281 | 275 |
if(*str == '^') { |
282 | 276 |
if(!mprintf_stdout) |
... | ... |
@@ -290,7 +296,6 @@ void mprintf(const char *str, ...) |
290 | 290 |
} |
291 | 291 |
|
292 | 292 |
va_end(args); |
293 |
- va_end(argscpy); |
|
294 | 293 |
|
295 | 294 |
if(fd == stdout) |
296 | 295 |
fflush(stdout); |
... | ... |
@@ -34,6 +34,8 @@ |
34 | 34 |
|
35 | 35 |
void sigtool(struct optstruct *opt); |
36 | 36 |
|
37 |
+short foreground = 1; |
|
38 |
+ |
|
37 | 39 |
int main(int argc, char **argv) |
38 | 40 |
{ |
39 | 41 |
int ret, opt_index, i, len; |
... | ... |
@@ -89,7 +91,7 @@ int main(int argc, char **argv) |
89 | 89 |
register_char_option(opt, ret, NULL); |
90 | 90 |
|
91 | 91 |
} else { |
92 |
- mprintf("!Unknown option passed.\n"); |
|
92 |
+ logg("!Unknown option passed.\n"); |
|
93 | 93 |
free_opt(opt); |
94 | 94 |
exit(40); |
95 | 95 |
} |
... | ... |
@@ -114,15 +114,15 @@ void sigtool(struct optstruct *opt) |
114 | 114 |
|
115 | 115 |
for(i = 0; (filename = cli_strtok(opt->filename, i, "\t")); i++) { |
116 | 116 |
if(stat(filename, &sb) == -1) { |
117 |
- mprintf("!Can't access file %s\n", filename); |
|
117 |
+ logg("!Can't access file %s\n", filename); |
|
118 | 118 |
perror(filename); |
119 | 119 |
} else { |
120 | 120 |
if((sb.st_mode & S_IFMT) == S_IFREG) { |
121 | 121 |
if((md5 = cli_md5file(filename))) { |
122 |
- mprintf("%s:%d:%s\n", md5, sb.st_size, filename); |
|
122 |
+ logg("%s:%d:%s\n", md5, sb.st_size, filename); |
|
123 | 123 |
free(md5); |
124 | 124 |
} else |
125 |
- mprintf("!Can't generate MD5 checksum for %s\n", filename); |
|
125 |
+ logg("!Can't generate MD5 checksum for %s\n", filename); |
|
126 | 126 |
} |
127 | 127 |
} |
128 | 128 |
|
... | ... |
@@ -132,7 +132,7 @@ void sigtool(struct optstruct *opt) |
132 | 132 |
} else { |
133 | 133 |
|
134 | 134 |
md5 = cli_md5stream(stdin, NULL); |
135 |
- mprintf("%s\n", md5); |
|
135 |
+ logg("%s\n", md5); |
|
136 | 136 |
free(md5); |
137 | 137 |
} |
138 | 138 |
|
... | ... |
@@ -140,7 +140,7 @@ void sigtool(struct optstruct *opt) |
140 | 140 |
int fd; |
141 | 141 |
|
142 | 142 |
if((fd = open(getargl(opt, "html-normalise"), O_RDONLY)) == -1) { |
143 |
- mprintf("Can't open file %s\n", getargl(opt, "html-normalise")); |
|
143 |
+ logg("Can't open file %s\n", getargl(opt, "html-normalise")); |
|
144 | 144 |
exit(1); |
145 | 145 |
} |
146 | 146 |
|
... | ... |
@@ -150,7 +150,7 @@ void sigtool(struct optstruct *opt) |
150 | 150 |
|
151 | 151 |
} else if(optc(opt, 'b')) { |
152 | 152 |
if(!optl(opt, "server")) { |
153 |
- mprintf("!--server is required in this mode\n"); |
|
153 |
+ logg("!--server is required in this mode\n"); |
|
154 | 154 |
exit(10); |
155 | 155 |
} |
156 | 156 |
|
... | ... |
@@ -183,13 +183,13 @@ void sigtool(struct optstruct *opt) |
183 | 183 |
/* generate the temporary directory */ |
184 | 184 |
dir = cli_gentemp(NULL); |
185 | 185 |
if(mkdir(dir, 0700)) { |
186 |
- mprintf("vba dump: Can't create temporary directory %s\n", dir); |
|
186 |
+ logg("vba dump: Can't create temporary directory %s\n", dir); |
|
187 | 187 |
return; |
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
if((fd = open(getargl(opt, "vba"), O_RDONLY)) == -1) { |
191 | 191 |
if((fd = open(getargl(opt, "vba-hex"), O_RDONLY)) == -1) { |
192 |
- mprintf("Can't open file %s\n", getargl(opt, "vba")); |
|
192 |
+ logg("Can't open file %s\n", getargl(opt, "vba")); |
|
193 | 193 |
exit(1); |
194 | 194 |
} |
195 | 195 |
} |
... | ... |
@@ -247,35 +247,35 @@ int build(struct optstruct *opt) |
247 | 247 |
|
248 | 248 |
|
249 | 249 |
if(stat("COPYING", &foo) == -1) { |
250 |
- mprintf("COPYING file not found in current working directory.\n"); |
|
250 |
+ logg("COPYING file not found in current working directory.\n"); |
|
251 | 251 |
exit(1); |
252 | 252 |
} |
253 | 253 |
|
254 | 254 |
if(stat("main.db", &foo) == -1 && stat("daily.db", &foo) == -1 && stat("main.hdb", &foo) == -1 && stat("daily.hdb", &foo) == -1 && stat("main.ndb", &foo) == -1 && stat("daily.ndb", &foo) == -1 && stat("main.zmd", &foo) == -1 && stat("main.rmd", &foo) == -1 && stat("daily.zmd", &foo) == -1 && stat("daily.rmd", &foo) == -1) { |
255 |
- mprintf("Virus database not found in current working directory.\n"); |
|
255 |
+ logg("Virus database not found in current working directory.\n"); |
|
256 | 256 |
exit(1); |
257 | 257 |
} |
258 | 258 |
|
259 | 259 |
cl_debug(); /* enable debug messages */ |
260 | 260 |
|
261 | 261 |
if((ret = cl_loaddbdir(".", &root, &no))) { |
262 |
- mprintf("!Can't load database: %s\n", cl_strerror(ret)); |
|
262 |
+ logg("!Can't load database: %s\n", cl_strerror(ret)); |
|
263 | 263 |
exit(1); |
264 | 264 |
} |
265 | 265 |
|
266 | 266 |
cl_free(root); |
267 | 267 |
|
268 |
- mprintf("Database properly parsed.\n"); |
|
268 |
+ logg("Database properly parsed.\n"); |
|
269 | 269 |
|
270 | 270 |
if(!no) { |
271 |
- mprintf("WARNING: There are no signatures in the database(s).\n"); |
|
271 |
+ logg("^There are no signatures in the database(s).\n"); |
|
272 | 272 |
} else { |
273 |
- mprintf("Signatures: %d\n", no); |
|
273 |
+ logg("Signatures: %d\n", no); |
|
274 | 274 |
realno = countlines("main.db") + countlines("daily.db") + countlines("main.hdb") + countlines("daily.hdb") + countlines("main.ndb") + countlines("daily.ndb") + countlines("main.zmd") + countlines("daily.zmd") + countlines("main.rmd") + countlines("daily.rmd") + countlines("main.fp") + countlines("daily.fp"); |
275 | 275 |
if(realno != no) { |
276 |
- mprintf("!Signatures in database: %d. Loaded: %d.\n", realno, no); |
|
277 |
- mprintf("Please check the current directory and remove unnecessary databases\n"); |
|
278 |
- mprintf("or install the latest ClamAV version.\n"); |
|
276 |
+ logg("!Signatures in database: %d. Loaded: %d.\n", realno, no); |
|
277 |
+ logg("Please check the current directory and remove unnecessary databases\n"); |
|
278 |
+ logg("or install the latest ClamAV version.\n"); |
|
279 | 279 |
exit(1); |
280 | 280 |
} |
281 | 281 |
} |
... | ... |
@@ -284,14 +284,14 @@ int build(struct optstruct *opt) |
284 | 284 |
|
285 | 285 |
switch(fork()) { |
286 | 286 |
case -1: |
287 |
- mprintf("!Can't fork.\n"); |
|
287 |
+ logg("!Can't fork.\n"); |
|
288 | 288 |
exit(1); |
289 | 289 |
case 0: |
290 | 290 |
{ |
291 | 291 |
char *args[] = { "tar", "-cvf", NULL, "COPYING", "main.db", "daily.db", "Notes", "viruses.db3", "main.hdb", "daily.hdb", "main.ndb", "daily.ndb", "main.zmd", "daily.zmd", "main.rmd", "daily.rmd", "main.fp", "daily.fp", NULL }; |
292 | 292 |
args[2] = tarfile; |
293 | 293 |
execv("/bin/tar", args); |
294 |
- mprintf("!Can't execute tar\n"); |
|
294 |
+ logg("!Can't execute tar\n"); |
|
295 | 295 |
perror("tar"); |
296 | 296 |
exit(1); |
297 | 297 |
} |
... | ... |
@@ -300,18 +300,18 @@ int build(struct optstruct *opt) |
300 | 300 |
} |
301 | 301 |
|
302 | 302 |
if(stat(tarfile, &foo) == -1) { |
303 |
- mprintf("!Can't generate tar file.\n"); |
|
303 |
+ logg("!Can't generate tar file.\n"); |
|
304 | 304 |
exit(1); |
305 | 305 |
} |
306 | 306 |
|
307 | 307 |
if((tar = fopen(tarfile, "rb")) == NULL) { |
308 |
- mprintf("!Can't open file %s\n", tarfile); |
|
308 |
+ logg("!Can't open file %s\n", tarfile); |
|
309 | 309 |
exit(1); |
310 | 310 |
} |
311 | 311 |
|
312 | 312 |
gzfile = cli_gentemp("."); |
313 | 313 |
if((gz = gzopen(gzfile, "wb")) == NULL) { |
314 |
- mprintf("!Can't open file %s to write.\n", gzfile); |
|
314 |
+ logg("!Can't open file %s to write.\n", gzfile); |
|
315 | 315 |
exit(1); |
316 | 316 |
} |
317 | 317 |
|
... | ... |
@@ -330,7 +330,7 @@ int build(struct optstruct *opt) |
330 | 330 |
sprintf(buffer, "%s/%s", dbdir, getargc(opt, 'b')); |
331 | 331 |
free(dbdir); |
332 | 332 |
if((oldcvd = cl_cvdhead(buffer)) == NULL) |
333 |
- mprintf("WARNING: CAN'T READ CVD HEADER OF CURRENT DATABASE %s\n", buffer); |
|
333 |
+ logg("^CAN'T READ CVD HEADER OF CURRENT DATABASE %s\n", buffer); |
|
334 | 334 |
|
335 | 335 |
/* generate header */ |
336 | 336 |
|
... | ... |
@@ -354,7 +354,7 @@ int build(struct optstruct *opt) |
354 | 354 |
sprintf(smbuff, ":%d:", oldcvd->version + 1); |
355 | 355 |
} else { |
356 | 356 |
fflush(stdin); |
357 |
- mprintf("Version number: "); |
|
357 |
+ logg("Version number: "); |
|
358 | 358 |
scanf("%d", &itmp); |
359 | 359 |
sprintf(smbuff, "%d:", itmp); |
360 | 360 |
} |
... | ... |
@@ -376,7 +376,7 @@ int build(struct optstruct *opt) |
376 | 376 |
|
377 | 377 |
/* ask for builder name */ |
378 | 378 |
fflush(stdin); |
379 |
- mprintf("Builder id: "); |
|
379 |
+ logg("Builder id: "); |
|
380 | 380 |
fscanf(stdin, "%s", smbuff); |
381 | 381 |
|
382 | 382 |
/* digital signature */ |
... | ... |
@@ -385,7 +385,7 @@ int build(struct optstruct *opt) |
385 | 385 |
fclose(fd); |
386 | 386 |
free(pt); |
387 | 387 |
if(!(pt = getdsig(getargl(opt, "server"), smbuff, buffer))) { |
388 |
- mprintf("No digital signature - no CVD file...\n"); |
|
388 |
+ logg("No digital signature - no CVD file...\n"); |
|
389 | 389 |
unlink(gzfile); |
390 | 390 |
exit(1); |
391 | 391 |
} |
... | ... |
@@ -409,7 +409,7 @@ int build(struct optstruct *opt) |
409 | 409 |
|
410 | 410 |
pt = getargc(opt, 'b'); |
411 | 411 |
if((cvd = fopen(pt, "wb")) == NULL) { |
412 |
- mprintf("!Can't write the final database %s\n", pt); |
|
412 |
+ logg("!Can't write the final database %s\n", pt); |
|
413 | 413 |
unlink(gzfile); |
414 | 414 |
exit(1); |
415 | 415 |
} |
... | ... |
@@ -417,7 +417,7 @@ int build(struct optstruct *opt) |
417 | 417 |
fwrite(header, 1, 512, cvd); |
418 | 418 |
|
419 | 419 |
if((tar = fopen(gzfile, "rb")) == NULL) { |
420 |
- mprintf("!Can't open file %s for reading.\n", gzfile); |
|
420 |
+ logg("!Can't open file %s for reading.\n", gzfile); |
|
421 | 421 |
exit(1); |
422 | 422 |
} |
423 | 423 |
|
... | ... |
@@ -430,7 +430,7 @@ int build(struct optstruct *opt) |
430 | 430 |
unlink(gzfile); |
431 | 431 |
free(gzfile); |
432 | 432 |
|
433 |
- mprintf("Database %s created.\n", pt); |
|
433 |
+ logg("Database %s created.\n", pt); |
|
434 | 434 |
|
435 | 435 |
/* try to load final cvd */ |
436 | 436 |
return 0; |
... | ... |
@@ -444,27 +444,27 @@ void cvdinfo(struct optstruct *opt) |
444 | 444 |
|
445 | 445 |
pt = getargc(opt, 'i'); |
446 | 446 |
if((cvd = cl_cvdhead(pt)) == NULL) { |
447 |
- mprintf("!Can't read/parse CVD header from %s\n", pt); |
|
447 |
+ logg("!Can't read/parse CVD header from %s\n", pt); |
|
448 | 448 |
exit(1); |
449 | 449 |
} |
450 | 450 |
|
451 |
- mprintf("Build time: %s\n", cvd->time); |
|
452 |
- mprintf("Version: %d\n", cvd->version); |
|
453 |
- mprintf("# of signatures: %d\n", cvd->sigs); |
|
454 |
- mprintf("Functionality level: %d\n", cvd->fl); |
|
455 |
- mprintf("Builder: %s\n", cvd->builder); |
|
456 |
- mprintf("MD5: %s\n", cvd->md5); |
|
451 |
+ logg("Build time: %s\n", cvd->time); |
|
452 |
+ logg("Version: %d\n", cvd->version); |
|
453 |
+ logg("# of signatures: %d\n", cvd->sigs); |
|
454 |
+ logg("Functionality level: %d\n", cvd->fl); |
|
455 |
+ logg("Builder: %s\n", cvd->builder); |
|
456 |
+ logg("MD5: %s\n", cvd->md5); |
|
457 | 457 |
|
458 |
- mprintf("Digital signature: %s\n", cvd->dsig); |
|
458 |
+ logg("Digital signature: %s\n", cvd->dsig); |
|
459 | 459 |
|
460 | 460 |
#ifndef HAVE_GMP |
461 |
- mprintf("Digital signature support not compiled in.\n"); |
|
461 |
+ logg("Digital signature support not compiled in.\n"); |
|
462 | 462 |
#endif |
463 | 463 |
|
464 | 464 |
if((ret = cl_cvdverify(pt))) |
465 |
- mprintf("!Verification: %s\n", cl_strerror(ret)); |
|
465 |
+ logg("!Verification: %s\n", cl_strerror(ret)); |
|
466 | 466 |
else |
467 |
- mprintf("Verification OK.\n"); |
|
467 |
+ logg("Verification OK.\n"); |
|
468 | 468 |
|
469 | 469 |
/* free */ |
470 | 470 |
} |
... | ... |
@@ -482,7 +482,7 @@ char *getdsig(const char *host, const char *user, const char *data) |
482 | 482 |
if((sockd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
483 | 483 |
#endif |
484 | 484 |
perror("socket()"); |
485 |
- mprintf("!Can't create the socket.\n"); |
|
485 |
+ logg("!Can't create the socket.\n"); |
|
486 | 486 |
return NULL; |
487 | 487 |
} |
488 | 488 |
|
... | ... |
@@ -493,7 +493,7 @@ char *getdsig(const char *host, const char *user, const char *data) |
493 | 493 |
if(connect(sockd, (struct sockaddr *) &server, sizeof(struct sockaddr_in)) < 0) { |
494 | 494 |
close(sockd); |
495 | 495 |
perror("connect()"); |
496 |
- mprintf("!Can't connect to ClamAV Signing Service at %s.\n", host); |
|
496 |
+ logg("!Can't connect to ClamAV Signing Service at %s.\n", host); |
|
497 | 497 |
return NULL; |
498 | 498 |
} |
499 | 499 |
|
... | ... |
@@ -507,7 +507,7 @@ char *getdsig(const char *host, const char *user, const char *data) |
507 | 507 |
len += 16; |
508 | 508 |
|
509 | 509 |
if(write(sockd, cmd, len) < 0) { |
510 |
- mprintf("!Can't write to the socket.\n"); |
|
510 |
+ logg("!Can't write to the socket.\n"); |
|
511 | 511 |
close(sockd); |
512 | 512 |
memset(cmd, 0, len); |
513 | 513 |
memset(pass, 0, strlen(pass)); |
... | ... |
@@ -520,12 +520,12 @@ char *getdsig(const char *host, const char *user, const char *data) |
520 | 520 |
memset(buff, 0, sizeof(buff)); |
521 | 521 |
if((bread = read(sockd, buff, sizeof(buff))) > 0) { |
522 | 522 |
if(!strstr(buff, "Signature:")) { |
523 |
- mprintf("!Signature generation error.\n"); |
|
524 |
- mprintf("ClamAV SDaemon: %s.\n", buff); |
|
523 |
+ logg("!Signature generation error.\n"); |
|
524 |
+ logg("ClamAV SDaemon: %s.\n", buff); |
|
525 | 525 |
close(sockd); |
526 | 526 |
return NULL; |
527 | 527 |
} else { |
528 |
- mprintf("Signature received (length = %d).\n", strlen(buff) - 10); |
|
528 |
+ logg("Signature received (length = %d).\n", strlen(buff) - 10); |
|
529 | 529 |
} |
530 | 530 |
} |
531 | 531 |
|
... | ... |
@@ -549,7 +549,7 @@ int unpack(struct optstruct *opt) |
549 | 549 |
name = strdup(getargc(opt, 'u')); |
550 | 550 |
|
551 | 551 |
if((fd = open(name, O_RDONLY|O_BINARY)) == -1) { |
552 |
- mprintf("!Can't open CVD file %s\n", name); |
|
552 |
+ logg("!Can't open CVD file %s\n", name); |
|
553 | 553 |
free(name); |
554 | 554 |
exit(1); |
555 | 555 |
} |
... | ... |
@@ -558,7 +558,7 @@ int unpack(struct optstruct *opt) |
558 | 558 |
lseek(fd, 512, SEEK_SET); |
559 | 559 |
|
560 | 560 |
if(cli_untgz(fd, ".")) { |
561 |
- mprintf("!Can't unpack file.\n"); |
|
561 |
+ logg("!Can't unpack file.\n"); |
|
562 | 562 |
close(fd); |
563 | 563 |
exit(1); |
564 | 564 |
} |
... | ... |
@@ -576,12 +576,12 @@ int listdb(const char *filename) |
576 | 576 |
|
577 | 577 |
|
578 | 578 |
if((fd = fopen(filename, "rb")) == NULL) { |
579 |
- mprintf("!listdb(): Can't open file %s\n", filename); |
|
579 |
+ logg("!listdb(): Can't open file %s\n", filename); |
|
580 | 580 |
return -1; |
581 | 581 |
} |
582 | 582 |
|
583 | 583 |
if(!(buffer = (char *) mmalloc(FILEBUFF))) { |
584 |
- mprintf("!listdb(): Can't allocate memory.\n"); |
|
584 |
+ logg("!listdb(): Can't allocate memory.\n"); |
|
585 | 585 |
fclose(fd); |
586 | 586 |
return -1; |
587 | 587 |
} |
... | ... |
@@ -605,7 +605,7 @@ int listdb(const char *filename) |
605 | 605 |
|
606 | 606 |
dir = cli_gentemp(tmpdir); |
607 | 607 |
if(mkdir(dir, 0700)) { |
608 |
- mprintf("!listdb(): Can't create temporary directory %s\n", dir); |
|
608 |
+ logg("!listdb(): Can't create temporary directory %s\n", dir); |
|
609 | 609 |
free(buffer); |
610 | 610 |
fclose(fd); |
611 | 611 |
return -1; |
... | ... |
@@ -619,7 +619,7 @@ int listdb(const char *filename) |
619 | 619 |
|
620 | 620 |
tmp = cli_gentemp(tmpdir); |
621 | 621 |
if((tmpd = fopen(tmp, "wb+")) == NULL) { |
622 |
- mprintf("!listdb(): Can't create temporary file %s\n", tmp); |
|
622 |
+ logg("!listdb(): Can't create temporary file %s\n", tmp); |
|
623 | 623 |
free(dir); |
624 | 624 |
free(tmp); |
625 | 625 |
free(buffer); |
... | ... |
@@ -637,7 +637,7 @@ int listdb(const char *filename) |
637 | 637 |
fseek(tmpd, 0L, SEEK_SET); |
638 | 638 |
|
639 | 639 |
if(cli_untgz(fileno(tmpd), dir)) { |
640 |
- mprintf("!listdb(): Can't unpack CVD file.\n"); |
|
640 |
+ logg("!listdb(): Can't unpack CVD file.\n"); |
|
641 | 641 |
cli_rmdirs(dir); |
642 | 642 |
free(dir); |
643 | 643 |
fclose(tmpd); |
... | ... |
@@ -669,7 +669,7 @@ int listdb(const char *filename) |
669 | 669 |
line++; |
670 | 670 |
pt = strchr(buffer, '='); |
671 | 671 |
if(!pt) { |
672 |
- mprintf("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
672 |
+ logg("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
673 | 673 |
fclose(fd); |
674 | 674 |
free(buffer); |
675 | 675 |
return -1; |
... | ... |
@@ -681,7 +681,7 @@ int listdb(const char *filename) |
681 | 681 |
if((pt = strstr(start, " (Clam)"))) |
682 | 682 |
*pt = 0; |
683 | 683 |
|
684 |
- mprintf("%s\n", start); |
|
684 |
+ logg("%s\n", start); |
|
685 | 685 |
} |
686 | 686 |
|
687 | 687 |
} else if(cli_strbcasestr(filename, ".hdb")) { |
... | ... |
@@ -692,7 +692,7 @@ int listdb(const char *filename) |
692 | 692 |
start = cli_strtok(buffer, 2, ":"); |
693 | 693 |
|
694 | 694 |
if(!start) { |
695 |
- mprintf("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
695 |
+ logg("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
696 | 696 |
fclose(fd); |
697 | 697 |
free(buffer); |
698 | 698 |
return -1; |
... | ... |
@@ -701,7 +701,7 @@ int listdb(const char *filename) |
701 | 701 |
if((pt = strstr(start, " (Clam)"))) |
702 | 702 |
*pt = 0; |
703 | 703 |
|
704 |
- mprintf("%s\n", start); |
|
704 |
+ logg("%s\n", start); |
|
705 | 705 |
free(start); |
706 | 706 |
} |
707 | 707 |
|
... | ... |
@@ -713,7 +713,7 @@ int listdb(const char *filename) |
713 | 713 |
start = cli_strtok(buffer, 0, ":"); |
714 | 714 |
|
715 | 715 |
if(!start) { |
716 |
- mprintf("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
716 |
+ logg("!listdb(): Malformed pattern line %d (file %s).\n", line, filename); |
|
717 | 717 |
fclose(fd); |
718 | 718 |
free(buffer); |
719 | 719 |
return -1; |
... | ... |
@@ -722,7 +722,7 @@ int listdb(const char *filename) |
722 | 722 |
if((pt = strstr(start, " (Clam)"))) |
723 | 723 |
*pt = 0; |
724 | 724 |
|
725 |
- mprintf("%s\n", start); |
|
725 |
+ logg("%s\n", start); |
|
726 | 726 |
free(start); |
727 | 727 |
} |
728 | 728 |
} |
... | ... |
@@ -740,7 +740,7 @@ int listdir(const char *dirname) |
740 | 740 |
|
741 | 741 |
|
742 | 742 |
if((dd = opendir(dirname)) == NULL) { |
743 |
- mprintf("!Can't open directory %s\n", dirname); |
|
743 |
+ logg("!Can't open directory %s\n", dirname); |
|
744 | 744 |
return -1; |
745 | 745 |
} |
746 | 746 |
|
... | ... |
@@ -761,14 +761,14 @@ int listdir(const char *dirname) |
761 | 761 |
dbfile = (char *) mcalloc(strlen(dent->d_name) + strlen(dirname) + 2, sizeof(char)); |
762 | 762 |
|
763 | 763 |
if(!dbfile) { |
764 |
- mprintf("!listdir(): Can't allocate memory.\n"); |
|
764 |
+ logg("!listdir(): Can't allocate memory.\n"); |
|
765 | 765 |
closedir(dd); |
766 | 766 |
return -1; |
767 | 767 |
} |
768 | 768 |
sprintf(dbfile, "%s/%s", dirname, dent->d_name); |
769 | 769 |
|
770 | 770 |
if(listdb(dbfile)) { |
771 |
- mprintf("!listdb(): error listing database %s\n", dbfile); |
|
771 |
+ logg("!listdb(): error listing database %s\n", dbfile); |
|
772 | 772 |
free(dbfile); |
773 | 773 |
closedir(dd); |
774 | 774 |
return -1; |
... | ... |
@@ -164,11 +164,11 @@ void output_token (unsigned char token) |
164 | 164 |
|
165 | 165 |
for (i = 0; mac_token[i].token != 0x00; i++) { |
166 | 166 |
if (token == mac_token[i].token) { |
167 |
- printf (" %s ", mac_token[i].str); |
|
167 |
+ logg (" %s ", mac_token[i].str); |
|
168 | 168 |
return; |
169 | 169 |
} |
170 | 170 |
} |
171 |
- printf ("[#0x%x]", token); |
|
171 |
+ logg ("[#0x%x]", token); |
|
172 | 172 |
return; |
173 | 173 |
} |
174 | 174 |
|
... | ... |
@@ -514,11 +514,11 @@ void output_token67 (uint16_t token) |
514 | 514 |
}; |
515 | 515 |
for (i = 0; mac_token[i].token != 0x0000; i++) { |
516 | 516 |
if (token == mac_token[i].token) { |
517 |
- printf ("%s", mac_token[i].str); |
|
517 |
+ logg ("%s", mac_token[i].str); |
|
518 | 518 |
return; |
519 | 519 |
} |
520 | 520 |
} |
521 |
- printf ("[#67(0x%x)]", token); |
|
521 |
+ logg ("[#67(0x%x)]", token); |
|
522 | 522 |
return; |
523 | 523 |
} |
524 | 524 |
|
... | ... |
@@ -765,11 +765,11 @@ void output_token73 (uint16_t token) |
765 | 765 |
|
766 | 766 |
for (i = 0; mac_token[i].token != 0x0000; i++) { |
767 | 767 |
if (token == mac_token[i].token) { |
768 |
- printf ("%s", mac_token[i].str); |
|
768 |
+ logg ("%s", mac_token[i].str); |
|
769 | 769 |
return; |
770 | 770 |
} |
771 | 771 |
} |
772 |
- printf ("[#73(0x%x)]", token); |
|
772 |
+ logg ("[#73(0x%x)]", token); |
|
773 | 773 |
return; |
774 | 774 |
} |
775 | 775 |
|
... | ... |
@@ -778,12 +778,12 @@ void print_hex_buff (unsigned char *start, unsigned char *end, int hex_output) |
778 | 778 |
if (!hex_output) { |
779 | 779 |
return; |
780 | 780 |
} |
781 |
- printf ("[clam hex:"); |
|
781 |
+ logg ("[clam hex:"); |
|
782 | 782 |
while (start < end) { |
783 |
- printf (" %.2x", *start); |
|
783 |
+ logg (" %.2x", *start); |
|
784 | 784 |
start++; |
785 | 785 |
} |
786 |
- printf ("]\n"); |
|
786 |
+ logg ("]\n"); |
|
787 | 787 |
} |
788 | 788 |
|
789 | 789 |
void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
... | ... |
@@ -803,7 +803,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
803 | 803 |
strncpy (tmp_buff, buff + i + 2, s_length); |
804 | 804 |
tmp_buff[s_length] = '\0'; |
805 | 805 |
print_hex_buff (line_start, buff + i + 2 + s_length, hex_output); |
806 |
- printf ("\n%s", tmp_buff); |
|
806 |
+ logg ("\n%s", tmp_buff); |
|
807 | 807 |
free (tmp_buff); |
808 | 808 |
i += 2 + s_length; |
809 | 809 |
line_start = buff + i; |
... | ... |
@@ -813,7 +813,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
813 | 813 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
814 | 814 |
strncpy (tmp_buff, buff + i + 2, s_length); |
815 | 815 |
tmp_buff[s_length] = '\0'; |
816 |
- printf (" %s", tmp_buff); |
|
816 |
+ logg (" %s", tmp_buff); |
|
817 | 817 |
free (tmp_buff); |
818 | 818 |
i += 2 + s_length; |
819 | 819 |
break; |
... | ... |
@@ -822,7 +822,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
822 | 822 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
823 | 823 |
strncpy (tmp_buff, buff + i + 2, s_length); |
824 | 824 |
tmp_buff[s_length] = '\0'; |
825 |
- printf (" \"%s\"", tmp_buff); |
|
825 |
+ logg (" \"%s\"", tmp_buff); |
|
826 | 826 |
free (tmp_buff); |
827 | 827 |
i += 2 + s_length; |
828 | 828 |
break; |
... | ... |
@@ -831,7 +831,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
831 | 831 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
832 | 832 |
strncpy (tmp_buff, buff + i + 2, s_length); |
833 | 833 |
tmp_buff[s_length] = '\0'; |
834 |
- printf (" '%s", tmp_buff); |
|
834 |
+ logg (" '%s", tmp_buff); |
|
835 | 835 |
free (tmp_buff); |
836 | 836 |
i += 2 + s_length; |
837 | 837 |
break; |
... | ... |
@@ -840,7 +840,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
840 | 840 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
841 | 841 |
strncpy (tmp_buff, buff + i + 2, s_length); |
842 | 842 |
tmp_buff[s_length] = '\0'; |
843 |
- printf (" %s", tmp_buff); |
|
843 |
+ logg (" %s", tmp_buff); |
|
844 | 844 |
free (tmp_buff); |
845 | 845 |
i += 2 + s_length; |
846 | 846 |
break; |
... | ... |
@@ -849,7 +849,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
849 | 849 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
850 | 850 |
strncpy (tmp_buff, buff + i + 2, s_length); |
851 | 851 |
tmp_buff[s_length] = '\0'; |
852 |
- printf ("REM%s", tmp_buff); |
|
852 |
+ logg ("REM%s", tmp_buff); |
|
853 | 853 |
free (tmp_buff); |
854 | 854 |
i += 2 + s_length; |
855 | 855 |
break; |
... | ... |
@@ -858,7 +858,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
858 | 858 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
859 | 859 |
strncpy (tmp_buff, buff + i + 2, s_length); |
860 | 860 |
tmp_buff[s_length] = '\0'; |
861 |
- printf (" .%s", tmp_buff); |
|
861 |
+ logg (" .%s", tmp_buff); |
|
862 | 862 |
free (tmp_buff); |
863 | 863 |
i += 2 + s_length; |
864 | 864 |
break; |
... | ... |
@@ -867,7 +867,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
867 | 867 |
tmp_buff = (unsigned char *) malloc (s_length + 1); |
868 | 868 |
strncpy (tmp_buff, buff + i + 2, s_length); |
869 | 869 |
tmp_buff[s_length] = '\0'; |
870 |
- printf ("%s", tmp_buff); |
|
870 |
+ logg ("%s", tmp_buff); |
|
871 | 871 |
free (tmp_buff); |
872 | 872 |
i += 2 + s_length; |
873 | 873 |
break; |
... | ... |
@@ -877,7 +877,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
877 | 877 |
memcpy (tmp_buff, buff + i + 3, w_length * 2); |
878 | 878 |
tmp_name = get_unicode_name (tmp_buff, w_length * 2); |
879 | 879 |
free (tmp_buff); |
880 |
- printf ("\"%s\"", tmp_name); |
|
880 |
+ logg ("\"%s\"", tmp_name); |
|
881 | 881 |
free (tmp_name); |
882 | 882 |
i += 3 + (w_length * 2); |
883 | 883 |
break; |
... | ... |
@@ -888,7 +888,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
888 | 888 |
memcpy (tmp_buff, buff + i + 2, s_length * 2); |
889 | 889 |
tmp_name = get_unicode_name (tmp_buff, s_length * 2); |
890 | 890 |
free (tmp_buff); |
891 |
- printf ("'%s", tmp_name); |
|
891 |
+ logg ("'%s", tmp_name); |
|
892 | 892 |
free (tmp_name); |
893 | 893 |
i += 2 + (s_length * 2); |
894 | 894 |
break; |
... | ... |
@@ -896,7 +896,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
896 | 896 |
case 0x66: |
897 | 897 |
int_val = (uint8_t) (buff[i + 2] << 8) + buff[i + 1]; |
898 | 898 |
print_hex_buff (line_start, buff + i + 3, hex_output); |
899 |
- printf ("\n%d", int_val); |
|
899 |
+ logg ("\n%d", int_val); |
|
900 | 900 |
i += 3; |
901 | 901 |
line_start = buff + i; |
902 | 902 |
break; |
... | ... |
@@ -907,25 +907,25 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
907 | 907 |
break; |
908 | 908 |
case 0x68: |
909 | 909 |
/* 8-byte float */ |
910 |
- printf ("(float)"); |
|
910 |
+ logg ("(float)"); |
|
911 | 911 |
i += 9; |
912 | 912 |
break; |
913 | 913 |
case 0x6c: |
914 | 914 |
int_val = (uint16_t) (buff[i + 2] << 8) + buff[i + 1]; |
915 |
- printf (" %d", int_val); |
|
915 |
+ logg (" %d", int_val); |
|
916 | 916 |
i += 3; |
917 | 917 |
break; |
918 | 918 |
case 0x6e: |
919 | 919 |
s_length = (uint8_t) buff[i + 1]; |
920 | 920 |
for (j = 0; j < s_length; j++) { |
921 |
- printf (" "); |
|
921 |
+ logg (" "); |
|
922 | 922 |
} |
923 | 923 |
i += 2; |
924 | 924 |
break; |
925 | 925 |
case 0x6f: |
926 | 926 |
s_length = (uint8_t) buff[i + 1]; |
927 | 927 |
for (j = 0; j < s_length; j++) { |
928 |
- printf ("\t"); |
|
928 |
+ logg ("\t"); |
|
929 | 929 |
} |
930 | 930 |
i += 2; |
931 | 931 |
break; |
... | ... |
@@ -936,7 +936,7 @@ void wm_decode_macro (unsigned char *buff, uint32_t len, int hex_output) |
936 | 936 |
break; |
937 | 937 |
case 0x64: |
938 | 938 |
print_hex_buff (line_start, buff + i + 1, hex_output); |
939 |
- printf ("\n"); |
|
939 |
+ logg ("\n"); |
|
940 | 940 |
i++; |
941 | 941 |
line_start = buff + i; |
942 | 942 |
break; |
... | ... |
@@ -990,17 +990,17 @@ static int sigtool_scandir (const char *dirname, int hex_output) |
990 | 990 |
/* generate the temporary directory */ |
991 | 991 |
dir = cli_gentemp (tmpdir); |
992 | 992 |
if (mkdir (dir, 0700)) { |
993 |
- printf ("Can't create temporary directory %s\n", dir); |
|
993 |
+ logg ("Can't create temporary directory %s\n", dir); |
|
994 | 994 |
return CL_ETMPDIR; |
995 | 995 |
} |
996 | 996 |
|
997 | 997 |
if ((desc = open (fname, O_RDONLY)) == -1) { |
998 |
- printf ("Can't open file %s\n", fname); |
|
998 |
+ logg ("Can't open file %s\n", fname); |
|
999 | 999 |
return 1; |
1000 | 1000 |
} |
1001 | 1001 |
|
1002 | 1002 |
if ((ret = cli_ole2_extract (desc, dir, NULL))) { |
1003 |
- printf ("ERROR %s\n", cl_strerror (ret)); |
|
1003 |
+ logg ("ERROR %s\n", cl_strerror (ret)); |
|
1004 | 1004 |
cli_rmdirs (dir); |
1005 | 1005 |
free (dir); |
1006 | 1006 |
return ret; |
... | ... |
@@ -1019,7 +1019,7 @@ static int sigtool_scandir (const char *dirname, int hex_output) |
1019 | 1019 |
} |
1020 | 1020 |
} |
1021 | 1021 |
} else { |
1022 |
- cli_errmsg ("Can't open directory %s.\n", dirname); |
|
1022 |
+ logg("!Can't open directory %s.\n", dirname); |
|
1023 | 1023 |
return CL_EOPEN; |
1024 | 1024 |
} |
1025 | 1025 |
|
... | ... |
@@ -1037,7 +1037,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output) |
1037 | 1037 |
char *fname, *fullname; |
1038 | 1038 |
unsigned char *data; |
1039 | 1039 |
|
1040 |
- cli_dbgmsg ("VBA scan dir: %s\n", dirname); |
|
1040 |
+ logg("^VBA scan dir: %s\n", dirname); |
|
1041 | 1041 |
if ((vba_project = (vba_project_t *) vba56_dir_read (dirname))) { |
1042 | 1042 |
|
1043 | 1043 |
for (i = 0; i < vba_project->count; i++) { |
... | ... |
@@ -1045,27 +1045,27 @@ int sigtool_vba_scandir (const char *dirname, int hex_output) |
1045 | 1045 |
sprintf (fullname, "%s/%s", vba_project->dir, vba_project->name[i]); |
1046 | 1046 |
fd = open (fullname, O_RDONLY); |
1047 | 1047 |
if (fd == -1) { |
1048 |
- cli_errmsg ("Scan->OLE2 -> Can't open file %s\n", fullname); |
|
1048 |
+ logg("!Scan->OLE2 -> Can't open file %s\n", fullname); |
|
1049 | 1049 |
free (fullname); |
1050 | 1050 |
ret = CL_EOPEN; |
1051 | 1051 |
break; |
1052 | 1052 |
} |
1053 | 1053 |
free (fullname); |
1054 |
- cli_dbgmsg ("decompress VBA project '%s'\n", vba_project->name[i]); |
|
1055 |
- printf ("-------------- start of %s ------------------\n", vba_project->name[i]); |
|
1054 |
+ logg("*decompress VBA project '%s'\n", vba_project->name[i]); |
|
1055 |
+ logg ("-------------- start of %s ------------------\n", vba_project->name[i]); |
|
1056 | 1056 |
data = (unsigned char *) vba_decompress (fd, vba_project->offset[i], &data_len); |
1057 | 1057 |
close (fd); |
1058 | 1058 |
|
1059 | 1059 |
if (!data) { |
1060 |
- cli_dbgmsg ("WARNING: VBA project '%s' decompressed to NULL\n", vba_project->name[i]); |
|
1060 |
+ logg("*VBA project '%s' decompressed to NULL\n", vba_project->name[i]); |
|
1061 | 1061 |
} else { |
1062 | 1062 |
data = (char *) realloc (data, data_len + 1); |
1063 | 1063 |
data[data_len] = '\0'; |
1064 |
- printf ("%s", data); |
|
1064 |
+ logg ("%s", data); |
|
1065 | 1065 |
free (data); |
1066 | 1066 |
|
1067 | 1067 |
} |
1068 |
- printf ("-------------- end of %s ------------------\n", vba_project->name[i]); |
|
1068 |
+ logg ("-------------- end of %s ------------------\n", vba_project->name[i]); |
|
1069 | 1069 |
} |
1070 | 1070 |
|
1071 | 1071 |
for (i = 0; i < vba_project->count; i++) |
... | ... |
@@ -1086,26 +1086,26 @@ int sigtool_vba_scandir (const char *dirname, int hex_output) |
1086 | 1086 |
sprintf (fullname, "%s/%s", vba_project->dir, vba_project->name[i]); |
1087 | 1087 |
fd = open (fullname, O_RDONLY); |
1088 | 1088 |
if (fd == -1) { |
1089 |
- cli_errmsg ("Scan->OLE2 -> Can't open file %s\n", fullname); |
|
1089 |
+ logg("!Scan->OLE2 -> Can't open file %s\n", fullname); |
|
1090 | 1090 |
free (fullname); |
1091 | 1091 |
ret = CL_EOPEN; |
1092 | 1092 |
break; |
1093 | 1093 |
} |
1094 | 1094 |
free (fullname); |
1095 |
- cli_dbgmsg ("decompress WM project '%s' macro %d\n", vba_project->name[i], i); |
|
1096 |
- printf ("\n\n-------------- start of macro:%d key:%d length:%d ------------------\n", i, |
|
1095 |
+ logg("*decompress WM project '%s' macro %d\n", vba_project->name[i], i); |
|
1096 |
+ logg ("\n\n-------------- start of macro:%d key:%d length:%d ------------------\n", i, |
|
1097 | 1097 |
vba_project->key[i], vba_project->length[i]); |
1098 | 1098 |
data = (unsigned char *) wm_decrypt_macro (fd, vba_project->offset[i], vba_project->length[i], |
1099 | 1099 |
vba_project->key[i]); |
1100 | 1100 |
close (fd); |
1101 | 1101 |
|
1102 | 1102 |
if (!data) { |
1103 |
- cli_dbgmsg ("WARNING: WM project '%s' macro %d decrypted to NULL\n", vba_project->name[i], i); |
|
1103 |
+ logg("*WM project '%s' macro %d decrypted to NULL\n", vba_project->name[i], i); |
|
1104 | 1104 |
} else { |
1105 | 1105 |
wm_decode_macro (data, vba_project->length[i], hex_output); |
1106 | 1106 |
free (data); |
1107 | 1107 |
} |
1108 |
- printf ("\n-------------- end of macro %d ------------------\n\n", i); |
|
1108 |
+ logg ("\n-------------- end of macro %d ------------------\n\n", i); |
|
1109 | 1109 |
} |
1110 | 1110 |
for (i = 0; i < vba_project->count; i++) |
1111 | 1111 |
free (vba_project->name[i]); |
... | ... |
@@ -1135,7 +1135,7 @@ int sigtool_vba_scandir (const char *dirname, int hex_output) |
1135 | 1135 |
} |
1136 | 1136 |
} |
1137 | 1137 |
} else { |
1138 |
- cli_errmsg ("ScanDir -> Can't open directory %s.\n", dirname); |
|
1138 |
+ logg("!ScanDir -> Can't open directory %s.\n", dirname); |
|
1139 | 1139 |
return CL_EOPEN; |
1140 | 1140 |
} |
1141 | 1141 |
|