Blame SOURCES/0003-dhclient-no-leading-zero-client-id-rh1556983.patch

52f25a
From 8e8c797904fc29396d340609f006add206df4973 Mon Sep 17 00:00:00 2001
52f25a
From: Beniamino Galvani <bgalvani@redhat.com>
52f25a
Date: Wed, 20 Jun 2018 11:49:22 +0200
52f25a
Subject: [PATCH 1/2] Revert "dhclient: write client-id with backslash and
52f25a
 quotes as hex"
52f25a
52f25a
This reverts commit 0e4b33ee7552b036332f1bdbfed78f8ee75f000e.
52f25a
---
52f25a
 src/dhcp/nm-dhcp-dhclient-utils.c   |  2 +-
52f25a
 src/dhcp/tests/test-dhcp-dhclient.c | 32 +----------------------------
52f25a
 2 files changed, 2 insertions(+), 32 deletions(-)
52f25a
52f25a
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
index 3290dd65c..6adb395c9 100644
52f25a
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
@@ -124,7 +124,7 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
52f25a
 		 * as long as all the characters are printable.
52f25a
 		 */
52f25a
 		for (i = 1; (p[0] == 0) && i < l; i++) {
52f25a
-			if (!g_ascii_isprint (p[i]) || p[i] == '\\' || p[i] == '"')
52f25a
+			if (!g_ascii_isprint (p[i]))
52f25a
 				break;
52f25a
 		}
52f25a
 
52f25a
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
index 2f369aacc..f3b17807f 100644
52f25a
--- a/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
+++ b/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
@@ -176,35 +176,6 @@ test_quote_client_id (void)
52f25a
 
52f25a
 /*****************************************************************************/
52f25a
 
52f25a
-static const char *quote_client_id_expected_2 = \
52f25a
-	"# Created by NetworkManager\n"
52f25a
-	"\n"
52f25a
-	"send dhcp-client-identifier 00:61:5c:62:63; # added by NetworkManager\n"
52f25a
-	"\n"
52f25a
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
-	"option wpad code 252 = string;\n"
52f25a
-	"\n"
52f25a
-	"also request rfc3442-classless-static-routes;\n"
52f25a
-	"also request ms-classless-static-routes;\n"
52f25a
-	"also request static-routes;\n"
52f25a
-	"also request wpad;\n"
52f25a
-	"also request ntp-servers;\n"
52f25a
-	"\n";
52f25a
-
52f25a
-static void
52f25a
-test_quote_client_id_2 (void)
52f25a
-{
52f25a
-	test_config (NULL, quote_client_id_expected_2,
52f25a
-	             AF_INET, NULL, 0, FALSE,
52f25a
-	             "a\\bc",
52f25a
-	             NULL,
52f25a
-	             "eth0",
52f25a
-	             NULL);
52f25a
-}
52f25a
-
52f25a
-/*****************************************************************************/
52f25a
-
52f25a
 static const char *hex_zero_client_id_expected = \
52f25a
 	"# Created by NetworkManager\n"
52f25a
 	"\n"
52f25a
@@ -1026,8 +997,7 @@ main (int argc, char **argv)
52f25a
 
52f25a
 	g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing);
52f25a
 	g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id);
52f25a
-	g_test_add_func ("/dhcp/dhclient/quote_client_id/1", test_quote_client_id);
52f25a
-	g_test_add_func ("/dhcp/dhclient/quote_client_id/2", test_quote_client_id_2);
52f25a
+	g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/hex_zero_client_id", test_hex_zero_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id);
52f25a
-- 
52f25a
2.17.0
52f25a
52f25a
From 5fa45f1a84ea2e46e5fb07aeef19cb46322b64bc Mon Sep 17 00:00:00 2001
52f25a
From: Beniamino Galvani <bgalvani@redhat.com>
52f25a
Date: Wed, 20 Jun 2018 11:50:51 +0200
52f25a
Subject: [PATCH 2/2] Revert "dhcp: dhclient: set type 0 for printable client
52f25a
 IDs"
