Skip to content

Commit 16deb39

Browse files
bvbharatJayapal
authored andcommitted
CLOUDSTACK-4317 make the regular expressions in dnsmasq.sh more tighter to avoid matching of ip6dns
Signed-off-by: Jayapal <jayapal@apache.org>
1 parent 8531897 commit 16deb39

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎patches/systemvm/debian/config/root/dnsmasq.sh‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ count=0
5555

5656

5757
# fetching the dns Ips from the command line.
58-
dns1=$(echo "$CMDLINE" | grep -o " dns1=.* " | sed -e 's/dns1=//' | awk '{print $1}')
59-
dns2=$(echo "$CMDLINE" | grep -o " dns2=.* " | sed -e 's/dns2=//' | awk '{print $1}')
58+
dns1=$(echo "$CMDLINE" | grep -o " dns1=[[:digit:]].* " | sed -e 's/dns1=//' | awk '{print $1}')
59+
dns2=$(echo "$CMDLINE" | grep -o " dns2=[[:digit:]].* " | sed -e 's/dns2=//' | awk '{print $1}')
6060

6161
dns_servers="${dns1}"
6262
if [ -n "$dns2" ]
@@ -89,19 +89,18 @@ done
8989

9090
#logging the configuration being removed.
9191
log=""
92-
log="${log}"`grep "^dhcp-option=6.*" "$DHCP_CONFIG_MAIN"`"\n"
93-
log="${log}"`grep "^dhcp-option=option:router.*" "$DHCP_CONFIG_MAIN"`"\n"
94-
log="${log}"`grep "^dhcp-range=.*" "$DHCP_CONFIG_MAIN"`"\n"
95-
echo -e "$log" > log.dnsmasq.txt
92+
log="${log}"`grep "^dhcp-option=6" "$DHCP_CONFIG_MAIN"`"\n"
93+
log="${log}"`grep "^dhcp-option=option:router" "$DHCP_CONFIG_MAIN"`"\n"
94+
log="${log}"`grep "^dhcp-range=" "$DHCP_CONFIG_MAIN"`"\n"
9695

9796
if [ "$log" != '\n\n\n' ]
9897
then
9998
#Cleaning the existing dhcp confgiuration
10099
logger -t cloud "dnsmasq.sh: remvoing the primaryip confg from dnsmasq.conf and adding it to /etc/dnsmaq.d/multiple_ranges.conf"
101100
logger -t cloud "dnsmasq.sh: config removed from dnsmasq.conf is $log"
102-
sed -i -e '/dhcp-option=6.*/d' "$DHCP_CONFIG_MAIN"
103-
sed -i -e '/dhcp-option=option:router.*/d' "$DHCP_CONFIG_MAIN"
104-
sed -i -e '/dhcp-range=.*/d' "$DHCP_CONFIG_MAIN"
101+
sed -i -e '/dhcp-option=6/d' "$DHCP_CONFIG_MAIN"
102+
sed -i -e '/dhcp-option=option:router/d' "$DHCP_CONFIG_MAIN"
103+
sed -i -e '/^dhcp-range=/d' "$DHCP_CONFIG_MAIN"
105104
fi
106105

107106
#wrting the new config into the config file.

0 commit comments

Comments
 (0)