summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/dhcp/dhclient/dhclient.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/dhcp/dhclient/dhclient.c b/usr.sbin/dhcp/dhclient/dhclient.c
index 6ff387acd26..d9934182b70 100644
--- a/usr.sbin/dhcp/dhclient/dhclient.c
+++ b/usr.sbin/dhcp/dhclient/dhclient.c
@@ -56,7 +56,7 @@
#ifndef lint
static char copyright[] =
-"$Id: dhclient.c,v 1.13 2001/01/03 16:04:39 ericj Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.14 2001/01/06 19:55:06 angelos Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -117,7 +117,7 @@ int main (argc, argv, envp)
int argc;
char **argv, **envp;
{
- int i;
+ int i, fd;
struct servent *ent;
struct interface_info *ip;
@@ -180,12 +180,20 @@ int main (argc, argv, envp)
/* Parse the dhclient.conf file. */
read_client_conf ();
+ /* Lock the leases file */
+ fd = open(path_dhclient_db, O_RDONLY | O_EXLOCK, 0);
+ if (fd < 0)
+ error ("can't open and lock %s: %m", path_dhclient_db);
+
/* Parse the lease database. */
read_client_leases ();
/* Rewrite the lease database... */
rewrite_client_leases ();
+ /* Close and unlock */
+ close(fd);
+
/* If no broadcast interfaces were discovered, call the script
and tell it so. */
if (!interfaces) {