netconsole: resolve domain name via 'getent' instead of 'hosts' #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit solves the issue described in RHBZ #1278519.
When the nameserver address lines are not present in
/etc/resolv.conf
, launching/etc/init.d/netconsole start
will result in this error:Server address not specified in /etc/sysconfig/netconsole
This was caused by using
hosts
command for domain name resolution. This is nowfixed by using
getent
command instead.I have improved the patch provided in the RHBZ, here is the basic overview:
IPV6INIT
variable is set toyes
, we are now usingis_true
instead of grep-ing the value from
/etc/sysconfig/network
directly.$SYSLOGADDR
with regular expressions has been extended.The regex for IPv6 has been added, and it is unfortunately quite huge because of possible
IPv6 variations (e.g. 4to6). It was taken from Stack Overflow and
edited. (It does not accept the mask of IP address - e.g. /64 ). The regex has been tested via regexpal.com.
(You can test it yourself -- copy-paste the regex there.)
$SYSLOGADDR
, then we assume the domain name is used and try to resolve it. The default behaviour forthis depends on if
IPV6INIT
is set, and other conditions. Excerpt from the patch:This should remain same for both RHEL6 and RHEL7/Fedora. I know that IPv6 is disabled on RHEL6, by default, and enabled in RHEL7/Fedora by default, but that is a separate (orthogonal) thing. When IPv6 is not forced, and both IPv4 and IPv6 are specified for the same domain name, the script will fallback to use of IPv4, which IMHO is desirable. IOW, the script is not forcing IPv6 on user unless there's no other IP available for that specific domain name.
I have successfully tested the patch on RHEL-6.8.