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

8e0e54
From 6b92df3dfca4854e35cb87024ccd17a34e731277 Mon Sep 17 00:00:00 2001
a31528
From: Beniamino Galvani <bgalvani@redhat.com>
a31528
Date: Wed, 20 Jun 2018 11:49:22 +0200
a31528
Subject: [PATCH 1/2] Revert "dhclient: write client-id with backslash and
a31528
 quotes as hex"
a31528
a31528
This reverts commit 0e4b33ee7552b036332f1bdbfed78f8ee75f000e.
a31528
---
a31528
 src/dhcp/nm-dhcp-dhclient-utils.c   |  2 +-
a31528
 src/dhcp/tests/test-dhcp-dhclient.c | 33 +----------------------------
a31528
 2 files changed, 2 insertions(+), 33 deletions(-)
a31528
a31528
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
8e0e54
index 85ca3704d12a..6cbc0c97c535 100644
a31528
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
a31528
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
8e0e54
@@ -135,7 +135,7 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
a31528
 		 * as long as all the characters are printable.
a31528
 		 */
a31528
 		for (i = 1; (p[0] == 0) && i < l; i++) {
a31528
-			if (!g_ascii_isprint (p[i]) || p[i] == '\\' || p[i] == '"')
a31528
+			if (!g_ascii_isprint (p[i]))
a31528
 				break;
a31528
 		}
a31528
 
a31528
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c
8e0e54
index 1eac36434cf9..fb9251f25a2e 100644
a31528
--- a/src/dhcp/tests/test-dhcp-dhclient.c
a31528
+++ b/src/dhcp/tests/test-dhcp-dhclient.c
a31528
@@ -178,36 +178,6 @@ test_quote_client_id (void)
a31528
 
a31528
 /*****************************************************************************/
a31528
 
a31528
-static const char *quote_client_id_expected_2 = \
a31528
-	"# Created by NetworkManager\n"
a31528
-	"\n"
a31528
-	"send dhcp-client-identifier 00:61:5c:62:63; # added by NetworkManager\n"
a31528
-	"\n"
a31528
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
-	"option wpad code 252 = string;\n"
a31528
-	"\n"
a31528
-	"also request rfc3442-classless-static-routes;\n"
a31528
-	"also request ms-classless-static-routes;\n"
a31528
-	"also request static-routes;\n"
a31528
-	"also request wpad;\n"
a31528
-	"also request ntp-servers;\n"
a31528
-	"also request root-path;\n"
a31528
-	"\n";
a31528
-
a31528
-static void
a31528
-test_quote_client_id_2 (void)
a31528
-{
a31528
-	test_config (NULL, quote_client_id_expected_2,
a31528
-	             AF_INET, NULL, 0, FALSE,
a31528
-	             "a\\bc",
a31528
-	             NULL,
a31528
-	             "eth0",
a31528
-	             NULL);
a31528
-}
a31528
-
a31528
-/*****************************************************************************/
a31528
-
a31528
 static const char *hex_zero_client_id_expected = \
a31528
 	"# Created by NetworkManager\n"
a31528
 	"\n"
a31528
@@ -1130,8 +1100,7 @@ main (int argc, char **argv)
a31528
 
a31528
 	g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing);
a31528
 	g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id);
a31528
-	g_test_add_func ("/dhcp/dhclient/quote_client_id/1", test_quote_client_id);
a31528
-	g_test_add_func ("/dhcp/dhclient/quote_client_id/2", test_quote_client_id_2);
a31528
+	g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/hex_zero_client_id", test_hex_zero_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id);
a31528
-- 
a31528
2.21.0
a31528
8e0e54
8e0e54
From 2203e61c9cee7b3fcb6052523cdc2721e54496c7 Mon Sep 17 00:00:00 2001
a31528
From: Beniamino Galvani <bgalvani@redhat.com>
a31528
Date: Wed, 20 Jun 2018 11:50:51 +0200
a31528
Subject: [PATCH 2/2] Revert "dhcp: dhclient: set type 0 for printable client
a31528
 IDs"
