From d1485c385d3ff961682a7a29be0c216c1904388a Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 18 Sep 2004 23:43:07 +0000 Subject: Debugging fixes for features recently added. --- src/clamsmtpd.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c index f1d6e75..34a53a3 100644 --- a/src/clamsmtpd.c +++ b/src/clamsmtpd.c @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -327,14 +328,16 @@ int cb_check_data(spctx_t* sp) const char* virus; clctx_t* ctx = (clctx_t*)sp; - /* Connect to clamav */ - if(!spio_valid(&(ctx->clam))) - r = connect_clam(ctx); - - if(r != -1 && (r = sp_cache_data(sp)) > 0) + /* ClamAV doesn't like empty files */ + if((r = sp_cache_data(sp)) > 0) + { + /* Connect to clamav */ + if(!spio_valid(&(ctx->clam))) + r = connect_clam(ctx); - /* ClamAV doesn't like empty files */ - r = clam_scan_file(ctx, &virus); + if(r != -1) + r = clam_scan_file(ctx, &virus); + } switch(r) { @@ -659,6 +662,9 @@ static int virus_action(clctx_t* ctx, const char* virus) if(g_clstate.virusaction != NULL) { + /* Cleanup any old actions */ + while(waitpid(-1, &i, WNOHANG) > 0) + ; sp_messagex(sp, LOG_DEBUG, "executing virus action: %s", g_clstate.virusaction); @@ -670,13 +676,6 @@ static int virus_action(clctx_t* ctx, const char* virus) /* The child */ case 0: - /* - * New process group because we don't care about this child, - * it's return value, waiting for it to exit or any of that. - * Apparently this can't fail when done like this. - */ - setsid(); - /* Close all descriptors */ for(i = 0; i <= 2; i++) close(i); @@ -696,7 +695,7 @@ static int virus_action(clctx_t* ctx, const char* virus) /* If that returned then there was an error, but there's * not much we can do about it. */ - exit(1); + _exit(1); break; }; } -- cgit v1.2.3