[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] tools/hotplug: Fix dhcpd symlink removal in vif-nat


  • To: Wei Liu <wl@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Mon, 7 Sep 2020 15:01:37 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d+I8ZUlWj8j0v26G2bSUn3k7DND1aWfmkg22VreE/OU=; b=ZAGg9uJgKKmSkL74wWV0f3ypc3GRLeBRiGaVEABENLzhDKblGOICXD9/OwK5cVKVSh25MIu6lpBel1cQafRIEg+3KnVKS8ktQlPQgBzqF4ktlwQKYzgqUhgN30EP0iDA6n4vB5/KZMVKVWwZ7Au5SVqCHTW5i/sM4VxZ5+GNmGOwICvuJDXU7XF662qmRYzofuhNyBLh5q7TPYZbOAodmdU2+BjHIaeRXFWglfdsDND0rFfhRO/ZicT/H2HdNbpf80EwfY0QMk6FHfyEyxXmTSIEmY2NGQ3f28SMsXb9PfvY37zb3o2XvmGOcLcIx3brI/bwjfIyhb9XgfcNIsfjMA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XslI2KRIoZZKlzXS/A81XqYyUgGPITpoo63o7CeKpXE95r+zfYfm23NXhNSeWJGA8OB9qF3S2iDbS6XXw3BN0ulOlDuaeNCB/QI+IKEF2t6FefolqG1ZXLhWjza8VOE9TKV6L7nEJTFNZuycviGaq8znAvaltVDpy+nT/5UMWcx2vEI3Qit71c1LLZ5LqUBeIKYzP/mJDKi4ZBYPWcCSocLcrPuh/UbhcKI8IWZZ3V3LwSyj/XWxidFgs55xONZ/PTKuE8MA9jqgwa5sdbzkNEgwi+DFMHxUznHUTyuBWdWtrjHfsqJLm6mPuOyYY7ZzjoS6bg7PCmM8tT5i3Gaf0Q==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Diego Sueiro <Diego.Sueiro@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, nd <nd@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Mon, 07 Sep 2020 15:01:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWduFzi7tknqNOmkiLnZ0D+vERVqldWqeAgAAHJgA=
  • Thread-topic: [PATCH 2/3] tools/hotplug: Fix dhcpd symlink removal in vif-nat

Hi Wei,

> On 7 Sep 2020, at 15:36, Wei Liu <wl@xxxxxxx> wrote:
> 
> On Thu, Aug 20, 2020 at 12:00:23PM +0100, Diego Sueiro wrote:
>> Copy temp files used to add/remove dhcpd configurations to avoid
>> replacing potential symlinks.
>> 
> 
> Can you clarify the issue you saw a bit?
> 
> Which one of the parameter is a symlink (I assume the latter) and what
> problem you see with replacing the symlinks?

Maybe i can explain here.

If you have this:
/etc/dhcp.conf -> dhcp.conf.real

mv will create a new file dhcp.conf where cp will actually modify
dhcp.conf.real instead of replacing the symlink with a real file.

This prevents some mistakes where the user will actually continue to
modify dhcp.conf.real where it would not be the one used anymore.

Bertrand

> 
>> Signed-off-by: Diego Sueiro <diego.sueiro@xxxxxxx>
>> ---
>> tools/hotplug/Linux/vif-nat | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat
>> index 2614435..1ab80ed 100644
>> --- a/tools/hotplug/Linux/vif-nat
>> +++ b/tools/hotplug/Linux/vif-nat
>> @@ -99,7 +99,8 @@ dhcparg_remove_entry()
>>   then
>>     rm "$tmpfile"
>>   else
>> -    mv "$tmpfile" "$dhcpd_arg_file"
>> +    cp "$tmpfile" "$dhcpd_arg_file"
>> +    rm "$tmpfile"
>>   fi
> 
> You could've simplified the code a bit here and below now that both
> branches issue the same rm command.
> 
> But don't resend just yet. Please help me understand your issue first.
> 
> Wei.
> 
>> }
>> 
>> @@ -109,11 +110,11 @@ dhcparg_add_entry()
>>   local tmpfile=$(mktemp)
>>   # handle Red Hat, SUSE, and Debian styles, with or without quotes
>>   sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"${dev} "'"/' \
>> -     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
>> +     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
>>   sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"${dev} "'"/' 
>> \
>> -     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
>> +     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
>>   sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"${dev} "'"/' \
>> -     "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file"
>> +     "$dhcpd_arg_file" >"$tmpfile" && cp "$tmpfile" "$dhcpd_arg_file"
>>   rm -f "$tmpfile"
>> }
>> 
>> @@ -125,7 +126,8 @@ dhcp_remove_entry()
>>   then
>>     rm "$tmpfile"
>>   else
>> -    mv "$tmpfile" "$dhcpd_conf_file"
>> +    cp "$tmpfile" "$dhcpd_conf_file"
>> +    rm "$tmpfile"
>>   fi
>>   dhcparg_remove_entry
>> }
>> -- 
>> 2.7.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.