diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-04-20 21:25:08 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-04-20 21:25:08 +0000 |
commit | dfc691e80928339783587845ab82af2504714f30 (patch) | |
tree | 163a1193d7e4e8a631198a0a858c6dba9f50374d /sbin | |
parent | d83d30bd8e4d4f8e9f4f7ad86d95f26855babd79 (diff) |
Make -L even more useful to monitoring processes. Truncate and
refill the file rather than creating a new one, which preserves
an fd being monitored. And truncate file on losing link.
Things like sysutils/ertn should now be able to see new leases, lease
renewals and cable unplugs.
tweaks by and ok sthen@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.8 | 14 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 14 |
2 files changed, 19 insertions, 9 deletions
diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8 index 0028a412022..cf2e6c3dfcd 100644 --- a/sbin/dhclient/dhclient.8 +++ b/sbin/dhclient/dhclient.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhclient.8,v 1.24 2013/08/22 19:15:41 jmc Exp $ +.\" $OpenBSD: dhclient.8,v 1.25 2014/04/20 21:25:07 krw Exp $ .\" .\" Copyright (c) 1997 The Internet Software Consortium. .\" All rights reserved. @@ -35,7 +35,7 @@ .\" Enterprises. To learn more about the Internet Software Consortium, .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. -.Dd $Mdocdate: August 22 2013 $ +.Dd $Mdocdate: April 20 2014 $ .Dt DHCLIENT 8 .Os .Sh NAME @@ -114,9 +114,13 @@ to write two pseudo-leases, and .Dq effective , to the specified file. -The offered block will contain the lease offered by the DHCP server; -the effective block will contain the modified lease used to configure the -interface. +.Dq offered +will be the lease offered by the DHCP server; +.Dq effective +will be the modified lease bound to the interface. +.Ar file +will be truncated when a lease is no longer bound to the interface or the +link goes down. .It Fl l Ar file Specify an alternate location to .Pa /var/db/dhclient.leases. Ns Aq Ar IFNAME diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index b0def3be04f..8f50b17c8b4 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.297 2014/04/17 13:46:48 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.298 2014/04/20 21:25:07 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -348,6 +348,11 @@ routehandler(void) client->state = S_REBOOTING; state_reboot(); } else { + /* Let monitoring programs see link loss. */ + write_file(path_option_db, + O_WRONLY | O_CREAT | O_TRUNC | O_SYNC | + O_EXLOCK | O_NOFOLLOW, S_IRUSR | S_IWUSR | + S_IRGRP, 0, 0, "", 0); /* No need to wait for anything but link. */ cancel_timeout(); } @@ -1955,10 +1960,11 @@ fork_privchld(int fd, int fd2) close(fd); if (strlen(path_option_db)) { - rslt = unlink(path_option_db); + /* Truncate the file so monitoring process see exit. */ + rslt = truncate(path_option_db, 0); if (rslt == -1) - warning("Could not unlink '%s': %s", - path_option_db, strerror(errno)); + warning("Unable to truncate '%s': %s", path_option_db, + strerror(errno)); } /* |