cloudera-ps / prereq-checks

Prerequisites checker for Cloudera Manager and CDP PVC Base installations
GNU General Public License v3.0
57 stars 58 forks source link

False negative on check /etc/hosts #142

Closed renatokrause closed 3 years ago

renatokrause commented 4 years ago

Although my /etc/hosts file only displayed: 127.0.0.1 localhost The script continued to display a warning about the presence of a strange entry. In the function "_checknetwork ()", specifically in the line: set -- "$ (echo" $ line "| awk '{print $ 1, $ 2}')" there should be no quotation marks because it is expected that afterwards there will be two entries: ip, hostname. Therefore, it is necessary to remove the quotation marks, thus: set -- $ (echo "$ line" | awk '{print $ 1, $ 2}') To facilitate sharing the diff: https://pastebin.com/Q40P6pUJ

melvin-koh commented 3 years ago

Closing this issue as bug seems to be fixed already in main branch.

Scenario 1: /etc/hosts file contains only 1 line with "127.0.0.1 localhost"

[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1   localhost
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
 PASS  Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 1

Scenario 2: /etc/hosts file contains only 2 lines with "127.0.0.1 localhost" and "::1 localhost"

[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
 PASS  Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 2

Scenario 3: /etc/hosts file contains custom hostname entry

[root@centos prereq-checks]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.246.18  dummy.meltest.com**
[root@centos prereq-checks]# ./prereq-check.sh |grep '/etc/hosts'
 WARN  Network: /etc/hosts entries should be <= 2 (use DNS). Actual: 3