freshclam: in interactive mode EXIT_n can be passed to --on-*-execute to overwrite the default return code values (bb#465)

git-svn: trunk@3874
remotes/push_mirror/metadata
Tomasz Kojm 17 years ago
parent 04ba76d2cb
commit 770fb16668
  1. 5
      ChangeLog
  2. 21
      freshclam/execute.c
  3. 4
      freshclam/execute.h
  4. 25
      freshclam/freshclam.c
  5. 18
      freshclam/manager.c

@ -1,3 +1,8 @@
Mon Jun 2 14:57:31 CEST 2008 (tk)
----------------------------------
* freshclam: in interactive mode EXIT_n can be passed to --on-*-execute
to overwrite the default return code values (bb#465)
Mon Jun 2 13:09:57 CEST 2008 (tk)
----------------------------------
* clamd: minimize memory fragmentation after db reload (bb#1028,

@ -33,14 +33,31 @@
#endif
#include "shared/output.h"
#include "shared/options.h"
#include "execute.h"
#define MAX_CHILDREN 5
int active_children;
void execute( const char *type, const char *text )
void execute( const char *type, const char *text, const struct optstruct *opt )
{
int ret;
#ifndef C_WINDOWS
pid_t pid;
#endif
if(!opt_check(opt, "daemon")) {
if(sscanf(text, "EXIT_%d", &ret) == 1) {
logg("*%s: EXIT_%d\n", type, ret);
exit(ret);
}
if(system(text) == -1) {
logg("%s: system(%s) failed\n", type, text);
return;
}
}
#ifdef C_WINDOWS
if(active_children < MAX_CHILDREN) {
if(spawnlp(P_DETACH, text, text, NULL) == -1) {
@ -51,8 +68,6 @@ void execute( const char *type, const char *text )
} else
logg("^%s: already %d processes active.\n", type, active_children);
#else
pid_t pid;
if ( active_children<MAX_CHILDREN )
switch( pid=fork() ) {
case 0:

@ -21,6 +21,8 @@
#ifndef __EXECUTE_H
#define __EXECUTE_H
void execute( const char *type, const char *text );
#include "shared/options.h"
void execute( const char *type, const char *text, const struct optstruct *opt );
#endif

@ -192,7 +192,7 @@ static int download(const struct cfgstruct *copt, const struct optstruct *opt, c
int main(int argc, char **argv)
{
int ret = 52;
const char *newdir, *cfgfile;
const char *newdir, *cfgfile, *arg = NULL;
char *pidfile = NULL;
struct cfgstruct *copt;
const struct cfgstruct *cpt;
@ -527,15 +527,15 @@ int main(int argc, char **argv)
ret = download(copt, opt, newdir);
if(ret > 1) {
const char *arg = NULL;
if(opt_check(opt, "on-error-execute"))
arg = opt_arg(opt, "on-error-execute");
else if((cpt = cfgopt(copt, "OnErrorExecute"))->enabled)
arg = cpt->strarg;
if(arg)
execute("OnErrorExecute", arg);
execute("OnErrorExecute", arg, opt);
arg = NULL;
}
logg("#--------------------------------------\n");
@ -578,17 +578,16 @@ int main(int argc, char **argv)
} else
ret = download(copt, opt, newdir);
if(opt_check(opt, "on-error-execute")) {
if(ret > 1)
if(system(opt_arg(opt, "on-error-execute")) == -1)
logg("!system(%s) failed\n", opt_arg(opt, "on-error-execute"));
} else if((cpt = cfgopt(copt, "OnErrorExecute"))->enabled) {
if(ret > 1)
if(system(cpt->strarg) == -1)
logg("!system(%s) failed\n", cpt->strarg);
if(ret > 1) {
if(opt_check(opt, "on-error-execute"))
arg = opt_arg(opt, "on-error-execute");
else if((cpt = cfgopt(copt, "OnErrorExecute"))->enabled)
arg = cpt->strarg;
if(arg)
execute("OnErrorExecute", arg, opt);
}
if (pidfile) {
unlink(pidfile);
}

@ -1351,12 +1351,8 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
else if((cpt = cfgopt(copt, "OnUpdateExecute"))->enabled)
arg = cpt->strarg;
if(arg) {
if(opt_check(opt, "daemon"))
execute("OnUpdateExecute", arg);
else if(system(arg) == -1)
logg("!system(%s) failed\n", arg);
}
if(arg)
execute("OnUpdateExecute", arg, opt);
}
if(outdated) {
@ -1400,12 +1396,9 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
free(buffer);
}
if(newver) {
if(opt_check(opt, "daemon"))
execute("OnOutdatedExecute", cmd);
else if(system(cmd) == -1)
logg("!system(%s) failed\n", cmd);
}
if(newver)
execute("OnOutdatedExecute", cmd, opt);
free(cmd);
}
}
@ -1415,4 +1408,3 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
return updated ? 0 : 1;
}

Loading…
Cancel
Save