summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-09-18 23:43:07 +0000
committerStef Walter <stef@memberwebs.com>2004-09-18 23:43:07 +0000
commitd1485c385d3ff961682a7a29be0c216c1904388a (patch)
tree895ecead2397ca8cdb6159b987cebdfe67a9fbbc /src
parent0233fd9704025b2472445448282a73dcb223adb7 (diff)
Debugging fixes for features recently added.
Diffstat (limited to 'src')
-rw-r--r--src/clamsmtpd.c29
1 files changed, 14 insertions, 15 deletions
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 <sys/types.h>
#include <sys/param.h>
+#include <sys/wait.h>
#include <paths.h>
#include <ctype.h>
@@ -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;
};
}