If possible, read /etc/hosts to find hosts.
()
| 114 | |
| 115 | |
| 116 | def _check_etc_hosts(): |
| 117 | """If possible, read /etc/hosts to find hosts.""" |
| 118 | filename = '/etc/hosts' |
| 119 | debug2(' > Reading %s on remote host' % filename) |
| 120 | try: |
| 121 | for line in open(filename): |
| 122 | line = re.sub(r'#.*', '', line) # remove comments |
| 123 | words = line.strip().split() |
| 124 | if not words: |
| 125 | continue |
| 126 | ip = words[0] |
| 127 | if _is_ip(ip): |
| 128 | names = words[1:] |
| 129 | debug3('< %s %r' % (ip, names)) |
| 130 | for n in names: |
| 131 | check_host(n) |
| 132 | found_host(n, ip) |
| 133 | except (OSError, IOError): |
| 134 | debug1("Failed to read %s on remote host" % filename) |
| 135 | |
| 136 | |
| 137 | def _check_revdns(ip): |
nothing calls this directly
no test coverage detected