Skip to content

Commit 3e213d3

Browse files
committed
Ignore non-existent /etc/hosts
Fixes #64
1 parent dac715c commit 3e213d3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/sockets/namedb/hosts.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
(destructuring-bind (address cname &rest aliases) tokens
5353
(push (make-host cname (ensure-address address) aliases)
5454
hosts))))
55-
(map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens)))
56-
file)
55+
(alexandria:ignore-some-conditions (file-error)
56+
(map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens)))
57+
file))
5758
(nreverse hosts))))
5859

5960
(defun search-host-by-name (name ipv6)

tests/sockets.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
(defparameter *google-ns*
188188
(list #/ip/8.8.8.8 #/ip/8.8.4.4))
189189

190+
(test (missing-hosts-file :compile-at :definition-time)
191+
(is-false (iolib/sockets::parse-/etc/hosts "/foo/no-such-file")))
192+
190193
#-no-internet-available
191194
(test (lookup-hostname.1 :compile-at :definition-time)
192195
(is (equalp (multiple-value-bind (address addresses truename)

0 commit comments

Comments
 (0)