diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2018-12-05 16:16:05 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-12-05 16:24:50 +0100 |
| commit | 970ebdae8cef6488c196ed899a774cda54da3588 (patch) | |
| tree | 004b49f617f36a44b3aef968d23c06443cbf4202 | |
| parent | eeedb094ec93ac63e92f733165a3e6883f6002ba (diff) | |
services: guix-daemon: Fix authorization of multiple keys.
Previously, the 'unless (file-exists? "/etc/guix/acl")' guard would mean
that only the first key in the list would get registered since were were
generating one registration snippet per key. This fixes that.
* gnu/services/base.scm (hydra-key-authorization): Change to be a
'for-each' loop iterating on #$KEYS.
| -rw-r--r-- | gnu/services/base.scm | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index cee9898d79e..89e39f76900 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm | |||
| @@ -1499,26 +1499,27 @@ starting at FIRST-UID, and under GID." | |||
| 1499 | 1+ | 1499 | 1+ |
| 1500 | 1)) | 1500 | 1)) |
| 1501 | 1501 | ||
| 1502 | (define (hydra-key-authorization key guix) | 1502 | (define (hydra-key-authorization keys guix) |
| 1503 | "Return a gexp with code to register KEY, a file containing a 'guix archive' | 1503 | "Return a gexp with code to register KEYS, a list of files containing 'guix |
| 1504 | public key, with GUIX." | 1504 | archive' public keys, with GUIX." |
| 1505 | #~(unless (file-exists? "/etc/guix/acl") | 1505 | #~(unless (file-exists? "/etc/guix/acl") |
| 1506 | (let ((pid (primitive-fork))) | 1506 | (for-each (lambda (key) |
| 1507 | (case pid | 1507 | (let ((pid (primitive-fork))) |
| 1508 | ((0) | 1508 | (case pid |
| 1509 | (let* ((key #$key) | 1509 | ((0) |
| 1510 | (port (open-file key "r0b"))) | 1510 | (let* ((port (open-file key "r0b"))) |
| 1511 | (format #t "registering public key '~a'...~%" key) | 1511 | (format #t "registering public key '~a'...~%" key) |
| 1512 | (close-port (current-input-port)) | 1512 | (close-port (current-input-port)) |
| 1513 | (dup port 0) | 1513 | (dup port 0) |
| 1514 | (execl #$(file-append guix "/bin/guix") | 1514 | (execl #$(file-append guix "/bin/guix") |
| 1515 | "guix" "archive" "--authorize") | 1515 | "guix" "archive" "--authorize") |
| 1516 | (exit 1))) | 1516 | (primitive-exit 1))) |
| 1517 | (else | 1517 | (else |
| 1518 | (let ((status (cdr (waitpid pid)))) | 1518 | (let ((status (cdr (waitpid pid)))) |
| 1519 | (unless (zero? status) | 1519 | (unless (zero? status) |
| 1520 | (format (current-error-port) "warning: \ | 1520 | (format (current-error-port) "warning: \ |
| 1521 | failed to register public key '~a': ~a~%" key status)))))))) | 1521 | failed to register public key '~a': ~a~%" key status))))))) |
| 1522 | '(#$@keys)))) | ||
| 1522 | 1523 | ||
| 1523 | (define %default-authorized-guix-keys | 1524 | (define %default-authorized-guix-keys |
| 1524 | ;; List of authorized substitute keys. | 1525 | ;; List of authorized substitute keys. |
| @@ -1632,8 +1633,7 @@ failed to register public key '~a': ~a~%" key status)))))))) | |||
| 1632 | 1633 | ||
| 1633 | ;; Optionally authorize substitute server keys. | 1634 | ;; Optionally authorize substitute server keys. |
| 1634 | (if authorize-key? | 1635 | (if authorize-key? |
| 1635 | #~(begin | 1636 | (hydra-key-authorization keys guix) |
| 1636 | #$@(map (cut hydra-key-authorization <> guix) keys)) | ||
| 1637 | #~#f)))) | 1637 | #~#f)))) |
| 1638 | 1638 | ||
| 1639 | (define* (references-file item #:optional (name "references")) | 1639 | (define* (references-file item #:optional (name "references")) |
