On 03/24/2020 01:31 PM, Kairui Song wrote:
On Fri, Mar 13, 2020 at 11:05 AM Pingfan Liu <piliu(a)redhat.com>
wrote:
>
> In /etc/hosts, the alias name can come at the 2nd column, regardless of the
> recommendation.
>
> E.g. the following format is valid although not recommended
> cat /etc/hosts
> 127.0.0.1 localhost localhost.localdomain localhost4
localhost4.localdomain4
> ::1 localhost localhost.localdomain localhost6
localhost6.localdomain6
> 192.168.22.21 fastvm-rhel-7-6-21 fastvm-rhel-7-6-21.localdomain
> 192.168.22.22 fastvm-rhel-7-6-22 fastvm-rhel-7-6-22.localdomain
>
> 192.168.22.21 node1_hb
> 192.168.22.22 node2_hb
>
> So filtering out both 2nd and 3rd column for matching.
>
> Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
> ---
> dracut-module-setup.sh | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 1237896..767be0a 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -683,7 +683,8 @@ get_alias() {
> ips=$(hostname -I)
> for ip in $ips
> do
> - entries=$(grep $ip /etc/hosts | awk '{ $1=$2=""; print $0
}')
> + # in /etc/hosts, alias can come at the 2nd column
> + entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0
}')
> if [ $? -eq 0 ]; then
> alias_set="$alias_set $entries"
> fi
> --
> 2.7.5
>
Hi Pingfan, the commit message seems a bit confusing.
It seems the currently code is filtering out both 2nd and 3rd column,
and after the patch, only first column (ip address) will be filtered
out, is this what the patch mean?
I may misuse "filter out". What I want
is to discard column one