summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-09-19 00:21:28 +0000
committerStef Walter <stef@memberwebs.com>2004-09-19 00:21:28 +0000
commit41e4eb34e76ac2594861f93b6bb3dc25ec614dd3 (patch)
tree11367b9e1a9b0820ec241035bef8b69b94f50b1d
parente37d1d9ac4fd7663100b9855a716c674f04c8241 (diff)
Close file descriptors on exec
-rw-r--r--common/smtppass.c2
-rw-r--r--common/spio.c2
-rw-r--r--src/clamsmtpd.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index 2604a85..25522de 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -275,6 +275,7 @@ int sp_run(const char* configfile, const char* pidfile, int dbg_level)
exit(1);
}
+ fcntl(sock, F_SETFD, fcntl(sock, F_GETFD, 0) | FD_CLOEXEC);
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&true, sizeof(true));
/* Unlink the socket file if it exists */
@@ -1173,6 +1174,7 @@ int sp_write_data(spctx_t* ctx, const char* buf, int len)
return -1;
}
+ fcntl(tfd, F_SETFD, fcntl(tfd, F_GETFD, 0) | FD_CLOEXEC);
sp_messagex(ctx, LOG_DEBUG, "created cache file: %s", ctx->cachename);
}
diff --git a/common/spio.c b/common/spio.c
index 8cd315b..91e2da0 100644
--- a/common/spio.c
+++ b/common/spio.c
@@ -125,6 +125,8 @@ int spio_connect(spctx_t* ctx, spio_t* io, const struct sockaddr_any* sany,
setsockopt(io->fd, SOL_SOCKET, SO_SNDTIMEO, &(g_state.timeout), sizeof(g_state.timeout)) == -1)
sp_messagex(ctx, LOG_WARNING, "couldn't set timeouts on connection");
+ fcntl(io->fd, F_SETFD, fcntl(io->fd, F_GETFD, 0) | FD_CLOEXEC);
+
if(connect(io->fd, &SANY_ADDR(*sany), SANY_LEN(*sany)) == -1)
RETURN(-1);
diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c
index 34a53a3..fdf6aa8 100644
--- a/src/clamsmtpd.c
+++ b/src/clamsmtpd.c
@@ -676,7 +676,7 @@ static int virus_action(clctx_t* ctx, const char* virus)
/* The child */
case 0:
- /* Close all descriptors */
+ /* Close std descriptors */
for(i = 0; i <= 2; i++)
close(i);