summaryrefslogtreecommitdiff
path: root/libexec/spamd
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2004-02-26 08:50:41 +0000
committerBob Beck <beck@cvs.openbsd.org>2004-02-26 08:50:41 +0000
commitebdb5a03f64fd2720325a3979ce808b763e4bb35 (patch)
tree577fb61a29e01f1670e4d5d4141cf5d83dc15113 /libexec/spamd
parent9061aaa1229327ef9df9dfaedd501a36376ca3c4 (diff)
don't leak an fd here.
Diffstat (limited to 'libexec/spamd')
-rw-r--r--libexec/spamd/grey.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c
index 03f65b8df02..e64edac256d 100644
--- a/libexec/spamd/grey.c
+++ b/libexec/spamd/grey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grey.c,v 1.3 2004/02/26 08:18:56 deraadt Exp $ */
+/* $OpenBSD: grey.c,v 1.4 2004/02/26 08:50:40 beck Exp $ */
/*
* Copyright (c) 2004 Bob Beck. All rights reserved.
@@ -412,21 +412,22 @@ int
greywatcher(void)
{
pid_t pid;
+ int i;
pfdev = open("/dev/pf", O_RDWR);
if (pfdev == -1)
err(1, "open of /dev/pf failed");
/* check to see if /var/db/spamd exists, if not, create it */
- if (open(PATH_SPAMD_DB, O_RDWR, 0) == -1 && errno == ENOENT) {
- int i;
+ if ((i = open(PATH_SPAMD_DB, O_RDWR, 0)) == -1 && errno == ENOENT) {
i = open(PATH_SPAMD_DB, O_RDWR|O_CREAT, 0644);
if (i == -1)
err(1, "can't create %s", PATH_SPAMD_DB);
/* if we are dropping privs, chown to that user */
if (pw && (fchown(i, pw->pw_uid, pw->pw_gid) == -1))
err(1, "can't chown %s", PATH_SPAMD_DB);
- }
+ } else if (i != -1)
+ close(i);
/*
* lose root, continue as non-root user