substitute: Make '%allow-unauthenticated-substitutes?' public.
* guix/scripts/substitute.scm (warn-about-missing-authentication): New procedure. (%allow-unauthenticated-substitutes?): Turn into a public parameter and use 'warn-about-missing-authentication'. (valid-narinfo?): Adjust accordingly. * tests/substitute.scm (call-with-narinfo): Likewise.
This commit is contained in:
parent
7f3bbfaf8e
commit
434138e2f2
|
@ -86,6 +86,8 @@
|
||||||
read-narinfo
|
read-narinfo
|
||||||
write-narinfo
|
write-narinfo
|
||||||
|
|
||||||
|
%allow-unauthenticated-substitutes?
|
||||||
|
|
||||||
substitute-urls
|
substitute-urls
|
||||||
guix-substitute))
|
guix-substitute))
|
||||||
|
|
||||||
|
@ -118,15 +120,21 @@
|
||||||
(string-append %state-directory "/substitute/cache"))
|
(string-append %state-directory "/substitute/cache"))
|
||||||
(string-append (cache-directory #:ensure? #f) "/substitute")))
|
(string-append (cache-directory #:ensure? #f) "/substitute")))
|
||||||
|
|
||||||
|
(define (warn-about-missing-authentication)
|
||||||
|
(warning (G_ "authentication and authorization of substitutes \
|
||||||
|
disabled!~%"))
|
||||||
|
#t)
|
||||||
|
|
||||||
(define %allow-unauthenticated-substitutes?
|
(define %allow-unauthenticated-substitutes?
|
||||||
;; Whether to allow unchecked substitutes. This is useful for testing
|
;; Whether to allow unchecked substitutes. This is useful for testing
|
||||||
;; purposes, and should be avoided otherwise.
|
;; purposes, and should be avoided otherwise.
|
||||||
(and (and=> (getenv "GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES")
|
(make-parameter
|
||||||
(cut string-ci=? <> "yes"))
|
(and=> (getenv "GUIX_ALLOW_UNAUTHENTICATED_SUBSTITUTES")
|
||||||
(begin
|
(cut string-ci=? <> "yes"))
|
||||||
(warning (G_ "authentication and authorization of substitutes \
|
(lambda (value)
|
||||||
disabled!~%"))
|
(when value
|
||||||
#t)))
|
(warn-about-missing-authentication))
|
||||||
|
value)))
|
||||||
|
|
||||||
(define %narinfo-ttl
|
(define %narinfo-ttl
|
||||||
;; Number of seconds during which cached narinfo lookups are considered
|
;; Number of seconds during which cached narinfo lookups are considered
|
||||||
|
@ -370,7 +378,7 @@ No authentication and authorization checks are performed here!"
|
||||||
(define* (valid-narinfo? narinfo #:optional (acl (current-acl))
|
(define* (valid-narinfo? narinfo #:optional (acl (current-acl))
|
||||||
#:key verbose?)
|
#:key verbose?)
|
||||||
"Return #t if NARINFO's signature is not valid."
|
"Return #t if NARINFO's signature is not valid."
|
||||||
(or %allow-unauthenticated-substitutes?
|
(or (%allow-unauthenticated-substitutes?)
|
||||||
(let ((hash (narinfo-sha256 narinfo))
|
(let ((hash (narinfo-sha256 narinfo))
|
||||||
(signature (narinfo-signature narinfo))
|
(signature (narinfo-signature narinfo))
|
||||||
(uri (uri->string (first (narinfo-uris narinfo)))))
|
(uri (uri->string (first (narinfo-uris narinfo)))))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
|
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
|
||||||
;;; Copyright © 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2014, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -169,9 +169,7 @@ a file for NARINFO."
|
||||||
(cute write-file
|
(cute write-file
|
||||||
(string-append narinfo-directory "/example.out") <>))
|
(string-append narinfo-directory "/example.out") <>))
|
||||||
|
|
||||||
(set! (@@ (guix scripts substitute)
|
(%allow-unauthenticated-substitutes? #f))
|
||||||
%allow-unauthenticated-substitutes?)
|
|
||||||
#f))
|
|
||||||
thunk
|
thunk
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when (file-exists? cache-directory)
|
(when (file-exists? cache-directory)
|
||||||
|
|
Loading…
Reference in New Issue