Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/dhcp/client create the dhclient.leases file mode 600 fo...



details:   https://anonhg.NetBSD.org/src/rev/5886a419eaf2
branches:  trunk
changeset: 565303:5886a419eaf2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Apr 04 02:35:21 2004 +0000

description:
create the dhclient.leases file mode 600 for now as it may contain
"media" lines that contain wireless network keys, that eg, ifconfig(8)
carefully hides.

this is not a complete solution, but it's OK until one arrives.

approved by mellon@.  fixes the problem described in PR#22271.

diffstat:

 dist/dhcp/client/dhclient.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 7720d5c0716b -r 5886a419eaf2 dist/dhcp/client/dhclient.c
--- a/dist/dhcp/client/dhclient.c       Sun Apr 04 02:09:34 2004 +0000
+++ b/dist/dhcp/client/dhclient.c       Sun Apr 04 02:35:21 2004 +0000
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static char ocopyright[] =
-"$Id: dhclient.c,v 1.11 2004/04/02 22:53:15 mellon Exp $ Copyright (c) 1995-2002 Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.12 2004/04/04 02:35:21 mrg Exp $ Copyright (c) 1995-2002 Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -2131,11 +2131,14 @@
        struct interface_info *ip;
        struct client_state *client;
        struct client_lease *lp;
+       int fd;
 
        if (leaseFile)
                fclose (leaseFile);
-       leaseFile = fopen (path_dhclient_db, "w");
-       if (!leaseFile) {
+       fd = open (path_dhclient_db, O_WRONLY|O_CREAT, 0600);
+       if (fd != -1)
+               leaseFile = fdopen (fd, "w");
+       if (fd == -1 || !leaseFile) {
                log_error ("can't create %s: %m", path_dhclient_db);
                return;
        }
@@ -2225,8 +2228,12 @@
                return 1;
 
        if (!leaseFile) {       /* XXX */
-               leaseFile = fopen (path_dhclient_db, "w");
-               if (!leaseFile) {
+               int fd;
+
+               fd = open (path_dhclient_db, O_WRONLY|O_CREAT, 0600);
+               if (fd != -1)
+                       leaseFile = fdopen (fd, "w");
+               if (fd == -1 || !leaseFile) {
                        log_error ("can't create %s: %m", path_dhclient_db);
                        return 0;
                }



Home | Main Index | Thread Index | Old Index