a31528
a31528
Keep the RHEL 7.5 behavior.
a31528
a31528
This reverts commit 8ffa22d10d3001405965826b46463663fd2dacc2.
a31528
---
a31528
 src/dhcp/nm-dhcp-dhclient-utils.c   | 46 +++------------
a31528
 src/dhcp/tests/test-dhcp-dhclient.c | 87 +++--------------------------
a31528
 2 files changed, 17 insertions(+), 116 deletions(-)
a31528
a31528
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
8e0e54
index 6cbc0c97c535..3338fbff2e93 100644
a31528
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
a31528
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
8e0e54
@@ -148,9 +148,8 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
a31528
 				g_string_append_printf (str, "%02x", (guint8) p[i]);
a31528
 			}
a31528
 		} else {
a31528
-			/* Printable; just add to the line with type 0 */
a31528
+			/* Printable; just add to the line minus the 'type' */
a31528
 			g_string_append_c (str, '"');
a31528
-			g_string_append (str, "\\x00");
a31528
 			g_string_append_len (str, p + 1, l - 1);
a31528
 			g_string_append_c (str, '"');
a31528
 		}
8e0e54
@@ -188,60 +187,31 @@ read_client_id (const char *str)
a31528
 {
a31528
 	gs_free char *s = NULL;
a31528
 	char *p;
a31528
-	int i = 0, j = 0;
a31528
 
a31528
 	nm_assert (!strncmp (str, CLIENTID_TAG, NM_STRLEN (CLIENTID_TAG)));
a31528
-	str += NM_STRLEN (CLIENTID_TAG);
a31528
 
a31528
-	if (!g_ascii_isspace (*str))
a31528
-		return NULL;
a31528
+	str += NM_STRLEN (CLIENTID_TAG);
a31528
 	while (g_ascii_isspace (*str))
a31528
 		str++;
a31528
 
a31528
 	if (*str == '"') {
a31528
-		/* Parse string literal with escape sequences */
a31528
 		s = g_strdup (str + 1);
a31528
 		p = strrchr (s, '"');
a31528
 		if (p)
a31528
 			*p = '\0';
a31528
 		else
a31528
 			return NULL;
a31528
+	} else
a31528
+		s = g_strdup (str);
a31528
 
a31528
-		if (!s[0])
a31528
-			return NULL;
a31528
-
a31528
-		while (s[i]) {
a31528
-			if (   s[i] == '\\'
a31528
-			    && s[i + 1] == 'x'
a31528
-			    && g_ascii_isxdigit (s[i + 2])
a31528
-			    && g_ascii_isxdigit (s[i + 3])) {
a31528
-				s[j++] =  (g_ascii_xdigit_value (s[i + 2]) << 4)
a31528
-				         + g_ascii_xdigit_value (s[i + 3]);
a31528
-				i += 4;
a31528
-				continue;
a31528
-			}
a31528
-			if (   s[i] == '\\'
a31528
-			    && s[i + 1] >= '0' && s[i + 1] <= '7'
a31528
-			    && s[1 + 2] >= '0' && s[i + 2] <= '7'
a31528
-			    && s[1 + 3] >= '0' && s[i + 3] <= '7') {
a31528
-				s[j++] =    ((s[i + 1] - '0') << 6)
a31528
-				          + ((s[i + 2] - '0') << 3)
a31528
-				          + ( s[i + 3] - '0');
a31528
-				i += 4;
a31528
-				continue;
a31528
-			}
a31528
-			s[j++] = s[i++];
a31528
-		}
a31528
-		return g_bytes_new_take (g_steal_pointer (&s), j);
a31528
-	}
a31528
-
a31528
-	/* Otherwise, try to read a hexadecimal sequence */
a31528
-	s = g_strdup (str);
a31528
 	g_strchomp (s);
a31528
 	if (s[strlen (s) - 1] == ';')
a31528
 		s[strlen (s) - 1] = '\0';
a31528
 
a31528
-	return nm_utils_hexstr2bin (s);
a31528
+	if (!s[0])
a31528
+		return NULL;
a31528
+
a31528
+	return nm_dhcp_utils_client_id_string_to_bytes (s);
a31528
 }
