Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysutils/dhcpleases: change duplicate hostname expiration handling. Fix #13321 #1176

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sysutils/dhcpleases/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# $FreeBSD$

PORTNAME= dhcpleases
PORTVERSION= 0.5
PORTVERSION= 0.6
PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= # empty
Expand Down
19 changes: 6 additions & 13 deletions sysutils/dhcpleases/files/dhcpleases.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ load_dhcp(FILE *fp, char *leasefile, char *domain_sufix, time_t now)
if ((tts != -1) && (ttd == tts - 1))
ttd = (time_t)0;

/* Skip expired leases */
if (ttd != (time_t)0 &&
difftime(now, ttd) > 0) {
continue;
}

if ((dot = strchr(hostname, '.'))) {
if (!domain_suffix ||
hostname_isequal(dot+1, domain_suffix)) {
Expand Down Expand Up @@ -420,19 +426,6 @@ load_dhcp(FILE *fp, char *leasefile, char *domain_sufix, time_t now)
}
}

/* prune expired leases */
LIST_FOREACH_SAFE(lease, &leases, next, tmp) {
if (lease->expires != (time_t)0 &&
difftime(now, lease->expires) > 0) {
if (lease->name)
free(lease->name);
if (lease->fqdn)
free(lease->fqdn);
LIST_REMOVE(lease, next);
free(lease);
}
}

return (0);
}

Expand Down