download: Protect against dangling symlinks in $SSL_CERT_DIR.
authorLudovic Courtès <ludo@gnu.org>
Fri, 16 Dec 2016 17:00:01 +0000 (18:00 +0100)
committerLudovic Courtès <ludo@gnu.org>
Fri, 16 Dec 2016 17:00:01 +0000 (18:00 +0100)
Reported by Christopher Baines <mail@cbaines.net>
in <https://bugs.gnu.org/25213>.

* guix/build/download.scm (make-credendials-with-ca-trust-files): Check
whether FILE exists before calling
'set-certificate-credentials-x509-trust-file!'.

guix/build/download.scm

index 8e32b3d..203338b 100644 (file)
@@ -289,9 +289,12 @@ DIRECTORY.  Those authority certificates are checked when
                               (string-suffix? ".pem" file)))
                    '())))
     (for-each (lambda (file)
-                (set-certificate-credentials-x509-trust-file!
-                 cred (string-append directory "/" file)
-                 x509-certificate-format/pem))
+                (let ((file (string-append directory "/" file)))
+                  ;; Protect against dangling symlinks.
+                  (when (file-exists? file)
+                    (set-certificate-credentials-x509-trust-file!
+                     cred file
+                     x509-certificate-format/pem))))
               (or files '()))
     cred))