[PATCH v2] Add a header in ifcfg and nm keyfiles describing the owner of the files

Ani Sinha posted 1 patch 2 weeks, 1 day ago
tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
[PATCH v2] Add a header in ifcfg and nm keyfiles describing the owner of the files
Posted by Ani Sinha 2 weeks, 1 day ago
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.

CC: shradhagupta@linux.microsoft.com
CC: eahariha@linux.microsoft.com
CC: wei.liu@kernel.org
Signed-off-by: Ani Sinha <anisinha@redhat.com>
---
 tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index ae57bf69ad4a..014e45be6981 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -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.
 	 */
-- 
2.42.0
Re: [PATCH v2] Add a header in ifcfg and nm keyfiles describing the owner of the files
Posted by Wei Liu 1 week, 3 days ago
On Thu, Apr 18, 2024 at 05:35:49PM +0530, Ani Sinha wrote:
> 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.
> 
> CC: shradhagupta@linux.microsoft.com
> CC: eahariha@linux.microsoft.com
> CC: wei.liu@kernel.org
> Signed-off-by: Ani Sinha <anisinha@redhat.com>

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.
Re: [PATCH v2] Add a header in ifcfg and nm keyfiles describing the owner of the files
Posted by Shradha Gupta 1 week, 6 days ago
On Thu, Apr 18, 2024 at 05:35:49PM +0530, Ani Sinha wrote:
> 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.
> 
> CC: shradhagupta@linux.microsoft.com
> CC: eahariha@linux.microsoft.com
> CC: wei.liu@kernel.org
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
> ---
>  tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> changelog:
> v2: simplify and fix issues with error handling.
> 
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
> index ae57bf69ad4a..014e45be6981 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -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.
>  	 */
> -- 
> 2.42.0
Reviewed-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Re: [PATCH v2] Add a header in ifcfg and nm keyfiles describing the owner of the files
Posted by Easwar Hariharan 2 weeks, 1 day ago
On 4/18/2024 5:05 AM, Ani Sinha wrote:
> 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.
> 
> CC: shradhagupta@linux.microsoft.com
> CC: eahariha@linux.microsoft.com
> CC: wei.liu@kernel.org
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
> ---
>  tools/hv/hv_kvp_daemon.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> changelog:
> v2: simplify and fix issues with error handling.
> 
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
> index ae57bf69ad4a..014e45be6981 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -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.
>  	 */


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.

Reviewed-by: Easwar Hariharan <eahariha@linux.microsoft.com>

Thanks,
Easwar