Closed baxtersa closed 6 years ago
I'm on RHEL 7.5, and my /etc/resolv.conf file contains the following comment
/etc/resolv.conf
# NOTE: the libc resolver may not support more than 3 nameservers. # The nameservers listed below may not be recognized.
Expected Behavior
The awk script in init.sh matches only lines of the pattern nameserver <ip-address>.
awk
init.sh
nameserver <ip-address>
Actual Behavior
The awk script matches both lines in the comment, injecting invalid syntax into the generated conf.d/includes/resolvers.conf file:
conf.d/includes/resolvers.conf
$ cat conf.d/includes/resolvers.conf resolver <ip-address> <ip-address> <ip-address> NOTE: The <ip-address>;
Proposed Solution
In init.sh, the awk command matches lines containing the string nameserver
nameserver
echo resolver $(awk 'BEGIN{ORS=" "} /nameserver/{print $2}' /etc/resolv.conf [...]
This should be changed to only match lines beginning with the string nameserver
echo resolver $(awk 'BEGIN{ORS=" "} /^nameserver/{print $2}' /etc/resolv.conf [...]
I'm happy to open up a PR with this minor change if people agree with it.
@baxtersa I think that we would welcome a PR as this is clearly not intended behavior. Thanks!
Thanks for the issue and PR! Nice catch. Merged!
I'm on RHEL 7.5, and my
/etc/resolv.conf
file contains the following commentExpected Behavior
The
awk
script ininit.sh
matches only lines of the patternnameserver <ip-address>
.Actual Behavior
The
awk
script matches both lines in the comment, injecting invalid syntax into the generatedconf.d/includes/resolvers.conf
file:Proposed Solution
In
init.sh
, theawk
command matches lines containing the stringnameserver
This should be changed to only match lines beginning with the string
nameserver
I'm happy to open up a PR with this minor change if people agree with it.