Index | Thread | Search

From:
"Kirill A. Korinsky" <kirill@korins.ky>
Subject:
Re: net/isc-dhcpd: avoid uncontrolled grow of lease db
To:
ports@openbsd.org
Date:
Wed, 10 Jan 2024 16:08:17 +0100

Download raw body.

Thread
On 10.01.24 12:55, Stuart Henderson wrote:

> Missing attachment.

It was added as attechment, which apparently was removed.

Instead inlined it.

> I think we'll need to warn users about the change some way or other
> otherwise they'll lose their existing lease db and could end up issuing
> conflicting leases. Though I wonder how this works at all t the moment
> because there's a "touch dhcpd.leases" in the rc script which would
> create it owned by root if missing...

I have no idea how to warn users to be honest. Can you suggest something?

This file should be also kept as _isc-dhcp:_isc-dhcp.

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/isc-dhcp/Makefile,v
retrieving revision 1.66
diff -u -p -r1.66 Makefile
--- Makefile    27 Sep 2023 14:18:12 -0000    1.66
+++ Makefile    10 Jan 2024 15:07:00 -0000
@@ -3,7 +3,7 @@ COMMENT-client=    ISC DHCP Client
  COMMENT-omapi=    ISC DHCP OMAPI

  VERSION=    4.4.3-P1
-REVISION=    0
+REVISION=    1

  DISTNAME=    isc-dhcp-${VERSION}
  PKGNAME-main=    isc-dhcp-server-${VERSION:S/-P/pl/}
@@ -60,6 +60,8 @@ post-install:
          ${SETENV} ${MAKE_ENV} ${FAKE_SETUP} ${MAKE_PROGRAM} 
${ALL_FAKE_FLAGS} install
      ${INSTALL_DATA_DIR} ${PREFIX}/${EXAMPLEDIR}
      ${INSTALL_SCRIPT} ${FILESDIR}/dhclient-script ${PREFIX}/sbin
+    ${INSTALL_SCRIPT} ${WRKSRC}/contrib/dhcp-lease-list.pl \
+        ${PREFIX}/sbin/dhcp-lease-list
      ${INSTALL_DATA} ${WRKSRC}/server/dhcpd.conf.example \
          ${PREFIX}/${EXAMPLEDIR}/dhcpd.conf
      ${INSTALL_DATA} ${WRKSRC}/client/dhclient.conf.example \
Index: patches/patch-contrib_dhcp-lease-list_pl
===================================================================
RCS file: patches/patch-contrib_dhcp-lease-list_pl
diff -N patches/patch-contrib_dhcp-lease-list_pl
--- /dev/null    1 Jan 1970 00:00:00 -0000
+++ patches/patch-contrib_dhcp-lease-list_pl    10 Jan 2024 15:07:00 -0000
@@ -0,0 +1,12 @@
+Index: contrib/dhcp-lease-list.pl
+--- contrib/dhcp-lease-list.pl.orig
++++ contrib/dhcp-lease-list.pl
+@@ -27,7 +27,7 @@ use strict;
+ use warnings;
+ use POSIX qw(strftime);
+
+-my @LEASES = ('/var/db/dhcpd.leases', '/var/lib/dhcp/dhcpd.leases', 
'/var/lib/dhcp3/dhcpd.leases');
++my @LEASES = ('/var/db/dhcpd/dhcpd.leases', '/var/db/dhcpd.leases', 
'/var/lib/dhcp/dhcpd.leases', '/var/lib/dhcp3/dhcpd.leases');
+ my @all_leases;
+ my @leases;
+
Index: pkg/PLIST-main
===================================================================
RCS file: /cvs/ports/net/isc-dhcp/pkg/PLIST-main,v
retrieving revision 1.8
diff -u -p -r1.8 PLIST-main
--- pkg/PLIST-main    8 Nov 2022 11:14:57 -0000    1.8
+++ pkg/PLIST-main    10 Jan 2024 15:07:00 -0000
@@ -13,7 +13,13 @@
  @man man/man8/keama.8
  @bin sbin/dhcpd
  @bin sbin/dhcrelay
+@bin sbin/dhcp-lease-list
  @bin sbin/keama
  share/examples/isc-dhcp/
  share/examples/isc-dhcp/dhcpd.conf
-@extra /var/db/dhcpd.leases
+@mode 755
+@owner _isc-dhcp
+@group _isc-dhcp
+@sample /var/db/dhcpd/
+@mode 644
+@extra /var/db/dhcpd/dhcpd.leases
Index: pkg/isc_dhcpd.rc
===================================================================
RCS file: /cvs/ports/net/isc-dhcp/pkg/isc_dhcpd.rc,v
retrieving revision 1.4
diff -u -p -r1.4 isc_dhcpd.rc
--- pkg/isc_dhcpd.rc    9 Mar 2022 18:09:53 -0000    1.4
+++ pkg/isc_dhcpd.rc    10 Jan 2024 15:07:00 -0000
@@ -1,14 +1,15 @@
  #!/bin/ksh

  daemon="${TRUEPREFIX}/sbin/dhcpd"
-daemon_flags="-user _isc-dhcp -group _isc-dhcp"
+daemon_flags="-user _isc-dhcp -group _isc-dhcp -lf 
/var/db/dhcpd/dhcpd.leases"

  . /etc/rc.d/rc.subr

  rc_reload=NO

  rc_pre() {
-    touch /var/db/dhcpd.leases
+    touch /var/db/dhcpd/dhcpd.leases
+    chown _isc-dhcp:_isc-dhcp /var/db/dhcpd/dhcpd.leases
  }

  rc_cmd $1