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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Diego Sueiro <diego.sueiro@xxxxxxx>
  • Date: Thu, 20 Aug 2020 12:00:23 +0100
  • 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=FNKPwqJpwUyVgt1gJW++t2rufxR2av2yxpDsmw1ZMKI=; b=jG9YfdkfheWthJ9iM9lPmkT0FcnxmNV2g2S68ygpx4FwH1/gOOJDp/rgDQJroPBQTtnfX50is/J4DI5EEDygAUeyIEDY6RAu/A+UdYRdNH1dGNZRdQQ7dtUw1z3kY2LZ7KU7NuTMtx3o0YpROlmhGbvT6RZua/Q+Rh/JMON4a/AMg3zCeUqoK+N/maPdI0mQjBkim3vZ7VeC7XvrZj4P0hdxx1kNHvtR9qTkKo0+RBzpPMGB2ZHEo7cFmk7KdE6WqfsvirHywekYpzFAXHAHxCcqFm8485rO1ymL/T35FZigjpraWsuUqFRFm/T8NT2JRJzpG7BxoW0ViuwnAB+5zQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XxfjOqiCKLw0kTZ3Ze0k7X2Kw58LBwMWnmP9ihnA/ravabd2Qbb1P934UBGOa3/GOKnwRngcR5nignltn596WOVLbv+qg1Kso8k/HAVOGOzUh9uDwTkKDoHhOtkzZOHUhT0RSP57uQJxDldZ0NDGwjBhkQHWGDILXOVE2aPiveT3ZpJR34yzT4R6Hzn0mcTDXli6g73aZHf/h8yYBAaek/nFKoIXQ+JNvzptvdC2JkG3jdqd8QD/eCMx21swHWcfL9Wke1X2tuAf2dZPeiphE9s+rz2OXOHDo7nH/DkkdVjpV+d+CsqQ5TCPu7aJ2DjxlJH2vUh3qp9lplEW5TOFdQ==
  • Authentication-results-original: lists.xenproject.org; dkim=none (message not signed) header.d=none; lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: nd@xxxxxxx, Diego Sueiro <diego.sueiro@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 20 Aug 2020 11:00:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;

Copy temp files used to add/remove dhcpd configurations to avoid
replacing potential symlinks.

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
 }
 
@@ -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®.