From cea2764d88bb2150116abad123f9511af8008a35 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Mon, 24 Dec 2018 18:36:25 +0000 Subject: 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. --- sbin/dhclient/dhclient.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sbin/dhclient') 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 @@ -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! */ } } -- cgit v1.2.3