Skip to content

Commit

Permalink
Update search pattern for resolv.conf
Browse files Browse the repository at this point in the history
Add strict case for pattern searching on resolv.conf file.
It make sure that `nameserver` and `search` keyword are
the start of the string when looking for name servers and
search domains on resolv.conf.

Signed-off-by: Obed N Munoz <[email protected]>
  • Loading branch information
obedmr authored and erick0z committed Dec 19, 2018
1 parent 650c00c commit e5883b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions startvm
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ if [[ "$ENABLE_DHCP" == 1 ]]; then
iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill

# Build DNS options from container /etc/resolv.conf
nameservers=($(grep nameserver /etc/resolv.conf | sed 's/nameserver //'))
searchdomains=$(grep search /etc/resolv.conf | sed 's/search //' | sed 's/ /,/g')
nameservers=($(grep ^nameserver /etc/resolv.conf | sed 's/nameserver //'))
searchdomains=$(grep ^search /etc/resolv.conf | sed 's/search //' | sed 's/ /,/g')
domainname=$(echo $searchdomains | awk -F"," '{print $1}')

for nameserver in "${nameservers[@]}"; do
Expand Down

0 comments on commit e5883b5

Please sign in to comment.