Skip to contentSkip to conversation

Add a header in ifcfg and nm keyfiles describing the owner of the files

PATCH Applied Ani Sinha 5 participants 6 messages Apr 18, 2024 – Apr 22, 2024

Subsystems (2)
lore
Share & tools
lore

Ani Sinha

author
#0 lore raw

PATCH v2 1/1 Add a header in ifcfg and nm keyfiles describing the owner of the files

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable both for debugging as well as for preventing users from modifying them.

---
 tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

changelog:
v2: simplify and fix issues with error handling.

tools/hv/hv_kvp_daemon.c +14 -0
index ae57bf69ad4a..014e45be6981 100644
@@ -94,6 +94,8 @@ static char *lic_version = "Unknown version";
 static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
 static struct utsname uts_buf;
 
+#define CFG_HEADER "# Generated by hyperv key-value pair daemon. Please do not modify.\n"
+
 /*
  * The location of the interface configuration file.
  */
@@ -1435,6 +1437,18 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
 		return HV_E_FAIL;
 	}
 
+	/* Write the config file headers */
+	error = fprintf(ifcfg_file, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;
+	}
+	error = fprintf(nmfile, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;
+	}
+
 	/*
 	 * First write out the MAC address.
 	 */
Signature · 1 line
2.42.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 37 lines · Ani Sinha

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable both for debugging as well as for preventing users from modifying them.

---
 tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

changelog:
v2: simplify and fix issues with error handling.

tools/hv/hv_kvp_daemon.c +7 -0
index ae57bf69ad4a..014e45be6981 100644
@@ -94,6 +94,8 @@ static char *lic_version = "Unknown version";
 static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
 static struct utsname uts_buf;
 
+#define CFG_HEADER "# Generated by hyperv key-value pair daemon. Please do not modify.\n"
+
 /*
  * The location of the interface configuration file.
  */
@@ -1435,6 +1437,18 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
 		return HV_E_FAIL;
 	}
 
+	/* Write the config file headers */
+	error = fprintf(ifcfg_file, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;

tools/hv/hv_kvp_daemon.c static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) · line 1454

Quoted 10 lines
tools/hv/hv_kvp_daemon.c +7 -0
+	}
+	error = fprintf(nmfile, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;
+	}
+
 	/*
 	 * First write out the MAC address.
 	 */

Looks good to me, I'll defer to other folks on the recipient list on whether "hyperv" should be capitalized as HyperV or other such feedback.

Thanks,
Easwar

maintainer
#2 lore raw
Quoted 6 lines

From: Easwar Hariharan <[email protected]>
Sent: Thursday, April 18, 2024 9:16 AM

Quoted 2 lines · Ani Sinha

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable

s/hyperv/Hyper-V/

Quoted 2 lines
Quoted 1 line

+#define CFG_HEADER "# Generated by hyperv key-value pair daemon.

Please do not modify.\n"

s/hyperv/Hyper-V/

Quoted 2 lines

Looks good to me, I'll defer to other folks on the recipient list on whether "hyperv" should be capitalized as HyperV or other such feedback.

It's recommended to use "Hyper-V". Wei can help fix this so I guess there is no need to resend the patch :-)

#3 lore raw
Quoted 12 lines · Dexuan Cui
Quoted 6 lines

From: Easwar Hariharan <[email protected]>
Sent: Thursday, April 18, 2024 9:16 AM

Quoted 2 lines · Ani Sinha

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable

s/hyperv/Hyper-V/

Quoted 2 lines
Quoted 1 line

+#define CFG_HEADER "# Generated by hyperv key-value pair daemon.

Please do not modify.\n"

Quoted 7 lines

s/hyperv/Hyper-V/

Quoted 2 lines

Looks good to me, I'll defer to other folks on the recipient list on whether "hyperv" should be capitalized as HyperV or other such feedback.

It's recommended to use "Hyper-V". Wei can help fix this so I guess there is no need to resend the patch :-)

Sounds good!

Reviewed-by on v2 1/1
#4 lore raw
In reply to Ani Sinha
Quoted 49 lines · Ani Sinha

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable both for debugging as well as for preventing users from modifying them.

---
 tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

changelog:
v2: simplify and fix issues with error handling.

tools/hv/hv_kvp_daemon.c +14 -0
index ae57bf69ad4a..014e45be6981 100644
@@ -94,6 +94,8 @@ static char *lic_version = "Unknown version";
 static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
 static struct utsname uts_buf;
 
+#define CFG_HEADER "# Generated by hyperv key-value pair daemon. Please do not modify.\n"
+
 /*
  * The location of the interface configuration file.
  */
@@ -1435,6 +1437,18 @@ static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val)
 		return HV_E_FAIL;
 	}
 
+	/* Write the config file headers */
+	error = fprintf(ifcfg_file, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;
+	}
+	error = fprintf(nmfile, CFG_HEADER);
+	if (error < 0) {
+		error = HV_E_FAIL;
+		goto setval_error;
+	}
+
 	/*
 	 * First write out the MAC address.
 	 */
Signature · 1 line
2.42.0
maintainer Applied
#5 lore raw
In reply to Ani Sinha
Quoted 8 lines · Ani Sinha

A comment describing the source of writing the contents of the ifcfg and network manager keyfiles (hyperv kvp daemon) is useful. It is valuable both for debugging as well as for preventing users from modifying them.

Applied to hyperv-fixes.

I changed hyperv to Hyper-V and changed the subject to

hv/hv_kvp_daemon: indicate the configuration files are generated

Thanks,
Wei.