git-svn: trunk@2224
Tomasz Kojm authored on 2006/08/31 07:41:21... | ... |
@@ -57,7 +57,6 @@ |
57 | 57 |
#include "misc.h" |
58 | 58 |
|
59 | 59 |
void help(void); |
60 |
-void daemonize(void); |
|
61 | 60 |
|
62 | 61 |
short debug_mode = 0, logok = 0; |
63 | 62 |
|
... | ... |
@@ -278,11 +277,12 @@ int main(int argc, char **argv) |
278 | 278 |
exit(1); |
279 | 279 |
} |
280 | 280 |
|
281 |
- |
|
282 | 281 |
/* fork into background */ |
283 |
- if(!cfgopt(copt, "Foreground")->enabled) |
|
282 |
+ if(!cfgopt(copt, "Foreground")->enabled) { |
|
284 | 283 |
daemonize(); |
285 |
- else |
|
284 |
+ if(!debug_mode) |
|
285 |
+ chdir("/"); |
|
286 |
+ } else |
|
286 | 287 |
foreground = 1; |
287 | 288 |
|
288 | 289 |
if(tcpsock) |
... | ... |
@@ -295,6 +295,7 @@ int main(int argc, char **argv) |
295 | 295 |
|
296 | 296 |
logg_close(); |
297 | 297 |
freecfg(copt); |
298 |
+ return ret; |
|
298 | 299 |
} |
299 | 300 |
|
300 | 301 |
void help(void) |
... | ... |
@@ -312,32 +313,3 @@ void help(void) |
312 | 312 |
exit(0); |
313 | 313 |
} |
314 | 314 |
|
315 |
-void daemonize(void) |
|
316 |
-{ |
|
317 |
- int i; |
|
318 |
- |
|
319 |
- |
|
320 |
-#ifdef C_OS2 |
|
321 |
- return; |
|
322 |
-#else |
|
323 |
- |
|
324 |
- if((i = open("/dev/null", O_WRONLY)) == -1) { |
|
325 |
- logg("!Cannot open /dev/null. Only use Debug if Foreground is enabled.\n"); |
|
326 |
- for(i = 0; i <= 2; i++) |
|
327 |
- close(i); |
|
328 |
- |
|
329 |
- } else { |
|
330 |
- close(0); |
|
331 |
- dup2(i, 1); |
|
332 |
- dup2(i, 2); |
|
333 |
- } |
|
334 |
- |
|
335 |
- if(!debug_mode) |
|
336 |
- chdir("/"); |
|
337 |
- |
|
338 |
- if(fork()) |
|
339 |
- exit(0); |
|
340 |
- |
|
341 |
- setsid(); |
|
342 |
-#endif |
|
343 |
-} |
233 | 231 |
deleted file mode 100644 |
... | ... |
@@ -1,40 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License as published by |
|
6 |
- * the Free Software Foundation; either version 2 of the License, or |
|
7 |
- * (at your option) any later version. |
|
8 |
- * |
|
9 |
- * This program is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
- * GNU General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU General Public License |
|
15 |
- * along with this program; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
- * MA 02110-1301, USA. |
|
18 |
- */ |
|
19 |
- |
|
20 |
-#ifndef DATADIR |
|
21 |
-# define DATADIR "/usr/local/share/clamav" |
|
22 |
-#endif |
|
23 |
- |
|
24 |
-#define VIRUSDBDIR DATADIR |
|
25 |
- |
|
26 |
-/* default names */ |
|
27 |
- |
|
28 |
-#ifdef CLAMAVUSER |
|
29 |
-#define UNPUSER CLAMAVUSER |
|
30 |
-#else |
|
31 |
-#define UNPUSER "clamav" |
|
32 |
-#endif |
|
33 |
- |
|
34 |
-#ifdef CLAMAVGROUP |
|
35 |
-#define UNPGROUP CLAMAVGROUP |
|
36 |
-#else |
|
37 |
-#define UNPGROUP "clamav" |
|
38 |
-#endif |
|
39 |
- |
|
40 |
-#define CL_MAX_CHILDREN 5 |
... | ... |
@@ -27,9 +27,9 @@ |
27 | 27 |
#include <string.h> |
28 | 28 |
#include <errno.h> |
29 | 29 |
|
30 |
-#include "defaults.h" |
|
31 |
-#include "freshclam.h" |
|
32 |
-#include "output.h" |
|
30 |
+#include "shared/output.h" |
|
31 |
+ |
|
32 |
+#define MAX_CHILDREN 5 |
|
33 | 33 |
|
34 | 34 |
int active_children; |
35 | 35 |
|
... | ... |
@@ -37,7 +37,7 @@ void execute( const char *type, const char *text ) |
37 | 37 |
{ |
38 | 38 |
pid_t pid; |
39 | 39 |
|
40 |
- if ( active_children<CL_MAX_CHILDREN ) |
|
40 |
+ if ( active_children<MAX_CHILDREN ) |
|
41 | 41 |
switch( pid=fork() ) { |
42 | 42 |
case 0: |
43 | 43 |
if ( -1==system(text) ) |
... | ... |
@@ -40,19 +40,20 @@ |
40 | 40 |
#include <syslog.h> |
41 | 41 |
#endif |
42 | 42 |
|
43 |
-#include "options.h" |
|
44 |
-#include "manager.h" |
|
45 |
-#include "defaults.h" |
|
46 |
-#include "freshclam.h" |
|
47 |
-#include "output.h" |
|
48 | 43 |
#include "target.h" |
49 |
-#include "misc.h" |
|
44 |
+#include "clamav.h" |
|
45 |
+ |
|
46 |
+#include "shared/options.h" |
|
47 |
+#include "shared/output.h" |
|
48 |
+#include "shared/misc.h" |
|
49 |
+ |
|
50 | 50 |
#include "execute.h" |
51 |
+#include "manager.h" |
|
51 | 52 |
|
52 | 53 |
static short terminate = 0; |
53 | 54 |
extern int active_children; |
54 | 55 |
|
55 |
-short foreground = 1; |
|
56 |
+static short foreground = 1; |
|
56 | 57 |
|
57 | 58 |
static void daemon_sighandler(int sig) { |
58 | 59 |
|
... | ... |
@@ -79,10 +80,11 @@ static void daemon_sighandler(int sig) { |
79 | 79 |
return; |
80 | 80 |
} |
81 | 81 |
|
82 |
- |
|
83 |
-static void writepid(char *pidfile) { |
|
82 |
+static void writepid(char *pidfile) |
|
83 |
+{ |
|
84 | 84 |
FILE *fd; |
85 | 85 |
int old_umask; |
86 |
+ |
|
86 | 87 |
old_umask = umask(0006); |
87 | 88 |
if((fd = fopen(pidfile, "w")) == NULL) { |
88 | 89 |
logg("!Can't save PID to file %s: %s\n", pidfile, strerror(errno)); |
... | ... |
@@ -93,14 +95,89 @@ static void writepid(char *pidfile) { |
93 | 93 |
umask(old_umask); |
94 | 94 |
} |
95 | 95 |
|
96 |
+void help(void) |
|
97 |
+{ |
|
98 |
+ mprintf_stdout = 1; |
|
99 |
+ |
|
100 |
+ mprintf("\n"); |
|
101 |
+ mprintf(" Clam AntiVirus: freshclam "VERSION"\n"); |
|
102 |
+ mprintf(" (C) 2002 - 2005 ClamAV Team - http://www.clamav.net/team.html\n\n"); |
|
103 |
+ |
|
104 |
+ mprintf(" --help -h show help\n"); |
|
105 |
+ mprintf(" --version -V print version number and exit\n"); |
|
106 |
+ mprintf(" --verbose -v be verbose\n"); |
|
107 |
+ mprintf(" --debug enable debug messages\n"); |
|
108 |
+ mprintf(" --quiet only output error messages\n"); |
|
109 |
+ mprintf(" --stdout write to stdout instead of stderr\n"); |
|
110 |
+ mprintf("\n"); |
|
111 |
+ mprintf(" --config-file=FILE read configuration from FILE.\n"); |
|
112 |
+ mprintf(" --log=FILE -l FILE log into FILE\n"); |
|
113 |
+ mprintf(" --daemon -d run in daemon mode\n"); |
|
114 |
+ mprintf(" --pid=FILE -p FILE save daemon's pid in FILE\n"); |
|
115 |
+ mprintf(" --user=USER -u USER run as USER\n"); |
|
116 |
+ mprintf(" --no-dns force old non-DNS verification method\n"); |
|
117 |
+ mprintf(" --checks=#n -c #n number of checks per day, 1 <= n <= 50\n"); |
|
118 |
+ mprintf(" --datadir=DIRECTORY download new databases into DIRECTORY\n"); |
|
119 |
+#ifdef BUILD_CLAMD |
|
120 |
+ mprintf(" --daemon-notify[=/path/clamd.conf] send RELOAD command to clamd\n"); |
|
121 |
+#endif |
|
122 |
+ mprintf(" --local-address=IP -a IP bind to IP for HTTP downloads\n"); |
|
123 |
+ mprintf(" --on-update-execute=COMMAND execute COMMAND after successful update\n"); |
|
124 |
+ mprintf(" --on-error-execute=COMMAND execute COMMAND if errors occured\n"); |
|
125 |
+ mprintf(" --on-outdated-execute=COMMAND execute COMMAND when software is outdated\n"); |
|
126 |
+ |
|
127 |
+ mprintf("\n"); |
|
128 |
+} |
|
129 |
+ |
|
130 |
+int download(const struct cfgstruct *copt, const struct optstruct *opt) |
|
131 |
+{ |
|
132 |
+ int ret = 0, try = 0, maxattempts = 0; |
|
133 |
+ struct cfgstruct *cpt; |
|
134 |
+ |
|
135 |
+ |
|
136 |
+ maxattempts = cfgopt(copt, "MaxAttempts")->numarg; |
|
137 |
+ logg("*Max retries == %d\n", maxattempts); |
|
138 |
+ |
|
139 |
+ if(!(cpt = cfgopt(copt, "DatabaseMirror"))->enabled) { |
|
140 |
+ logg("^You must specify at least one database mirror.\n"); |
|
141 |
+ return 56; |
|
142 |
+ } else { |
|
143 |
+ |
|
144 |
+ while(cpt) { |
|
145 |
+ ret = downloadmanager(copt, opt, cpt->strarg); |
|
146 |
+ alarm(0); |
|
147 |
+ |
|
148 |
+ if(ret == 52 || ret == 54 || ret == 58 || ret == 59) { |
|
149 |
+ if(try < maxattempts - 1) { |
|
150 |
+ logg("Trying again in 5 secs...\n"); |
|
151 |
+ try++; |
|
152 |
+ sleep(5); |
|
153 |
+ continue; |
|
154 |
+ } else { |
|
155 |
+ logg("Giving up on %s...\n", cpt->strarg); |
|
156 |
+ cpt = (struct cfgstruct *) cpt->nextarg; |
|
157 |
+ if(!cpt) { |
|
158 |
+ logg("^Update failed. Your network may be down or none of the mirrors listed in freshclam.conf is working.\n"); |
|
159 |
+ } |
|
160 |
+ try = 0; |
|
161 |
+ } |
|
162 |
+ |
|
163 |
+ } else { |
|
164 |
+ return ret; |
|
165 |
+ } |
|
166 |
+ } |
|
167 |
+ } |
|
168 |
+ |
|
169 |
+ return ret; |
|
170 |
+} |
|
171 |
+ |
|
96 | 172 |
int main(int argc, char **argv) |
97 | 173 |
{ |
98 | 174 |
int ret = 52; |
99 | 175 |
char *newdir, *cfgfile; |
100 | 176 |
char *pidfile = NULL; |
101 | 177 |
struct cfgstruct *copt, *cpt; |
102 |
- struct sigaction sigact; |
|
103 |
- struct sigaction oldact; |
|
178 |
+ struct sigaction sigact, oldact; |
|
104 | 179 |
#if !defined(C_CYGWIN) && !defined(C_OS2) |
105 | 180 |
char *unpuser; |
106 | 181 |
struct passwd *user; |
... | ... |
@@ -142,8 +219,15 @@ int main(int argc, char **argv) |
142 | 142 |
} |
143 | 143 |
|
144 | 144 |
if(opt_check(opt, "help")) { |
145 |
- opt_free(opt); |
|
146 | 145 |
help(); |
146 |
+ opt_free(opt); |
|
147 |
+ return 0; |
|
148 |
+ } |
|
149 |
+ |
|
150 |
+ if(opt_check(opt, "version")) { |
|
151 |
+ print_version(); |
|
152 |
+ opt_free(opt); |
|
153 |
+ return 0; |
|
147 | 154 |
} |
148 | 155 |
|
149 | 156 |
/* parse the config file */ |
... | ... |
@@ -181,44 +265,46 @@ int main(int argc, char **argv) |
181 | 181 |
|
182 | 182 |
#if !defined(C_CYGWIN) && !defined(C_OS2) |
183 | 183 |
/* freshclam shouldn't work with root privileges */ |
184 |
- if(opt_check(opt, "user")) { |
|
184 |
+ if(opt_check(opt, "user")) |
|
185 | 185 |
unpuser = opt_arg(opt, "user"); |
186 |
- } else if((cpt = cfgopt(copt, "DatabaseOwner"))->enabled) { |
|
187 |
- unpuser = cpt->strarg; |
|
188 |
- } else { |
|
189 |
- unpuser = UNPUSER; |
|
190 |
- } |
|
186 |
+ else |
|
187 |
+ unpuser = cfgopt(copt, "DatabaseOwner")->strarg; |
|
191 | 188 |
|
192 | 189 |
if(!geteuid()) { |
193 | 190 |
if((user = getpwnam(unpuser)) == NULL) { |
194 | 191 |
logg("^Can't get information about user %s.\n", unpuser); |
195 |
- exit(60); /* this is critical problem, so we just exit here */ |
|
192 |
+ opt_free(opt); |
|
193 |
+ return 60; |
|
196 | 194 |
} |
197 | 195 |
|
198 | 196 |
if(cfgopt(copt, "AllowSupplementaryGroups")->enabled) { |
199 | 197 |
#ifdef HAVE_INITGROUPS |
200 | 198 |
if(initgroups(unpuser, user->pw_gid)) { |
201 | 199 |
logg("^initgroups() failed.\n"); |
202 |
- exit(61); |
|
200 |
+ opt_free(opt); |
|
201 |
+ return 61; |
|
203 | 202 |
} |
204 | 203 |
#endif |
205 | 204 |
} else { |
206 | 205 |
#ifdef HAVE_SETGROUPS |
207 | 206 |
if(setgroups(1, &user->pw_gid)) { |
208 | 207 |
logg("^setgroups() failed.\n"); |
209 |
- exit(61); |
|
208 |
+ opt_free(opt); |
|
209 |
+ return 61; |
|
210 | 210 |
} |
211 | 211 |
#endif |
212 | 212 |
} |
213 | 213 |
|
214 | 214 |
if(setgid(user->pw_gid)) { |
215 | 215 |
logg("^setgid(%d) failed.\n", (int) user->pw_gid); |
216 |
- exit(61); |
|
216 |
+ opt_free(opt); |
|
217 |
+ return 61; |
|
217 | 218 |
} |
218 | 219 |
|
219 | 220 |
if(setuid(user->pw_uid)) { |
220 | 221 |
logg("^setuid(%d) failed.\n", (int) user->pw_uid); |
221 |
- exit(61); |
|
222 |
+ opt_free(opt); |
|
223 |
+ return 61; |
|
222 | 224 |
} |
223 | 225 |
} |
224 | 226 |
#endif |
... | ... |
@@ -237,11 +323,6 @@ int main(int argc, char **argv) |
237 | 237 |
if(opt_check(opt, "stdout")) |
238 | 238 |
mprintf_stdout = 1; |
239 | 239 |
|
240 |
- if(opt_check(opt, "version")) { |
|
241 |
- print_version(); |
|
242 |
- exit(0); |
|
243 |
- } |
|
244 |
- |
|
245 | 240 |
/* initialize logger */ |
246 | 241 |
|
247 | 242 |
if(cfgopt(copt, "LogVerbose")->enabled) |
... | ... |
@@ -251,13 +332,15 @@ int main(int argc, char **argv) |
251 | 251 |
logg_file = opt_arg(opt, "log"); |
252 | 252 |
if(logg("#--------------------------------------\n")) { |
253 | 253 |
mprintf("!Problem with internal logger (--log=%s).\n", logg_file); |
254 |
- exit(62); |
|
254 |
+ opt_free(opt); |
|
255 |
+ return 62; |
|
255 | 256 |
} |
256 | 257 |
} else if((cpt = cfgopt(copt, "UpdateLogFile"))->enabled) { |
257 | 258 |
logg_file = cpt->strarg; |
258 | 259 |
if(logg("#--------------------------------------\n")) { |
259 | 260 |
mprintf("!Problem with internal logger (UpdateLogFile = %s).\n", logg_file); |
260 |
- exit(62); |
|
261 |
+ opt_free(opt); |
|
262 |
+ return 62; |
|
261 | 263 |
} |
262 | 264 |
} else |
263 | 265 |
logg_file = NULL; |
... | ... |
@@ -269,7 +352,8 @@ int main(int argc, char **argv) |
269 | 269 |
if((cpt = cfgopt(copt, "LogFacility"))->enabled) { |
270 | 270 |
if((fac = logg_facility(cpt->strarg)) == -1) { |
271 | 271 |
mprintf("!LogFacility: %s: No such facility.\n", cpt->strarg); |
272 |
- exit(62); |
|
272 |
+ opt_free(opt); |
|
273 |
+ return 62; |
|
273 | 274 |
} |
274 | 275 |
} |
275 | 276 |
|
... | ... |
@@ -286,11 +370,11 @@ int main(int argc, char **argv) |
286 | 286 |
|
287 | 287 |
if(chdir(newdir)) { |
288 | 288 |
logg("Can't change dir to %s\n", newdir); |
289 |
- exit(50); |
|
289 |
+ opt_free(opt); |
|
290 |
+ return 50; |
|
290 | 291 |
} else |
291 | 292 |
logg("*Current working dir is %s\n", newdir); |
292 | 293 |
|
293 |
- |
|
294 | 294 |
if(opt_check(opt, "daemon")) { |
295 | 295 |
int bigsleep, checks; |
296 | 296 |
time_t now, wakeup; |
... | ... |
@@ -305,13 +389,15 @@ int main(int argc, char **argv) |
305 | 305 |
|
306 | 306 |
if(checks <= 0) { |
307 | 307 |
logg("^Number of checks must be a positive integer.\n"); |
308 |
- exit(41); |
|
308 |
+ opt_free(opt); |
|
309 |
+ return 41; |
|
309 | 310 |
} |
310 | 311 |
|
311 | 312 |
if(!cfgopt(copt, "DNSDatabaseInfo")->enabled || opt_check(opt, "no-dns")) { |
312 | 313 |
if(checks > 50) { |
313 | 314 |
logg("^Number of checks must be between 1 and 50.\n"); |
314 |
- exit(41); |
|
315 |
+ opt_free(opt); |
|
316 |
+ return 41; |
|
315 | 317 |
} |
316 | 318 |
} |
317 | 319 |
|
... | ... |
@@ -320,6 +406,7 @@ int main(int argc, char **argv) |
320 | 320 |
if(!cfgopt(copt, "Foreground")->enabled) { |
321 | 321 |
foreground = 0; |
322 | 322 |
daemonize(); |
323 |
+ mprintf_disabled = 1; |
|
323 | 324 |
} |
324 | 325 |
|
325 | 326 |
if(opt_check(opt, "pid")) { |
... | ... |
@@ -397,96 +484,3 @@ int main(int argc, char **argv) |
397 | 397 |
opt_free(opt); |
398 | 398 |
return(ret); |
399 | 399 |
} |
400 |
- |
|
401 |
-int download(const struct cfgstruct *copt, const struct optstruct *opt) |
|
402 |
-{ |
|
403 |
- int ret = 0, try = 0, maxattempts = 0; |
|
404 |
- struct cfgstruct *cpt; |
|
405 |
- |
|
406 |
- |
|
407 |
- maxattempts = cfgopt(copt, "MaxAttempts")->numarg; |
|
408 |
- logg("*Max retries == %d\n", maxattempts); |
|
409 |
- |
|
410 |
- if(!(cpt = cfgopt(copt, "DatabaseMirror"))->enabled) { |
|
411 |
- logg("^You must specify at least one database mirror.\n"); |
|
412 |
- return 56; |
|
413 |
- } else { |
|
414 |
- |
|
415 |
- while(cpt) { |
|
416 |
- ret = downloadmanager(copt, opt, cpt->strarg); |
|
417 |
- alarm(0); |
|
418 |
- |
|
419 |
- if(ret == 52 || ret == 54 || ret == 58 || ret == 59) { |
|
420 |
- if(try < maxattempts - 1) { |
|
421 |
- logg("Trying again in 5 secs...\n"); |
|
422 |
- try++; |
|
423 |
- sleep(5); |
|
424 |
- continue; |
|
425 |
- } else { |
|
426 |
- logg("Giving up on %s...\n", cpt->strarg); |
|
427 |
- cpt = (struct cfgstruct *) cpt->nextarg; |
|
428 |
- if(!cpt) { |
|
429 |
- logg("^Update failed. Your network may be down or none of the mirrors listed in freshclam.conf is working.\n"); |
|
430 |
- } |
|
431 |
- try = 0; |
|
432 |
- } |
|
433 |
- |
|
434 |
- } else { |
|
435 |
- return ret; |
|
436 |
- } |
|
437 |
- } |
|
438 |
- } |
|
439 |
- |
|
440 |
- return ret; |
|
441 |
-} |
|
442 |
- |
|
443 |
-void daemonize(void) |
|
444 |
-{ |
|
445 |
- int i; |
|
446 |
- |
|
447 |
- for(i = 0; i < 3; i++) |
|
448 |
- close(i); |
|
449 |
- |
|
450 |
- umask(0); |
|
451 |
- |
|
452 |
- if(fork()) |
|
453 |
- exit(0); |
|
454 |
- |
|
455 |
- setsid(); |
|
456 |
- mprintf_disabled = 1; |
|
457 |
-} |
|
458 |
- |
|
459 |
-void help(void) |
|
460 |
-{ |
|
461 |
- mprintf_stdout = 1; |
|
462 |
- |
|
463 |
- mprintf("\n"); |
|
464 |
- mprintf(" Clam AntiVirus: freshclam "VERSION"\n"); |
|
465 |
- mprintf(" (C) 2002 - 2005 ClamAV Team - http://www.clamav.net/team.html\n\n"); |
|
466 |
- |
|
467 |
- mprintf(" --help -h show help\n"); |
|
468 |
- mprintf(" --version -V print version number and exit\n"); |
|
469 |
- mprintf(" --verbose -v be verbose\n"); |
|
470 |
- mprintf(" --debug enable debug messages\n"); |
|
471 |
- mprintf(" --quiet only output error messages\n"); |
|
472 |
- mprintf(" --stdout write to stdout instead of stderr\n"); |
|
473 |
- mprintf("\n"); |
|
474 |
- mprintf(" --config-file=FILE read configuration from FILE.\n"); |
|
475 |
- mprintf(" --log=FILE -l FILE log into FILE\n"); |
|
476 |
- mprintf(" --daemon -d run in daemon mode\n"); |
|
477 |
- mprintf(" --pid=FILE -p FILE save daemon's pid in FILE\n"); |
|
478 |
- mprintf(" --user=USER -u USER run as USER\n"); |
|
479 |
- mprintf(" --no-dns force old non-DNS verification method\n"); |
|
480 |
- mprintf(" --checks=#n -c #n number of checks per day, 1 <= n <= 50\n"); |
|
481 |
- mprintf(" --datadir=DIRECTORY download new databases into DIRECTORY\n"); |
|
482 |
-#ifdef BUILD_CLAMD |
|
483 |
- mprintf(" --daemon-notify[=/path/clamd.conf] send RELOAD command to clamd\n"); |
|
484 |
-#endif |
|
485 |
- mprintf(" --local-address=IP -a IP bind to IP for HTTP downloads\n"); |
|
486 |
- mprintf(" --on-update-execute=COMMAND execute COMMAND after successful update\n"); |
|
487 |
- mprintf(" --on-error-execute=COMMAND execute COMMAND if errors occured\n"); |
|
488 |
- mprintf(" --on-outdated-execute=COMMAND execute COMMAND when software is outdated\n"); |
|
489 |
- |
|
490 |
- mprintf("\n"); |
|
491 |
- exit(0); |
|
492 |
-} |
493 | 400 |
deleted file mode 100644 |
... | ... |
@@ -1,30 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2002 - 2005 Tomasz Kojm <tkojm@clamav.net> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License as published by |
|
6 |
- * the Free Software Foundation; either version 2 of the License, or |
|
7 |
- * (at your option) any later version. |
|
8 |
- * |
|
9 |
- * This program is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
- * GNU General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU General Public License |
|
15 |
- * along with this program; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
- * MA 02110-1301, USA. |
|
18 |
- */ |
|
19 |
- |
|
20 |
-#ifndef __FRESHCLAM_H |
|
21 |
-#define __FRESHCLAM_H |
|
22 |
- |
|
23 |
-#include "cfgparser.h" |
|
24 |
-#include "options.h" |
|
25 |
- |
|
26 |
-void help(void); |
|
27 |
-void daemonize(void); |
|
28 |
-int download(const struct cfgstruct *copt, const struct optstruct *opt); |
|
29 |
- |
|
30 |
-#endif |
... | ... |
@@ -531,7 +531,7 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna |
531 | 531 |
if(!strstr(buffer, "HTTP/1.1 200") && !strstr(buffer, "HTTP/1.0 200") && |
532 | 532 |
!strstr(buffer, "HTTP/1.1 206") && !strstr(buffer, "HTTP/1.0 206")) { |
533 | 533 |
logg("!getfile: Unknown response from remote server\n"); |
534 |
- return NULL; |
|
534 |
+ return 58; |
|
535 | 535 |
} |
536 | 536 |
|
537 | 537 |
/* get size of resource */ |
... | ... |
@@ -26,11 +26,11 @@ |
26 | 26 |
#include <string.h> |
27 | 27 |
#include <ctype.h> |
28 | 28 |
|
29 |
-#include "cfgparser.h" |
|
30 |
-#include "memory.h" |
|
31 |
-#include "misc.h" |
|
29 |
+#include "shared/cfgparser.h" |
|
30 |
+#include "shared/memory.h" |
|
31 |
+#include "shared/misc.h" |
|
32 | 32 |
|
33 |
-#include "../libclamav/str.h" |
|
33 |
+#include "libclamav/str.h" |
|
34 | 34 |
|
35 | 35 |
struct cfgoption cfg_options[] = { |
36 | 36 |
{"LogFile", OPT_STR, -1, NULL, 0, OPT_CLAMD}, |
... | ... |
@@ -90,7 +90,7 @@ struct cfgoption cfg_options[] = { |
90 | 90 |
{"ClamukoExcludePath", OPT_STR, 0, NULL, 0, OPT_CLAMD}, |
91 | 91 |
{"ClamukoMaxFileSize", OPT_COMPSIZE, 5242880, NULL, 0, OPT_CLAMD}, |
92 | 92 |
{"ClamukoScanArchive", OPT_BOOL, 0, NULL, 0, OPT_CLAMD}, |
93 |
- {"DatabaseOwner", OPT_STR, -1, NULL, 0, OPT_FRESHCLAM}, |
|
93 |
+ {"DatabaseOwner", OPT_STR, -1, CLAMAVUSER, 0, OPT_FRESHCLAM}, |
|
94 | 94 |
{"Checks", OPT_NUM, 12, NULL, 0, OPT_FRESHCLAM}, |
95 | 95 |
{"UpdateLogFile", OPT_STR, -1, NULL, 0, OPT_FRESHCLAM}, |
96 | 96 |
{"DNSDatabaseInfo", OPT_STR, -1, "current.cvd.clamav.net", 0, OPT_FRESHCLAM}, |
... | ... |
@@ -289,3 +289,28 @@ int cvd_unpack(const char *cvd, const char *destdir) |
289 | 289 |
|
290 | 290 |
return 0; |
291 | 291 |
} |
292 |
+ |
|
293 |
+void daemonize(void) |
|
294 |
+{ |
|
295 |
+ int i; |
|
296 |
+ |
|
297 |
+#ifdef C_OS2 |
|
298 |
+ return; |
|
299 |
+#else |
|
300 |
+ |
|
301 |
+ if((i = open("/dev/null", O_WRONLY)) == -1) { |
|
302 |
+ for(i = 0; i <= 2; i++) |
|
303 |
+ close(i); |
|
304 |
+ |
|
305 |
+ } else { |
|
306 |
+ close(0); |
|
307 |
+ dup2(i, 1); |
|
308 |
+ dup2(i, 2); |
|
309 |
+ } |
|
310 |
+ |
|
311 |
+ if(fork()) |
|
312 |
+ exit(0); |
|
313 |
+ |
|
314 |
+ setsid(); |
|
315 |
+#endif |
|
316 |
+} |