From a3922ffaf600bcd06d7363d5e87ff9289859ce65 Mon Sep 17 00:00:00 2001 From: brian Date: Thu, 17 Aug 2006 17:12:27 +0000 Subject: Add a -p switch to dhclient. The switch tells dhclient to persist despite the interface link status. Add dhclient_flags_iface and background_dhclient_iface rc.conf options. (where iface is a specific interface). These can be used to give interface specific flags to dhclient. Reviewed by: brooks@ --- sbin/dhclient/dhclient.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sbin/dhclient/dhclient.c') diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index ce40562..22e69ba 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -295,13 +295,14 @@ main(int argc, char *argv[]) int ch, fd, quiet = 0, i = 0; int pipe_fd[2]; int immediate_daemon = 0; + int persist = 0; struct passwd *pw; /* Initially, log errors to stderr as well as to syslogd. */ openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY); setlogmask(LOG_UPTO(LOG_INFO)); - while ((ch = getopt(argc, argv, "bc:dl:qu")) != -1) + while ((ch = getopt(argc, argv, "bc:dl:pqu")) != -1) switch (ch) { case 'b': immediate_daemon = 1; @@ -315,6 +316,9 @@ main(int argc, char *argv[]) case 'l': path_dhclient_db = optarg; break; + case 'p': + persist = 1; + break; case 'q': quiet = 1; break; @@ -362,12 +366,18 @@ main(int argc, char *argv[]) fprintf(stderr, "."); fflush(stderr); if (++i > 10) { - fprintf(stderr, " giving up\n"); - exit(1); + if (persist) { + fprintf(stderr, " giving up for now\n"); + break; + } else { + fprintf(stderr, " giving up\n"); + exit(1); + } } sleep(1); } - fprintf(stderr, " got link\n"); + if (i <= 10) + fprintf(stderr, " got link\n"); } if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) -- cgit v1.1