From 3085653819b00924caff1cdf33adf04d8ff509f0 Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Tue, 2 Dec 1997 07:44:56 +0000 Subject: [PATCH] Create database with mode 0664 & ~umask, not 0666 & ~umask. --- server/db.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/db.c b/server/db.c index f4700cb79..327a9355a 100644 --- a/server/db.c +++ b/server/db.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: db.c,v 1.16 1997/11/29 07:53:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: db.c,v 1.17 1997/12/02 07:44:56 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -201,6 +201,7 @@ void new_lease_file () char newfname [512]; char backfname [512]; TIME t; + int db_fd; /* If we already have an open database, close it. */ if (db_file) { @@ -210,8 +211,12 @@ void new_lease_file () /* Make a temporary lease file... */ GET_TIME (&t); sprintf (newfname, "%s.%d", path_dhcpd_db, (int)t); - if ((db_file = fopen (newfname, "w")) == NULL) { - error ("Can't start new lease file: %m"); + db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664); + if (db_fd < 0) { + error ("Can't create new lease file: %m"); + } + if ((db_file = fdopen (db_fd, "w")) == NULL) { + error ("Can't fdopen new lease file!"); } /* Write out all the leases that we know of... */ -- 2.47.2