summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2021-03-04 02:00:42 +0000
committerkrw <krw@openbsd.org>2021-03-04 02:00:42 +0000
commitff95ba1861c7b7092df036fe53dd9a9e7d4537bf (patch)
tree2a02aa3361d36c1c2b53af918fd37d8d4e25849b /sbin/dhclient
parentNever automatically rewrite perl/dist/Devel-PPPort/t/01_test.t (diff)
downloadwireguard-openbsd-ff95ba1861c7b7092df036fe53dd9a9e7d4537bf.tar.xz
wireguard-openbsd-ff95ba1861c7b7092df036fe53dd9a9e7d4537bf.zip
Notice when link-timeout expires even if istty(STDERR) hints that dhclient has
already gone daemon. Sometimes it's just that 2>/dev/null or something has been done. Should fix problem with sysupgrade when an interface (e.g. a wired interface that has no cable plugged in) never comes up. Problem reported and debug info from kettenis@, Jean-Philippe Luigi, Thomas L. and Markus Lude. Thanks!
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 63fa1334767..4260a8806fa 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.708 2021/03/02 14:32:14 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.709 2021/03/04 02:00:42 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2643,9 +2643,6 @@ tick_msg(const char *preamble, int action)
static int linkup, preamble_sent, sleeping;
int printmsg;
- if (isatty(STDERR_FILENO) == 0 || sleeping == 1)
- return;
-
clock_gettime(CLOCK_REALTIME, &now);
if (!timespecisset(&stop)) {
@@ -2654,7 +2651,10 @@ tick_msg(const char *preamble, int action)
timespecadd(&now, &grace_intvl, &grace);
return;
}
- if (timespeccmp(&now, &grace, <))
+
+ if (isatty(STDERR_FILENO) == 0 || sleeping == 1)
+ printmsg = 0; /* Already in the background. */
+ else if (timespeccmp(&now, &grace, <))
printmsg = 0; /* Wait a bit before speaking. */
else if (linkup && strcmp("link", preamble) == 0)
printmsg = 0; /* One 'got link' is enough for anyone. */