Copy temp files used to add/remove dhcpd configurations to avoid replacing potential symlinks.
Signed-off-by: Diego Sueiro <diego.sue...@arm.com> --- 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