SHA256
1
0
forked from pool/dhcp
dhcp/0006-dhcp-4.2.5-dhclient-send-hostname-rml.patch
Marius Tomaschewski d059c507b7 - Initially switched to use systemd service files under systemd
and enabled Restart=on-abort (fate#315133).
- Update to ISC dhcp-4.2.6 release. See RELNOTES file for the
  complete list of changes -- digest of fixes not in dhcp-4.2.5:
  - Tidy up receive packet processing.
    Thanks to Brad Plank of GTA for reporting the issue and
    suggesting a possible patch. [ISC-Bugs #34447]
  - Fix the socket handling for DHCPv6 clients to allow multiple
    instances of a client on a single machine to work properly.
    Previously only one client would receive the packets.
    Thanks to Jiri Popelka at Red Hat for the bug report and a
    potential patch. [ISC-Bugs #34784]
  - Added support for gentle shutdown after signal is received.
    [ISC-Bugs #32692] [ISC-Bugs 34945]
  - Enhance the DHCPv6 server logging to include the addresses
    that are assigned to the clients.  This can be enabled by
    defining LOG_V6_ADDRESSES in site.h. [ISC-Bugs #26377]
  - Fix an operation in the DDNS code to be a bitwise instead
    of logical or. [ISC-Bugs #35138]
- Merged patches for dhcp-4.2.6 version to apply without fuzzy,
  prepended patch number prefixes to match spec file patch nr,
  added patch markup tags / bug numbers to the spec file.
- Applied contrib-lease-path pach to contrib.tar.gz
  [- contrib-lease-path.diff]
- Changed to require automake and use its config.sub and guess
  files instead of maintaining a patch.
  [- config-guess-sub-update.patch]
- Enabled to log DHCPv6 addresses assigned by server to clients
  [+ 0016-server-log-DHCPv6-addresses-assigned-to-clients.patch]
- Cleaned up documentation, rpmlint adjustments.

OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=121
2014-02-10 18:14:12 +00:00

123 lines
3.5 KiB
Diff

From 94cff63e89710f5e67944d57d76edaec968fe139 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.2.5-dhclient-send-hostname-rml
---
client/dhclient.8 | 8 ++++++++
client/dhclient.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/client/dhclient.8 b/client/dhclient.8
index 0aa1119..bc34c6a 100644
--- a/client/dhclient.8
+++ b/client/dhclient.8
@@ -60,6 +60,10 @@ dhclient - Dynamic Host Configuration Protocol Client
.I LL|LLT
]
[
+.B -H
+.I hostname
+]
+[
.B -p
.I port-number
]
@@ -316,6 +320,10 @@ transmits these messages to 255.255.255.255 (the IP limited broadcast
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. 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
diff --git a/client/dhclient.c b/client/dhclient.c
index 203d3d1..b7a14fe 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -119,6 +119,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;
#endif /* DHCPv6 */
@@ -231,6 +232,22 @@ main(int argc, char **argv) {
if (++i == argc)
usage();
mockup_relay = argv[i];
+ } else if (!strcmp (argv[i], "-H")) {
+ size_t len;
+ if (++i == argc || !argv[i] || *(argv[i]) == '\0')
+ usage ();
+ len = strlen (argv[i]);
+ if (len > HOST_NAME_MAX) {
+ log_error("-H option host-name 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, 0) != 0) {
+ log_error("suspect host-name in -H \"%s\"",
+ argv[i]);
+ exit(1);
+ }
+ dhclient_hostname = argv [i];
} else if (!strcmp(argv[i], "-nw")) {
nowait = 1;
} else if (!strcmp(argv[i], "-n")) {
@@ -491,6 +508,35 @@ 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[HOST_NAME_MAX + 40];
+ int len;
+
+ snprintf (buf, sizeof(buf), "send host-name \"%s\";",
+ dhclient_hostname);
+ len = strlen(buf);
+
+ status = new_parse (&cfile, -1, buf, len,
+ "host-name option", 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();
@@ -719,9 +765,9 @@ static void usage()
log_fatal("Usage: dhclient "
#ifdef DHCPv6
- "[-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-D LL|LLT]\n"
+ "[-4|-6] [-SNTP1dvrx] [-nw] [-H <hostname>] [-p <port>] [-D LL|LLT]\n"
#else /* DHCPv6 */
- "[-1dvrx] [-nw] [-p <port>]\n"
+ "[-1dvrx] [-nw] [-H <hostname>] [-p <port>]\n"
#endif /* DHCPv6 */
" [-s server-addr] [-cf config-file] "
"[-lf lease-file]\n"
--
1.8.4