From: Ted Lemon Date: Thu, 1 Jul 1999 19:55:12 +0000 (+0000) Subject: - Record ddns information. X-Git-Tag: V3-BETA-1-PATCH-0~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ebffe9c748a7d44a0ed6fce9fb3f5fe23fa7a40;p=thirdparty%2Fdhcp.git - Record ddns information. - Test names for printability using db_printable instead of doing it inline. --- diff --git a/server/db.c b/server/db.c index fc4467f8c..cc055b9fb 100644 --- a/server/db.c +++ b/server/db.c @@ -22,10 +22,11 @@ #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 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)