SHA256
1
0
forked from pool/dhcp
dhcp/0006-dhcp-4.3.2-dhclient-send-hostname-or-fqdn.patch

129 lines
3.9 KiB
Diff
Raw Permalink Normal View History

From ec55fe43e597e5ea0f8dff5b8edef091c0911801 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Thu, 18 Aug 2011 10:49:07 +0200
Subject: [PATCH] dhcp-4.3.2-dhclient-send-hostname-or-fqdn
Signed-off-by: Marius Tomaschewski <mt@suse.de>
Accepting request 866365 from home:dirkmueller:branches:network:dhcp - update to 4.4.2: * Please note that that ISC DHCP is now licensed under the Mozilla Public License, MPL 2.0. In general, the areas of focus for ISC DHCP 4.4 were: 1. Dynamic DNS additions 2. dhclient improvements 3. Support for dynamic shared libraries * Added the interface name to socket initialization failure log messages. Prior to this the log messages stated only the error reason without stating the target interface. * Corrected buffer pointer logic in dhcrelay functions that manipulate agent relay options. Thanks to Thomas Imbert of MSRC Vulnerabilities & Mitigations for reporting the issue. * Corrected unresolved symbol errors building relay_unittests when configured to build using libtool. * A new configuration parameter, ping-cltt-secs (v4 operation only), has been added to allow the user to specify the number of seconds that must elapse since CLTT before a ping check is conducted. Prior to this, the value was hard coded at 60 seconds. Please see the server man pages for a more detailed discussion. * A new configuration parameter, ping-timeout-ms (v4 operation only), has been added that allows the user to specify the amount of time the server waits for a ping-check response in milliseconds rather than in seconds (via ping-timeout). When greater than zero, the value of ping-timeout-ms will override the value of ping-timeout. Thanks to Jay Doran from Bluecat Networks for suggesting this feature. * An experimental tool called, Keama (KEA Migration Assistant), which helps translate ISC DHCP configurations to Kea configurations, is now included in the distribution. * Corrected a misuse of the BIND9 DDNS API which caused DDNS updates to be OBS-URL: https://build.opensuse.org/request/show/866365 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=224
2021-02-10 15:21:23 +01:00
Index: dhcp-4.4.2/client/dhclient.8
===================================================================
--- dhcp-4.4.2.orig/client/dhclient.8
+++ dhcp-4.4.2/client/dhclient.8
@@ -73,6 +73,10 @@ dhclient - Dynamic Host Configuration Pr
.I LL|LLT
]
[
+.B -H
+.I hostname
+]
+[
.B -p
.I port-number
]
Accepting request 866365 from home:dirkmueller:branches:network:dhcp - update to 4.4.2: * Please note that that ISC DHCP is now licensed under the Mozilla Public License, MPL 2.0. In general, the areas of focus for ISC DHCP 4.4 were: 1. Dynamic DNS additions 2. dhclient improvements 3. Support for dynamic shared libraries * Added the interface name to socket initialization failure log messages. Prior to this the log messages stated only the error reason without stating the target interface. * Corrected buffer pointer logic in dhcrelay functions that manipulate agent relay options. Thanks to Thomas Imbert of MSRC Vulnerabilities & Mitigations for reporting the issue. * Corrected unresolved symbol errors building relay_unittests when configured to build using libtool. * A new configuration parameter, ping-cltt-secs (v4 operation only), has been added to allow the user to specify the number of seconds that must elapse since CLTT before a ping check is conducted. Prior to this, the value was hard coded at 60 seconds. Please see the server man pages for a more detailed discussion. * A new configuration parameter, ping-timeout-ms (v4 operation only), has been added that allows the user to specify the amount of time the server waits for a ping-check response in milliseconds rather than in seconds (via ping-timeout). When greater than zero, the value of ping-timeout-ms will override the value of ping-timeout. Thanks to Jay Doran from Bluecat Networks for suggesting this feature. * An experimental tool called, Keama (KEA Migration Assistant), which helps translate ISC DHCP configurations to Kea configurations, is now included in the distribution. * Corrected a misuse of the BIND9 DDNS API which caused DDNS updates to be OBS-URL: https://build.opensuse.org/request/show/866365 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=224
2021-02-10 15:21:23 +01:00
@@ -353,6 +357,11 @@ transmits these messages to 255.255.255.
address). Overriding this is mostly useful for debugging purposes. This
feature is not supported in DHCPv6 (\fB-6\fR) mode.
.TP
+.BI \-H \ hostname
+This flag may be used to specify a client hostname that should be sent to
+the DHCP server as host-name (ipv4 only) or fqdn to perform dns update.
+Note, that this option is a SUSE/Novell extension.
+.TP
.BI \-g \ relay
.\" mockup relay
Set the giaddr field of all packets to the \fIrelay\fR IP address
Accepting request 866365 from home:dirkmueller:branches:network:dhcp - update to 4.4.2: * Please note that that ISC DHCP is now licensed under the Mozilla Public License, MPL 2.0. In general, the areas of focus for ISC DHCP 4.4 were: 1. Dynamic DNS additions 2. dhclient improvements 3. Support for dynamic shared libraries * Added the interface name to socket initialization failure log messages. Prior to this the log messages stated only the error reason without stating the target interface. * Corrected buffer pointer logic in dhcrelay functions that manipulate agent relay options. Thanks to Thomas Imbert of MSRC Vulnerabilities & Mitigations for reporting the issue. * Corrected unresolved symbol errors building relay_unittests when configured to build using libtool. * A new configuration parameter, ping-cltt-secs (v4 operation only), has been added to allow the user to specify the number of seconds that must elapse since CLTT before a ping check is conducted. Prior to this, the value was hard coded at 60 seconds. Please see the server man pages for a more detailed discussion. * A new configuration parameter, ping-timeout-ms (v4 operation only), has been added that allows the user to specify the amount of time the server waits for a ping-check response in milliseconds rather than in seconds (via ping-timeout). When greater than zero, the value of ping-timeout-ms will override the value of ping-timeout. Thanks to Jay Doran from Bluecat Networks for suggesting this feature. * An experimental tool called, Keama (KEA Migration Assistant), which helps translate ISC DHCP configurations to Kea configurations, is now included in the distribution. * Corrected a misuse of the BIND9 DDNS API which caused DDNS updates to be OBS-URL: https://build.opensuse.org/request/show/866365 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=224
2021-02-10 15:21:23 +01:00
Index: dhcp-4.4.2/client/dhclient.c
===================================================================
--- dhcp-4.4.2.orig/client/dhclient.c
+++ dhcp-4.4.2/client/dhclient.c
@@ -185,6 +185,7 @@ static const char use_v6command[] = "Com
#endif
#define DHCLIENT_USAGEC \
+" [-H hostname]\n" \
" [-s server-addr] [-cf config-file]\n" \
" [-df duid-file] [-lf lease-file]\n" \
" [-pf pid-file] [--no-pid] [-e VAR=val]\n" \
@@ -235,6 +236,7 @@ main(int argc, char **argv) {
int no_dhclient_db = 0;
int no_dhclient_pid = 0;
int no_dhclient_script = 0;
+ char *dhclient_hostname = NULL;
#ifdef DHCPv6
int local_family_set = 0;
Accepting request 508601 from home:ndas:branches:network:dhcp - fixed a typo in nis-servers option name breaking the config file introduced in previous change to workaround issues in NetworkManager parser. - Update to dhcp-4.3.5 - Corrected a bug which could cause the server to sporadically crash while loading lease files with the lease-id-format is set to "hex". Our thanks to Jay Ford, University of Iowa for reporting the issue. [ISC-Bugs #43185] - Eliminated a noisy, but otherwise harmless debug log statment that may appear during server startup when building with --enable-binary-leases and configuring multiple pools in a shared network. Thanks to Fernando Soto from BlueCat Networks for reporting the issue and supplying a patch. [ISC-Bugs #43262] - Fixed util/bindvar.sh error handling. [ISC-Bugs #41973] - Correct error message in relay to use remote id length instead of circuit id length. [ISC-Bugs #42556] - Add logic to test directory Makefiles to avoid copying Attfile(s) when building within the source tree. This eliminates a noisy but otherwise harmless error message when running "make check". [ISC-Bugs #41883] - Leases are now scrubbed of certain prior use information when pool re-balancing reassigns them from one FO peer to the other. This corrects an issue where leases that were offered but not used by the client retained the client hostname from the original client. Thanks to Pavel Polacek, Jan Evangelista Purkyne University for reporting the issue. [ISC-Bugs #42008] - In the LDAP code and schema add some missing '6' characters to use the v6 instead of the v4 versions. Thanks to Denis Taranushin for OBS-URL: https://build.opensuse.org/request/show/508601 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=174
2017-07-06 17:49:46 +02:00
#ifdef DHCP4o6
Accepting request 866365 from home:dirkmueller:branches:network:dhcp - update to 4.4.2: * Please note that that ISC DHCP is now licensed under the Mozilla Public License, MPL 2.0. In general, the areas of focus for ISC DHCP 4.4 were: 1. Dynamic DNS additions 2. dhclient improvements 3. Support for dynamic shared libraries * Added the interface name to socket initialization failure log messages. Prior to this the log messages stated only the error reason without stating the target interface. * Corrected buffer pointer logic in dhcrelay functions that manipulate agent relay options. Thanks to Thomas Imbert of MSRC Vulnerabilities & Mitigations for reporting the issue. * Corrected unresolved symbol errors building relay_unittests when configured to build using libtool. * A new configuration parameter, ping-cltt-secs (v4 operation only), has been added to allow the user to specify the number of seconds that must elapse since CLTT before a ping check is conducted. Prior to this, the value was hard coded at 60 seconds. Please see the server man pages for a more detailed discussion. * A new configuration parameter, ping-timeout-ms (v4 operation only), has been added that allows the user to specify the amount of time the server waits for a ping-check response in milliseconds rather than in seconds (via ping-timeout). When greater than zero, the value of ping-timeout-ms will override the value of ping-timeout. Thanks to Jay Doran from Bluecat Networks for suggesting this feature. * An experimental tool called, Keama (KEA Migration Assistant), which helps translate ISC DHCP configurations to Kea configurations, is now included in the distribution. * Corrected a misuse of the BIND9 DDNS API which caused DDNS updates to be OBS-URL: https://build.opensuse.org/request/show/866365 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=224
2021-02-10 15:21:23 +01:00
@@ -434,6 +436,24 @@ main(int argc, char **argv) {
if (++i == argc)
Accepting request 508601 from home:ndas:branches:network:dhcp - fixed a typo in nis-servers option name breaking the config file introduced in previous change to workaround issues in NetworkManager parser. - Update to dhcp-4.3.5 - Corrected a bug which could cause the server to sporadically crash while loading lease files with the lease-id-format is set to "hex". Our thanks to Jay Ford, University of Iowa for reporting the issue. [ISC-Bugs #43185] - Eliminated a noisy, but otherwise harmless debug log statment that may appear during server startup when building with --enable-binary-leases and configuring multiple pools in a shared network. Thanks to Fernando Soto from BlueCat Networks for reporting the issue and supplying a patch. [ISC-Bugs #43262] - Fixed util/bindvar.sh error handling. [ISC-Bugs #41973] - Correct error message in relay to use remote id length instead of circuit id length. [ISC-Bugs #42556] - Add logic to test directory Makefiles to avoid copying Attfile(s) when building within the source tree. This eliminates a noisy but otherwise harmless error message when running "make check". [ISC-Bugs #41883] - Leases are now scrubbed of certain prior use information when pool re-balancing reassigns them from one FO peer to the other. This corrects an issue where leases that were offered but not used by the client retained the client hostname from the original client. Thanks to Pavel Polacek, Jan Evangelista Purkyne University for reporting the issue. [ISC-Bugs #42008] - In the LDAP code and schema add some missing '6' characters to use the v6 instead of the v4 versions. Thanks to Denis Taranushin for OBS-URL: https://build.opensuse.org/request/show/508601 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=174
2017-07-06 17:49:46 +02:00
usage(use_noarg, argv[i-1]);
mockup_relay = argv[i];
+ } else if (!strcmp (argv[i], "-H")) {
+ size_t len;
+ if (++i == argc || !argv[i] || *(argv[i]) == '\0')
Accepting request 508601 from home:ndas:branches:network:dhcp - fixed a typo in nis-servers option name breaking the config file introduced in previous change to workaround issues in NetworkManager parser. - Update to dhcp-4.3.5 - Corrected a bug which could cause the server to sporadically crash while loading lease files with the lease-id-format is set to "hex". Our thanks to Jay Ford, University of Iowa for reporting the issue. [ISC-Bugs #43185] - Eliminated a noisy, but otherwise harmless debug log statment that may appear during server startup when building with --enable-binary-leases and configuring multiple pools in a shared network. Thanks to Fernando Soto from BlueCat Networks for reporting the issue and supplying a patch. [ISC-Bugs #43262] - Fixed util/bindvar.sh error handling. [ISC-Bugs #41973] - Correct error message in relay to use remote id length instead of circuit id length. [ISC-Bugs #42556] - Add logic to test directory Makefiles to avoid copying Attfile(s) when building within the source tree. This eliminates a noisy but otherwise harmless error message when running "make check". [ISC-Bugs #41883] - Leases are now scrubbed of certain prior use information when pool re-balancing reassigns them from one FO peer to the other. This corrects an issue where leases that were offered but not used by the client retained the client hostname from the original client. Thanks to Pavel Polacek, Jan Evangelista Purkyne University for reporting the issue. [ISC-Bugs #42008] - In the LDAP code and schema add some missing '6' characters to use the v6 instead of the v4 versions. Thanks to Denis Taranushin for OBS-URL: https://build.opensuse.org/request/show/508601 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=174
2017-07-06 17:49:46 +02:00
+ usage(use_noarg, argv[i-1]);
+ len = strlen (argv[i]);
+ if (len > HOST_NAME_MAX) {
+ log_error("-H option hostname string \"%s\" is too long:"
+ "maximum length is %d characters",
+ argv[i], HOST_NAME_MAX);
+ exit(1);
+ } else if(check_domain_name(argv[i], len,
+ local_family == AF_INET6 ? 1 : 0) != 0) {
+ log_error("suspect %s in -H option: \"%s\"",
+ local_family == AF_INET6 ? "fqdn" : "hostname",
+ argv[i]);
+ exit(1);
+ }
+ dhclient_hostname = argv [i];
} else if (!strcmp(argv[i], "-nw")) {
nowait = 1;
} else if (!strcmp(argv[i], "-n")) {
Accepting request 866365 from home:dirkmueller:branches:network:dhcp - update to 4.4.2: * Please note that that ISC DHCP is now licensed under the Mozilla Public License, MPL 2.0. In general, the areas of focus for ISC DHCP 4.4 were: 1. Dynamic DNS additions 2. dhclient improvements 3. Support for dynamic shared libraries * Added the interface name to socket initialization failure log messages. Prior to this the log messages stated only the error reason without stating the target interface. * Corrected buffer pointer logic in dhcrelay functions that manipulate agent relay options. Thanks to Thomas Imbert of MSRC Vulnerabilities & Mitigations for reporting the issue. * Corrected unresolved symbol errors building relay_unittests when configured to build using libtool. * A new configuration parameter, ping-cltt-secs (v4 operation only), has been added to allow the user to specify the number of seconds that must elapse since CLTT before a ping check is conducted. Prior to this, the value was hard coded at 60 seconds. Please see the server man pages for a more detailed discussion. * A new configuration parameter, ping-timeout-ms (v4 operation only), has been added that allows the user to specify the amount of time the server waits for a ping-check response in milliseconds rather than in seconds (via ping-timeout). When greater than zero, the value of ping-timeout-ms will override the value of ping-timeout. Thanks to Jay Doran from Bluecat Networks for suggesting this feature. * An experimental tool called, Keama (KEA Migration Assistant), which helps translate ISC DHCP configurations to Kea configurations, is now included in the distribution. * Corrected a misuse of the BIND9 DDNS API which caused DDNS updates to be OBS-URL: https://build.opensuse.org/request/show/866365 OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=224
2021-02-10 15:21:23 +01:00
@@ -759,6 +779,48 @@ main(int argc, char **argv) {
/* Parse the dhclient.conf file. */
read_client_conf();
+ /* If the user specified a hostname, send it here and now */
+ if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) {
+ struct parse *cfile = NULL;
+ char buf[1024] = {'\0'};
+ int len;
+
+ if (strchr(dhclient_hostname, '.')) {
+ len = strlen(dhclient_hostname);
+ snprintf (buf, sizeof(buf),
+ "send fqdn.fqdn \"%s%s\";\n"
+ "send fqdn.encoded on;\n"
+ "send fqdn.server-update on;\n"
+ "also request %s;\n",
+ dhclient_hostname,
+ dhclient_hostname[len - 1] == '.' ? "" : ".",
+ local_family == AF_INET6 ? "dhcp6.fqdn" : "fqdn");
+ } else if (local_family == AF_INET) {
+ snprintf (buf, sizeof(buf),
+ "send host-name \"%s\";",
+ dhclient_hostname);
+ }
+ if ((len = strlen(buf))) {
+ status = new_parse (&cfile, -1, buf, len,
+ "hostname update options", 0);
+ if (status != ISC_R_SUCCESS)
+ log_fatal ("Cannot parse send host-name statement!");
+
+ for (;;) {
+ const char *val = NULL;
+ int token;
+
+ token = peek_token (&val, (unsigned *)0, cfile);
+ if (token == END_OF_FILE)
+ break;
+
+ parse_client_statement (cfile, NULL,
+ &top_level_config);
+ }
+ end_parse (&cfile);
+ }
+ }
+
/* Parse the lease database. */
read_client_leases();