diff options
author | 2017-11-18 16:33:25 +0000 | |
---|---|---|
committer | 2017-11-18 16:33:25 +0000 | |
commit | da29bca4015fd1ec6c97be66693547d9fca99923 (patch) | |
tree | da5c565297872322943a14139c997f7727420b76 | |
parent | Submit incoming packets to the network stack in batches like is done (diff) | |
download | wireguard-openbsd-da29bca4015fd1ec6c97be66693547d9fca99923.tar.xz wireguard-openbsd-da29bca4015fd1ec6c97be66693547d9fca99923.zip |
Generate correct time comments (renewal/rebind/expiry) in
dhclient.leases and the 'offered' lease generated by -L. i.e. the
times contained in the actual offer, and not the 'effective' times
that reflect changes imposed by dhclient.conf or -i.
-rw-r--r-- | sbin/dhclient/dhclient.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 008bcc3ea09..7e619b7eb36 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.523 2017/11/14 17:48:48 mpi Exp $ */ +/* $OpenBSD: dhclient.c,v 1.524 2017/11/18 16:33:25 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1907,6 +1907,7 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease) char timebuf[27]; /* 6 2017/04/08 05:47:50 UTC; */ struct option_data *opt; char *buf, *name; + time_t renewal, rebind, expiry; size_t rslt; int i; @@ -1968,6 +1969,16 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease) append_statement(string, sizeof(string), " epoch ", buf); free(buf); + /* + * Save lease times, generate new ones based on lease info + * rather than effective times, print out lease-based times, + * restore effective times. + */ + renewal = lease->renewal; + rebind = lease->rebind; + expiry = lease->expiry; + set_lease_times(lease); + rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, gmtime(&lease->renewal)); if (rslt == 0) @@ -1986,6 +1997,10 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease) return NULL; append_statement(string, sizeof(string), " expire ", timebuf); + lease->renewal = renewal; + lease->rebind = rebind; + lease->expiry = expiry; + rslt = strlcat(string, "}\n", sizeof(string)); if (rslt >= sizeof(string)) return NULL; |