apache / openwhisk-apigateway

Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
https://openwhisk.apache.org/
Apache License 2.0
64 stars 45 forks source link

awk script in init.sh matches wrong lines in /etc/resolv.conf #312

Closed baxtersa closed 6 years ago

baxtersa commented 6 years ago

I'm on RHEL 7.5, and my /etc/resolv.conf file contains the following comment

# 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>.

Actual Behavior

The awk script matches both lines in the comment, injecting invalid syntax into the generated conf.d/includes/resolvers.conf file:

$ 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

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.

mrutkows commented 6 years ago

@baxtersa I think that we would welcome a PR as this is clearly not intended behavior. Thanks!

mhamann commented 6 years ago

Thanks for the issue and PR! Nice catch. Merged!