diff --git a/src/sockets/namedb/hosts.lisp b/src/sockets/namedb/hosts.lisp index fccb8d55..f2c0cdd5 100644 --- a/src/sockets/namedb/hosts.lisp +++ b/src/sockets/namedb/hosts.lisp @@ -52,8 +52,9 @@ (destructuring-bind (address cname &rest aliases) tokens (push (make-host cname (ensure-address address) aliases) hosts)))) - (map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens))) - file) + (alexandria:ignore-some-conditions (file-error) + (map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens))) + file)) (nreverse hosts)))) (defun search-host-by-name (name ipv6) diff --git a/tests/sockets.lisp b/tests/sockets.lisp index fd9b8e09..06cd8333 100644 --- a/tests/sockets.lisp +++ b/tests/sockets.lisp @@ -187,6 +187,9 @@ (defparameter *google-ns* (list #/ip/8.8.8.8 #/ip/8.8.4.4)) +(test (missing-hosts-file :compile-at :definition-time) + (is-false (iolib/sockets::parse-/etc/hosts "/foo/no-such-file"))) + #-no-internet-available (test (lookup-hostname.1 :compile-at :definition-time) (is (equalp (multiple-value-bind (address addresses truename)