a31528
 
a31528
 static gboolean
a31528
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c
8e0e54
index fb9251f25a2e..f6267cd2816d 100644
a31528
--- a/src/dhcp/tests/test-dhcp-dhclient.c
a31528
+++ b/src/dhcp/tests/test-dhcp-dhclient.c
a31528
@@ -151,7 +151,7 @@ test_override_client_id (void)
a31528
 static const char *quote_client_id_expected = \
a31528
 	"# Created by NetworkManager\n"
a31528
 	"\n"
a31528
-	"send dhcp-client-identifier \"\\x00abcd\"; # added by NetworkManager\n"
a31528
+	"send dhcp-client-identifier \"1234\"; # added by NetworkManager\n"
a31528
 	"\n"
a31528
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
@@ -170,37 +170,7 @@ test_quote_client_id (void)
a31528
 {
a31528
 	test_config (NULL, quote_client_id_expected,
a31528
 	             AF_INET, NULL, 0, FALSE,
a31528
-	             "abcd",
a31528
-	             NULL,
a31528
-	             "eth0",
a31528
-	             NULL);
a31528
-}
a31528
-
a31528
-/*****************************************************************************/
a31528
-
a31528
-static const char *hex_zero_client_id_expected = \
a31528
-	"# Created by NetworkManager\n"
a31528
-	"\n"
a31528
-	"send dhcp-client-identifier 00:11:22:33; # added by NetworkManager\n"
a31528
-	"\n"
a31528
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
-	"option wpad code 252 = string;\n"
a31528
-	"\n"
a31528
-	"also request rfc3442-classless-static-routes;\n"
a31528
-	"also request ms-classless-static-routes;\n"
a31528
-	"also request static-routes;\n"
a31528
-	"also request wpad;\n"
a31528
-	"also request ntp-servers;\n"
a31528
-	"also request root-path;\n"
a31528
-	"\n";
a31528
-
a31528
-static void
a31528
-test_hex_zero_client_id (void)
a31528
-{
a31528
-	test_config (NULL, hex_zero_client_id_expected,
a31528
-	             AF_INET, NULL, 0, FALSE,
a31528
-	             "00:11:22:33",
a31528
+	             "1234",
a31528
 	             NULL,
a31528
 	             "eth0",
a31528
 	             NULL);
a31528
@@ -211,7 +181,7 @@ test_hex_zero_client_id (void)
a31528
 static const char *ascii_client_id_expected = \
a31528
 	"# Created by NetworkManager\n"
a31528
 	"\n"
a31528
-	"send dhcp-client-identifier \"\\x00qb:cd:ef:12:34:56\"; # added by NetworkManager\n"
a31528
+	"send dhcp-client-identifier \"qb:cd:ef:12:34:56\"; # added by NetworkManager\n"
a31528
 	"\n"
a31528
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
@@ -269,13 +239,13 @@ test_hex_single_client_id (void)
a31528
 /*****************************************************************************/
a31528
 
a31528
 static const char *existing_hex_client_id_orig = \
a31528
-	"send dhcp-client-identifier 10:30:04:20:7A:08;\n";
a31528
+	"send dhcp-client-identifier 00:30:04:20:7A:08;\n";
a31528
 
a31528
 static const char *existing_hex_client_id_expected = \
a31528
 	"# Created by NetworkManager\n"
a31528
 	"# Merged from /path/to/dhclient.conf\n"
a31528
 	"\n"
a31528
-	"send dhcp-client-identifier 10:30:04:20:7A:08;\n"
a31528
+	"send dhcp-client-identifier 00:30:04:20:7A:08;\n"
a31528
 	"\n"
a31528
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
@@ -293,7 +263,7 @@ static void
a31528
 test_existing_hex_client_id (void)
a31528
 {
a31528
 	gs_unref_bytes GBytes *new_client_id = NULL;
a31528
-	const guint8 bytes[] = { 0x10, 0x30, 0x04, 0x20, 0x7A, 0x08 };
a31528
+	const guint8 bytes[] = { 0x00, 0x30, 0x04,0x20, 0x7A, 0x08 };
a31528
 
a31528
 	new_client_id = g_bytes_new (bytes, sizeof (bytes));
a31528
 	test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
a31528
@@ -306,53 +276,16 @@ test_existing_hex_client_id (void)
a31528
 
a31528
 /*****************************************************************************/
a31528
 
a31528
-static const char *existing_escaped_client_id_orig = \
a31528
-	"send dhcp-client-identifier \"\\044test\\xfe\";\n";
a31528
-
a31528
-static const char *existing_escaped_client_id_expected = \
a31528
-	"# Created by NetworkManager\n"
a31528
-	"# Merged from /path/to/dhclient.conf\n"
a31528
-	"\n"
a31528
-	"send dhcp-client-identifier \"\\044test\\xfe\";\n"
a31528
-	"\n"
a31528
-	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
-	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
-	"option wpad code 252 = string;\n"
a31528
-	"\n"
a31528
-	"also request rfc3442-classless-static-routes;\n"
a31528
-	"also request ms-classless-static-routes;\n"
a31528
-	"also request static-routes;\n"
a31528
-	"also request wpad;\n"
a31528
-	"also request ntp-servers;\n"
a31528
-	"also request root-path;\n"
a31528
-	"\n";
a31528
-
a31528
-static void
a31528
-test_existing_escaped_client_id (void)
a31528
-{
a31528
-	gs_unref_bytes GBytes *new_client_id = NULL;
a31528
-
a31528
-	new_client_id = g_bytes_new ("$test\xfe", 6);
a31528
-	test_config (existing_escaped_client_id_orig, existing_escaped_client_id_expected,
a31528
-	             AF_INET, NULL, 0, FALSE,
a31528
-	             NULL,
a31528
-	             new_client_id,
a31528
-	             "eth0",
a31528
-	             NULL);
a31528
-}
a31528
-
a31528
-/*****************************************************************************/
a31528
-
a31528
 #define EACID "qb:cd:ef:12:34:56"
a31528
 
a31528
 static const char *existing_ascii_client_id_orig = \
a31528
-	"send dhcp-client-identifier \"\\x00" EACID "\";\n";
a31528
+	"send dhcp-client-identifier \"" EACID "\";\n";
a31528
 
a31528
 static const char *existing_ascii_client_id_expected = \
a31528
 	"# Created by NetworkManager\n"
a31528
 	"# Merged from /path/to/dhclient.conf\n"
a31528
 	"\n"
a31528
-	"send dhcp-client-identifier \"\\x00" EACID "\";\n"
a31528
+	"send dhcp-client-identifier \"" EACID "\";\n"
a31528
 	"\n"
a31528
 	"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
a31528
 	"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
a31528
@@ -944,7 +877,7 @@ static void
a31528
 test_structured (void)
a31528
 {
a31528
 	gs_unref_bytes GBytes *new_client_id = NULL;
a31528
-	const guint8 bytes[] = "sad-and-useless";
a31528
+	const guint8 bytes[] = "\x00sad-and-useless";
a31528
 
a31528
 	static const char *const orig = \
a31528
 		"interface \"eth0\"   {  \n"
a31528
@@ -1101,11 +1034,9 @@ main (int argc, char **argv)
a31528
 	g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing);
a31528
 	g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/quote_client_id", test_quote_client_id);
a31528
-	g_test_add_func ("/dhcp/dhclient/hex_zero_client_id", test_hex_zero_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/ascii_client_id", test_ascii_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/hex_single_client_id", test_hex_single_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/existing-hex-client-id", test_existing_hex_client_id);
a31528
-	g_test_add_func ("/dhcp/dhclient/existing-client-id", test_existing_escaped_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/existing-ascii-client-id", test_existing_ascii_client_id);
a31528
 	g_test_add_func ("/dhcp/dhclient/fqdn", test_fqdn);
a31528
 	g_test_add_func ("/dhcp/dhclient/fqdn_options_override", test_fqdn_options_override);
a31528
-- 
a31528
2.21.0
a31528