summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-10-23 15:15:23 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-10-23 15:15:23 +0000
commit427b3e34a2cf05064f11372bc41ba1d72687f291 (patch)
tree86ada348bf0d50b0e88908a5b345ef092b148dd6 /usr.sbin
parent8dfafb1a51ce47117fce58dfa86068454c0dd324 (diff)
Close the socket (and dfd) in at(1) child processes
Fixes a failure at restart if a child process still has the socket opened. Spotted by millert@, ok friehm@ millert@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cron/atrun.c6
-rw-r--r--usr.sbin/cron/cron.c4
-rw-r--r--usr.sbin/cron/globals.h3
3 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index 6f08809a341..bc2e3098bad 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.46 2017/06/08 16:23:39 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.47 2017/10/23 15:15:22 jca Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -283,6 +283,10 @@ run_job(const atjob *job, int dfd, const char *atfile)
return;
}
+ /* Close fds opened by the parent. */
+ close(cronSock);
+ close(dfd);
+
/*
* We don't want the main cron daemon to wait for our children--
* we will do it ourselves via waitpid().
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index f76d95a1de2..8fa4f8e97b6 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.76 2017/06/07 23:36:43 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.77 2017/10/23 15:15:22 jca Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -60,7 +60,6 @@ static int open_socket(void);
static volatile sig_atomic_t got_sigchld;
static time_t timeRunning, virtualTime, clockTime;
-static int cronSock;
static long GMToff;
static cron_db *database;
static at_db *at_database;
@@ -68,6 +67,7 @@ static double batch_maxload = BATCH_MAXLOAD;
static int NoFork;
static time_t StartTime;
gid_t cron_gid;
+ int cronSock;
static void
usage(void)
diff --git a/usr.sbin/cron/globals.h b/usr.sbin/cron/globals.h
index 811ec7b5562..78cd51b62cf 100644
--- a/usr.sbin/cron/globals.h
+++ b/usr.sbin/cron/globals.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: globals.h,v 1.14 2017/06/07 23:36:43 millert Exp $ */
+/* $OpenBSD: globals.h,v 1.15 2017/10/23 15:15:22 jca Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -18,5 +18,6 @@
*/
extern gid_t cron_gid;
+extern int cronSock;
extern int LineNumber;
extern char *__progname;