git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@173 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/01/09 10:10:52... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Fri Jan 9 02:07:53 CET 2004 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam: restored old command line options (except for proxy settings) - |
|
4 |
+ if activated, they will overwrite settings from freshclam.conf |
|
5 |
+ * clamscan: --beep |
|
6 |
+ |
|
1 | 7 |
Wed Jan 7 21:50:28 CET 2004 (tk) |
2 | 8 |
--------------------------------- |
3 | 9 |
* clamscan: removed support for sendfile() under Linux |
... | ... |
@@ -96,6 +96,8 @@ void clamscan(struct optstruct *opt) |
96 | 96 |
if(optc(opt, 'i')) printinfected = 1; |
97 | 97 |
else printinfected = 0; |
98 | 98 |
|
99 |
+ if(optl(opt, "bell")) bell = 1; |
|
100 |
+ |
|
99 | 101 |
/* initialize logger */ |
100 | 102 |
|
101 | 103 |
if(optl(opt, "log-verbose")) logverbose = 1; |
... | ... |
@@ -140,7 +142,7 @@ void clamscan(struct optstruct *opt) |
140 | 140 |
gettimeofday(&t1, &tz); |
141 | 141 |
ret = scanmanager(opt); |
142 | 142 |
|
143 |
- if(!optl(opt, "disable-summary")) { |
|
143 |
+ if(!optl(opt, "disable-summary") && !optl(opt, "no-summary")) { |
|
144 | 144 |
gettimeofday(&t2, &tz); |
145 | 145 |
ds = t2.tv_sec - t1.tv_sec; |
146 | 146 |
dms = t2.tv_usec - t1.tv_usec; |
... | ... |
@@ -205,10 +207,11 @@ void help(void) |
205 | 205 |
mprintf(" --move=DIRECTORY Move infected files into DIRECTORY\n"); |
206 | 206 |
mprintf(" --exclude=PATT Don't scan file names containing PATT\n"); |
207 | 207 |
mprintf(" --include=PATT Only scan file names containing PATT\n"); |
208 |
- mprintf(" --disable-summary Disable summary at end of scanning\n"); |
|
208 |
+ mprintf(" --bell Sound bell on virus detection\n"); |
|
209 |
+ mprintf(" --no-summary Disable summary at end of scanning\n"); |
|
209 | 210 |
mprintf(" --mbox -m Treat stdin as a mailbox\n"); |
210 | 211 |
mprintf("\n"); |
211 |
- mprintf(" --disable-archive Disable libclamav archive support\n"); |
|
212 |
+ mprintf(" --no-archive Disable libclamav archive support\n"); |
|
212 | 213 |
mprintf(" --max-space=#n Extract first #n kilobytes only\n"); |
213 | 214 |
mprintf(" --max-files=#n Extract first #n files only\n"); |
214 | 215 |
mprintf(" --max-recursion=#n Maximal recursion level\n"); |
... | ... |
@@ -344,7 +344,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us |
344 | 344 |
return 0; |
345 | 345 |
} |
346 | 346 |
|
347 |
- if(optl(opt, "disable-archive")) |
|
347 |
+ if(optl(opt, "disable-archive") || optl(opt, "no-archive")) |
|
348 | 348 |
options &= ~CL_ARCHIVE; |
349 | 349 |
else |
350 | 350 |
options |= CL_ARCHIVE; |
... | ... |
@@ -631,6 +631,10 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
631 | 631 |
case 1: |
632 | 632 |
logg("%s: Infected Archive FOUND\n", filename); |
633 | 633 |
mprintf("%s: Infected Archive FOUND\n", filename); |
634 |
+ |
|
635 |
+ if(bell) |
|
636 |
+ printf("\007"); |
|
637 |
+ |
|
634 | 638 |
if(optl(opt, "remove")) { |
635 | 639 |
if(unlink(filename)) { |
636 | 640 |
mprintf("%s: Can't remove.\n", filename); |
... | ... |
@@ -756,6 +760,10 @@ int checkfile(const char *filename, const struct cl_node *root, const struct cl_ |
756 | 756 |
mprintf("%s: %s FOUND\n", filename, virname); |
757 | 757 |
logg("%s: %s FOUND\n", filename, virname); |
758 | 758 |
claminfo.ifiles++; |
759 |
+ |
|
760 |
+ if(bell) |
|
761 |
+ printf("\007"); |
|
762 |
+ |
|
759 | 763 |
} else if(ret == CL_CLEAN) { |
760 | 764 |
if(!printinfected) |
761 | 765 |
mprintf("%s: OK\n", filename); |
... | ... |
@@ -778,6 +786,10 @@ int checkstdin(const struct cl_node *root, const struct cl_limits *limits) |
778 | 778 |
if((ret = cl_scandesc(0, &virname, &claminfo.blocks, root, limits, CL_RAW)) == CL_VIRUS) { |
779 | 779 |
mprintf("stdin: %s FOUND\n", virname); |
780 | 780 |
claminfo.ifiles++; |
781 |
+ |
|
782 |
+ if(bell) |
|
783 |
+ printf("\007"); |
|
784 |
+ |
|
781 | 785 |
} else if(ret == CL_CLEAN) { |
782 | 786 |
if(!printinfected) |
783 | 787 |
mprintf("stdin: OK\n"); |
... | ... |
@@ -52,7 +52,9 @@ int main(int argc, char **argv) |
52 | 52 |
{"whole-file", 0, 0, 'w'}, /* not used */ |
53 | 53 |
{"force", 0, 0, 0}, |
54 | 54 |
{"recursive", 0, 0, 'r'}, |
55 |
- {"disable-summary", 0, 0, 0}, |
|
55 |
+ {"bell", 0, 0, 0}, |
|
56 |
+ {"disable-summary", 0, 0, 0}, /* obsolete */ |
|
57 |
+ {"no-summary", 0, 0, 0}, |
|
56 | 58 |
{"infected", 0, 0, 'i'}, |
57 | 59 |
{"log", 1, 0, 'l'}, |
58 | 60 |
{"log-verbose", 0, 0, 0}, |
... | ... |
@@ -66,6 +68,7 @@ int main(int argc, char **argv) |
66 | 66 |
{"max-space", 1, 0, 0}, |
67 | 67 |
{"max-recursion", 1, 0, 0}, |
68 | 68 |
{"disable-archive", 0, 0, 0}, |
69 |
+ {"no-archive", 0, 0, 0}, |
|
69 | 70 |
|
70 | 71 |
{"mbox", 0, 0, 'm'}, |
71 | 72 |
{"stdout", 0, 0, 0}, |
... | ... |
@@ -32,7 +32,7 @@ struct s_info { |
32 | 32 |
long int blocks; /* number of read 16kb blocks */ |
33 | 33 |
} claminfo; |
34 | 34 |
|
35 |
-short int mprintf_disabled, mprintf_verbose, mprintf_quiet, mprintf_stdout, logverbose, recursion, printinfected; |
|
35 |
+short int mprintf_disabled, mprintf_verbose, mprintf_quiet, mprintf_stdout, logverbose, recursion, printinfected, bell; |
|
36 | 36 |
const char *logfile; |
37 | 37 |
|
38 | 38 |
#endif |
... | ... |
@@ -64,12 +64,19 @@ int freshclam(struct optstruct *opt) |
64 | 64 |
return 56; |
65 | 65 |
} |
66 | 66 |
|
67 |
+ if(optl(opt, "http-proxy") || optl(opt, "proxy-user")) |
|
68 |
+ mprintf("WARNING: Proxy settings are now only configurable in the config file.\n"); |
|
69 |
+ |
|
70 |
+ |
|
67 | 71 |
#ifndef C_CYGWIN |
68 | 72 |
/* freshclam shouldn't work with root priviledges */ |
69 |
- if((cpt = cfgopt(copt, "DatabaseOwner")) == NULL) |
|
70 |
- unpuser = UNPUSER; |
|
71 |
- else |
|
73 |
+ if(optc(opt, 'u')) { |
|
74 |
+ unpuser = getargc(opt, 'u'); |
|
75 |
+ } if((cpt = cfgopt(copt, "DatabaseOwner"))) { |
|
72 | 76 |
unpuser = cpt->strarg; |
77 |
+ } else { |
|
78 |
+ unpuser = UNPUSER; |
|
79 |
+ } |
|
73 | 80 |
|
74 | 81 |
if(!getuid()) { |
75 | 82 |
if((user = getpwnam(unpuser)) == NULL) { |
... | ... |
@@ -116,7 +123,13 @@ int freshclam(struct optstruct *opt) |
116 | 116 |
else |
117 | 117 |
logverbose = 0; |
118 | 118 |
|
119 |
- if((cpt = cfgopt(copt, "UpdateLogFile"))) { |
|
119 |
+ if(optc(opt, 'l')) { |
|
120 |
+ logfile = getargc(opt, 'l'); |
|
121 |
+ if(logg("--------------------------------------\n")) { |
|
122 |
+ mprintf("!Problem with internal logger.\n"); |
|
123 |
+ mexit(1); |
|
124 |
+ } |
|
125 |
+ } else if((cpt = cfgopt(copt, "UpdateLogFile"))) { |
|
120 | 126 |
logfile = cpt->strarg; |
121 | 127 |
if(logg("--------------------------------------\n")) { |
122 | 128 |
mprintf("!Problem with internal logger.\n"); |
... | ... |
@@ -145,10 +158,14 @@ int freshclam(struct optstruct *opt) |
145 | 145 |
if(optc(opt, 'd')) { |
146 | 146 |
int bigsleep, checks; |
147 | 147 |
|
148 |
- if((cpt = cfgopt(copt, "Checks"))) |
|
148 |
+ |
|
149 |
+ if(optc(opt, 'c')) { |
|
150 |
+ checks = atoi(getargc(opt, 'c')); |
|
151 |
+ } if((cpt = cfgopt(copt, "Checks"))) { |
|
149 | 152 |
checks = cpt->numarg; |
150 |
- else |
|
153 |
+ } else { |
|
151 | 154 |
checks = CL_DEFAULT_CHECKS; |
155 |
+ } |
|
152 | 156 |
|
153 | 157 |
if(checks <= 0 || checks > 50) { |
154 | 158 |
mprintf("@Number of checks must be between 1 and 50.\n"); |
... | ... |
@@ -159,22 +176,33 @@ int freshclam(struct optstruct *opt) |
159 | 159 |
daemonize(); |
160 | 160 |
|
161 | 161 |
while(1) { |
162 |
- ret = download(copt); |
|
162 |
+ ret = download(copt, opt); |
|
163 |
+ |
|
163 | 164 |
|
164 |
- if((cpt = cfgopt(copt, "OnErrorExecute"))) |
|
165 |
+ if(optl(opt, "on-error-execute")) { |
|
166 |
+ if(ret > 1) |
|
167 |
+ system(getargl(opt, "on-error-execute")); |
|
168 |
+ |
|
169 |
+ } else if((cpt = cfgopt(copt, "OnErrorExecute"))) { |
|
165 | 170 |
if(ret > 1) |
166 | 171 |
system(cpt->strarg); |
172 |
+ } |
|
167 | 173 |
|
168 | 174 |
logg("\n--------------------------------------\n"); |
169 | 175 |
sleep(bigsleep); |
170 | 176 |
} |
171 | 177 |
|
172 | 178 |
} else |
173 |
- ret = download(copt); |
|
179 |
+ ret = download(copt, opt); |
|
174 | 180 |
|
175 |
- if((cpt = cfgopt(copt, "OnErrorExecute"))) |
|
181 |
+ if(optl(opt, "on-error-execute")) { |
|
182 |
+ if(ret > 1) |
|
183 |
+ system(getargl(opt, "on-error-execute")); |
|
184 |
+ |
|
185 |
+ } else if((cpt = cfgopt(copt, "OnErrorExecute"))) { |
|
176 | 186 |
if(ret > 1) |
177 | 187 |
system(cpt->strarg); |
188 |
+ } |
|
178 | 189 |
|
179 | 190 |
return(ret); |
180 | 191 |
} |
... | ... |
@@ -185,7 +213,7 @@ void d_timeout(int sig) |
185 | 185 |
exit(1); |
186 | 186 |
} |
187 | 187 |
|
188 |
-int download(const struct cfgstruct *copt) |
|
188 |
+int download(const struct cfgstruct *copt, const struct optstruct *opt) |
|
189 | 189 |
{ |
190 | 190 |
int ret = 0, try = 0, maxattempts = 0; |
191 | 191 |
struct sigaction sigalrm; |
... | ... |
@@ -207,7 +235,7 @@ int download(const struct cfgstruct *copt) |
207 | 207 |
|
208 | 208 |
while(cpt) { |
209 | 209 |
alarm(TIMEOUT); |
210 |
- ret = downloadmanager(copt, cpt->strarg); |
|
210 |
+ ret = downloadmanager(copt, opt, cpt->strarg); |
|
211 | 211 |
alarm(0); |
212 | 212 |
|
213 | 213 |
if(ret == 52 || ret == 54) { |
... | ... |
@@ -266,8 +294,19 @@ void help(void) |
266 | 266 |
mprintf(" --stdout write to stdout instead of stderr\n"); |
267 | 267 |
mprintf(" (this help is always written to stdout)\n"); |
268 | 268 |
mprintf("\n"); |
269 |
+ mprintf(" --config-file=FILE -c FILE Read configuration from FILE.\n"); |
|
270 |
+ mprintf(" --log=FILE -l FILE log into FILE\n"); |
|
271 |
+ mprintf(" --log-verbose log additional information\n"); |
|
269 | 272 |
mprintf(" --daemon -d run in daemon mode\n"); |
273 |
+ mprintf(" --user=USER -u USER run as USER\n"); |
|
274 |
+ mprintf(" --checks=#n -c #n #n checks by day, 1 <= n <= 50\n"); |
|
270 | 275 |
mprintf(" --datadir=DIRECTORY download new databases into DIRECTORY\n"); |
276 |
+#ifdef BUILD_CLAMD |
|
277 |
+ mprintf(" --daemon-notify[=/path/clamav.conf] send RELOAD command to clamd\n"); |
|
278 |
+#endif |
|
279 |
+ mprintf(" --on-update-execute=COMMAND execute COMMAND after successful update\n"); |
|
280 |
+ mprintf(" --on-error-execute=COMMAND execute COMMAND if errors occured\n"); |
|
281 |
+ |
|
271 | 282 |
mprintf("\n"); |
272 | 283 |
exit(0); |
273 | 284 |
} |
... | ... |
@@ -42,7 +42,7 @@ |
42 | 42 |
#include "shared.h" |
43 | 43 |
#include "notify.h" |
44 | 44 |
|
45 |
-int downloadmanager(const struct cfgstruct *copt, const char *hostname) |
|
45 |
+int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname) |
|
46 | 46 |
{ |
47 | 47 |
time_t currtime; |
48 | 48 |
int ret, updated = 0, signo = 0; |
... | ... |
@@ -82,7 +82,13 @@ int downloadmanager(const struct cfgstruct *copt, const char *hostname) |
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
#ifdef BUILD_CLAMD |
85 |
- if((cpt = cfgopt(copt, "NotifyClamd"))) { |
|
85 |
+ if(optl(opt, "daemon-notify")) { |
|
86 |
+ const char *clamav_conf = getargl(opt, "daemon-notify"); |
|
87 |
+ if(!clamav_conf) |
|
88 |
+ clamav_conf = CONFDIR"/clamav.conf"; |
|
89 |
+ |
|
90 |
+ notify(clamav_conf); |
|
91 |
+ } else if((cpt = cfgopt(copt, "NotifyClamd"))) { |
|
86 | 92 |
const char *clamav_conf = cpt->strarg; |
87 | 93 |
if(!clamav_conf) |
88 | 94 |
clamav_conf = CONFDIR"/clamav.conf"; |
... | ... |
@@ -91,7 +97,9 @@ int downloadmanager(const struct cfgstruct *copt, const char *hostname) |
91 | 91 |
} |
92 | 92 |
#endif |
93 | 93 |
|
94 |
- if((cpt = cfgopt(copt, "OnUpdateExecute"))) |
|
94 |
+ if(optl(opt, "on-update-execute")) |
|
95 |
+ system(getargl(opt, "on-update-execute")); |
|
96 |
+ else if((cpt = cfgopt(copt, "OnUpdateExecute"))) |
|
95 | 97 |
system(cpt->strarg); |
96 | 98 |
|
97 | 99 |
return 0; |
... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
#include "cfgfile.h" |
23 | 23 |
#include "clamav.h" |
24 | 24 |
|
25 |
-int downloadmanager(const struct cfgstruct *copt, const char *hostname); |
|
25 |
+int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, const char *hostname); |
|
26 | 26 |
|
27 | 27 |
int downloaddb(const char *localname, const char *remotename, const char *hostname, char *ip, int *signo, const struct cfgstruct *copt); |
28 | 28 |
|
... | ... |
@@ -48,7 +48,7 @@ int main(int argc, char **argv) |
48 | 48 |
{"stdout", 0, 0, 0}, |
49 | 49 |
{"daemon", 0, 0, 'd'}, |
50 | 50 |
{"user", 1, 0, 'u'}, /* not used */ |
51 |
- {"config-file", 1, 0, 'c'}, /* not used */ |
|
51 |
+ {"config-file", 1, 0, 'c'}, |
|
52 | 52 |
{"checks", 1, 0, 'c'}, |
53 | 53 |
{"http-proxy", 1, 0, 0}, |
54 | 54 |
{"proxy-user", 1, 0, 0}, |