From ff95ba1861c7b7092df036fe53dd9a9e7d4537bf Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 4 Mar 2021 02:00:42 +0000 Subject: [PATCH] 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! --- sbin/dhclient/dhclient.c | 10 +++++----- 1 file 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 @@ -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. */ -- 2.20.1