52f25a
52f25a
Keep the RHEL 7.5 behavior.
52f25a
52f25a
This reverts commit 8ffa22d10d3001405965826b46463663fd2dacc2.
52f25a
---
52f25a
 src/dhcp/nm-dhcp-dhclient-utils.c   | 46 +++-------------
52f25a
 src/dhcp/tests/test-dhcp-dhclient.c | 83 +++--------------------------
52f25a
 2 files changed, 16 insertions(+), 113 deletions(-)
52f25a
52f25a
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
index 6adb395c9..90fa33397 100644
52f25a
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
52f25a
@@ -137,9 +137,8 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
52f25a
 				g_string_append_printf (str, "%02x", (guint8) p[i]);
52f25a
 			}
52f25a
 		} else {
52f25a
-			/* Printable; just add to the line with type 0 */
52f25a
+			/* Printable; just add to the line minus the 'type' */
52f25a
 			g_string_append_c (str, '"');
52f25a
-			g_string_append (str, "\\x00");
52f25a
 			g_string_append_len (str, p + 1, l - 1);
52f25a
 			g_string_append_c (str, '"');
52f25a
 		}
52f25a
@@ -177,60 +176,31 @@ read_client_id (const char *str)
52f25a
 {
52f25a
 	gs_free char *s = NULL;
52f25a
 	char *p;
52f25a
-	int i = 0, j = 0;
52f25a
 
52f25a
 	nm_assert (!strncmp (str, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG)));
52f25a
-	str += NM_STRLEN (CLIENTID_TAG);
52f25a
 
52f25a
-	if (!g_ascii_isspace (*str))
52f25a
-		return NULL;
52f25a
+	str += NM_STRLEN (CLIENTID_TAG);
52f25a
 	while (g_ascii_isspace (*str))
52f25a
 		str++;
52f25a
 
52f25a
 	if (*str == '"') {
52f25a
-		/* Parse string literal with escape sequences */
52f25a
 		s = g_strdup (str + 1);
52f25a
 		p = strrchr (s, '"');
52f25a
 		if (p)
52f25a
 			*p = '\0';
52f25a
 		else
52f25a
 			return NULL;
52f25a
+	} else
52f25a
+		s = g_strdup (str);
52f25a
 
52f25a
-		if (!s[0])
52f25a
-			return NULL;
52f25a
-
52f25a
-		while (s[i]) {
52f25a
-			if (   s[i] == '\\'
52f25a
-			    && s[i + 1] == 'x'
52f25a
-			    && g_ascii_isxdigit (s[i + 2])
52f25a
-			    && g_ascii_isxdigit (s[i + 3])) {
52f25a
-				s[j++] =  (g_ascii_xdigit_value (s[i + 2]) << 4)
52f25a
-				         + g_ascii_xdigit_value (s[i + 3]);
52f25a
-				i += 4;
52f25a
-				continue;
52f25a
-			}
52f25a
-			if (   s[i] == '\\'
52f25a
-			    && s[i + 1] >= '0' && s[i + 1] <= '7'
52f25a
-			    && s[1 + 2] >= '0' && s[i + 2] <= '7'
52f25a
-			    && s[1 + 3] >= '0' && s[i + 3] <= '7') {
52f25a
-				s[j++] =    ((s[i + 1] - '0') << 6)
52f25a
-				          + ((s[i + 2] - '0') << 3)
52f25a
-				          + ( s[i + 3] - '0');
52f25a
-				i += 4;
52f25a
-				continue;
52f25a
-			}
52f25a
-			s[j++] = s[i++];
52f25a
-		}
52f25a
-		return g_bytes_new_take (g_steal_pointer (&s), j);
52f25a
-	}
52f25a
-
52f25a
-	/* Otherwise, try to read a hexadecimal sequence */
52f25a
-	s = g_strdup (str);
52f25a
 	g_strchomp (s);
52f25a
 	if (s[strlen (s) - 1] == ';')
