]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Record ddns information.
authorTed Lemon <source@isc.org>
Thu, 1 Jul 1999 19:55:12 +0000 (19:55 +0000)
committerTed Lemon <source@isc.org>
Thu, 1 Jul 1999 19:55:12 +0000 (19:55 +0000)
- Test names for printability using db_printable instead of doing it inline.

server/db.c

index fc4467f8c43cd241a8629af470bb5b65a87cb727..cc055b9fb5f615ed35b9e783314386cd09d65664 100644 (file)
 
 #ifndef lint
 static char copyright[] =
-"$Id: db.c,v 1.24 1999/05/06 20:28:29 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: db.c,v 1.25 1999/07/01 19:55:12 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
+#include <ctype.h>
 
 FILE *db_file;
 
@@ -123,11 +124,24 @@ int write_lease (lease)
                        ++errors;
                }
        }
-       if (lease -> client_hostname) {
-               for (i = 0; lease -> client_hostname [i]; i++)
-                       if (lease -> client_hostname [i] < 33 ||
-                           lease -> client_hostname [i] > 126)
-                               goto bad_client_hostname;
+       if (lease -> ddns_fwd_name && db_printable (lease -> ddns_fwd_name)) {
+               errno = 0;
+               fprintf (db_file, "\n\tddns-fwd-name \"%s\";",
+                        lease -> ddns_fwd_name);
+               if (errno) {
+                       ++errors;
+               }
+       }
+       if (lease -> ddns_rev_name && db_printable (lease -> ddns_rev_name)) {
+               errno = 0;
+               fprintf (db_file, "\n\tddns-rev-name \"%s\";",
+                        lease -> ddns_rev_name);
+               if (errno) {
+                       ++errors;
+               }
+       }
+       if (lease -> client_hostname &&
+           db_printable (lease -> client_hostname)) {
                errno = 0;
                fprintf (db_file, "\n\tclient-hostname \"%s\";",
                         lease -> client_hostname);
@@ -135,12 +149,7 @@ int write_lease (lease)
                        ++errors;
                }
        }
-       bad_client_hostname:
-       if (lease -> hostname) {
-               for (i = 0; lease -> hostname [i]; i++)
-                       if (lease -> hostname [i] < 33 ||
-                           lease -> hostname [i] > 126)
-                               goto bad_hostname;
+       if (lease -> hostname && db_printable (lease -> hostname)) {
                errno = 0;
                errno = 0;
                fprintf (db_file, "\n\thostname \"%s\";",
@@ -149,7 +158,6 @@ int write_lease (lease)
                        ++errors;
                }
        }
-       bad_hostname:
        errno = 0;
        fputs ("\n}\n", db_file);
        if (errno) {
@@ -161,6 +169,16 @@ int write_lease (lease)
        return !errors;
 }
 
+int db_printable (s)
+       char *s;
+{
+       int i;
+       for (i = 0; s [i]; i++)
+               if (!isascii (s [i]) || !isprint (s [i]))
+                       return 0;
+       return 1;
+}
+
 /* Write a spawned class to the database file. */
 
 int write_billing_class (class)