summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2018-12-24 18:36:25 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2018-12-24 18:36:25 +0000
commitcea2764d88bb2150116abad123f9511af8008a35 (patch)
treedc6b12a252f1be1747c3b67df685ed01d778f921 /sbin/dhclient
parentb4897d13409ab7cf422562de1159f5e91bca1cde (diff)
tick_msg() needs to note that it has called go_daemon(), since
dhclient could have been started with '-d'. Which means go_daemon() may not actually daemonize. Which means isatty(STDERR_FILENO) may always return 1. Which means "... sleeping" messages would be emitted forever. e.g. running with '-d' and never successfully obtaining a lease.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 64b835b4dbb..ba91792c9fb 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.590 2018/11/12 16:46:02 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.591 2018/12/24 18:36:24 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2755,7 +2755,7 @@ lease_rebind(struct client_lease *lease)
void
tick_msg(const char *preamble, int success, time_t start)
{
- static int preamble_sent;
+ static int preamble_sent, sleeping;
static time_t stop;
time_t cur_time;
@@ -2777,7 +2777,8 @@ tick_msg(const char *preamble, int success, time_t start)
return;
}
- if (isatty(STDERR_FILENO) == 0 || cur_time < start + GRACE_SECONDS)
+ if (isatty(STDERR_FILENO) == 0 || sleeping == 1 || cur_time < start +
+ GRACE_SECONDS)
return;
if (preamble_sent == 0) {
@@ -2797,7 +2798,7 @@ tick_msg(const char *preamble, int success, time_t start)
fprintf(stderr, " sleeping\n");
fflush(stderr);
go_daemon();
- preamble_sent = 0;
+ sleeping = 1; /* OPT_FOREGROUND means isatty() == 1! */
}
}