52f25a
 		s[strlen (s) - 1] = '\0';
52f25a
 
52f25a
-	return nm_utils_hexstr2bin (s);
52f25a
+	if (!s[0])
52f25a
+		return NULL;
52f25a
+
52f25a
+	return nm_dhcp_utils_client_id_string_to_bytes (s);
52f25a
 }
52f25a
 
52f25a
 GBytes *
52f25a
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
index f3b17807f..377938c87 100644
52f25a
--- a/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
+++ b/src/dhcp/tests/test-dhcp-dhclient.c
52f25a
@@ -150,7 +150,7 @@ test_override_client_id (void)
52f25a
 static const char *quote_client_id_expected = \
52f25a
 	"# Created by NetworkManager\n"
52f25a
 	"\n"
52f25a
-	"send dhcp-client-identifier \"\\x00abcd\"; # added by NetworkManager\n"
52f25a
+	"send dhcp-client-identifier \"1234\"; # added by NetworkManager\n"
52f25a
 	"\n"
52f25a
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
@@ -168,36 +168,7 @@ test_quote_client_id (void)
52f25a
 {
52f25a
 	test_config (NULL, quote_client_id_expected,
52f25a
 	             AF_INET, NULL, 0, FALSE,
52f25a
-	             "abcd",
52f25a
-	             NULL,
52f25a
-	             "eth0",
52f25a
-	             NULL);
52f25a
-}
52f25a
-
52f25a
-/*****************************************************************************/
52f25a
-
52f25a
-static const char *hex_zero_client_id_expected = \
52f25a
-	"# Created by NetworkManager\n"
52f25a
-	"\n"
52f25a
-	"send dhcp-client-identifier 00:11:22:33; # added by NetworkManager\n"
52f25a
-	"\n"
52f25a
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
-	"option wpad code 252 = string;\n"
52f25a
-	"\n"
52f25a
-	"also request rfc3442-classless-static-routes;\n"
52f25a
-	"also request ms-classless-static-routes;\n"
52f25a
-	"also request static-routes;\n"
52f25a
-	"also request wpad;\n"
52f25a
-	"also request ntp-servers;\n"
52f25a
-	"\n";
52f25a
-
52f25a
-static void
52f25a
-test_hex_zero_client_id (void)
52f25a
-{
52f25a
-	test_config (NULL, hex_zero_client_id_expected,
52f25a
-	             AF_INET, NULL, 0, FALSE,
52f25a
-	             "00:11:22:33",
52f25a
+	             "1234",
52f25a
 	             NULL,
52f25a
 	             "eth0",
52f25a
 	             NULL);
52f25a
@@ -208,7 +179,7 @@ test_hex_zero_client_id (void)
52f25a
 static const char *ascii_client_id_expected = \
52f25a
 	"# Created by NetworkManager\n"
52f25a
 	"\n"
52f25a
-	"send dhcp-client-identifier \"\\x00qb:cd:ef:12:34:56\"; # added by NetworkManager\n"
52f25a
+	"send dhcp-client-identifier \"qb:cd:ef:12:34:56\"; # added by NetworkManager\n"
52f25a
 	"\n"
52f25a
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
@@ -264,13 +235,13 @@ test_hex_single_client_id (void)
52f25a
 /*****************************************************************************/
52f25a
 
52f25a
 static const char *existing_hex_client_id_orig = \
52f25a
-	"send dhcp-client-identifier 10:30:04:20:7A:08;\n";
52f25a
+	"send dhcp-client-identifier 00:30:04:20:7A:08;\n";
52f25a
 
52f25a
 static const char *existing_hex_client_id_expected = \
52f25a
 	"# Created by NetworkManager\n"
52f25a
 	"# Merged from /path/to/dhclient.conf\n"
52f25a
 	"\n"
52f25a
-	"send dhcp-client-identifier 10:30:04:20:7A:08;\n"
52f25a
+	"send dhcp-client-identifier 00:30:04:20:7A:08;\n"
52f25a
 	"\n"
52f25a
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
@@ -287,7 +258,7 @@ static void
52f25a
 test_existing_hex_client_id (void)
52f25a
 {
52f25a
 	gs_unref_bytes GBytes *new_client_id = NULL;
52f25a
-	const guint8 bytes[] = { 0x10, 0x30, 0x04, 0x20, 0x7A, 0x08 };
52f25a
+	const guint8 bytes[] = { 0x00, 0x30, 0x04,0x20, 0x7A, 0x08 };
52f25a
 
52f25a
 	new_client_id = g_bytes_new (bytes, sizeof (bytes));
52f25a
 	test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
52f25a
@@ -300,52 +271,16 @@ test_existing_hex_client_id (void)
52f25a
 
52f25a
 /*****************************************************************************/
52f25a
 
52f25a
-static const char *existing_escaped_client_id_orig = \
52f25a
-	"send dhcp-client-identifier \"\\044test\\xfe\";\n";
52f25a
-
52f25a
-static const char *existing_escaped_client_id_expected = \
52f25a
-	"# Created by NetworkManager\n"
52f25a
-	"# Merged from /path/to/dhclient.conf\n"
52f25a
-	"\n"
52f25a
-	"send dhcp-client-identifier \"\\044test\\xfe\";\n"
52f25a
-	"\n"
52f25a
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
-	"option wpad code 252 = string;\n"
52f25a
-	"\n"
52f25a
-	"also request rfc3442-classless-static-routes;\n"
52f25a
-	"also request ms-classless-static-routes;\n"
52f25a
-	"also request static-routes;\n"
52f25a
-	"also request wpad;\n"
52f25a
-	"also request ntp-servers;\n"
52f25a
-	"\n";
52f25a
-
52f25a
-static void
52f25a
-test_existing_escaped_client_id (void)
52f25a
-{
52f25a
-	gs_unref_bytes GBytes *new_client_id = NULL;
52f25a
-
52f25a
-	new_client_id = g_bytes_new ("$test\xfe", 6);
52f25a
-	test_config (existing_escaped_client_id_orig, existing_escaped_client_id_expected,
52f25a
-	             AF_INET, NULL, 0, FALSE,
52f25a
-	             NULL,
52f25a
-	             new_client_id,
52f25a
-	             "eth0",
52f25a
-	             NULL);
52f25a
-}
52f25a
-
52f25a
-/*****************************************************************************/
52f25a
-
52f25a
 #define EACID "qb:cd:ef:12:34:56"
52f25a
 
52f25a
 static const char *existing_ascii_client_id_orig = \
52f25a
-	"send dhcp-client-identifier \"\\x00" EACID "\";\n";
52f25a
+	"send dhcp-client-identifier \"" EACID "\";\n";
52f25a
 
52f25a
 static const char *existing_ascii_client_id_expected = \
52f25a
 	"# Created by NetworkManager\n"
52f25a
 	"# Merged from /path/to/dhclient.conf\n"
52f25a
 	"\n"
52f25a
-	"send dhcp-client-identifier \"\\x00" EACID "\";\n"
52f25a
+	"send dhcp-client-identifier \"" EACID "\";\n"
52f25a
 	"\n"
52f25a
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
52f25a
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
52f25a
@@ -998,11 +933,9 @@ main (int argc, char **argv)
52f25a
 	g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing);
52f25a
 	g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id);
52f25a
-	g_test_add_func ("/dhcp/dhclient/hex_zero_client_id", test_hex_zero_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/existing-hex-client-id", test_existing_hex_client_id);
52f25a
-	g_test_add_func ("/dhcp/dhclient/existing-client-id", test_existing_escaped_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/existing-ascii-client-id", test_existing_ascii_client_id);
52f25a
 	g_test_add_func ("/dhcp/dhclient/fqdn", test_fqdn);
52f25a
 	g_test_add_func ("/dhcp/dhclient/fqdn_options_override", test_fqdn_options_override);
52f25a
-- 
52f25a
2.17.0
52f25a