pki: Introduce 'write-acl', and fix wrong conversion in 'ensure-acl'.

* guix/pki.scm (write-acl): New procedure.
  (ensure-acl): Use it.  Fixes a regression introduced in 39831f1,
  whereby 'ensure-acl' would yield a wrong-type-arg error.
* guix/scripts/archive.scm (authorize-key): Use 'write-acl'.
This commit is contained in:
Ludovic Courtès 2014-04-04 00:23:17 +02:00
parent 7864504feb
commit ded1012f3c
2 changed files with 9 additions and 6 deletions

View File

@ -30,6 +30,7 @@
public-keys->acl public-keys->acl
acl->public-keys acl->public-keys
authorized-key? authorized-key?
write-acl
signature-sexp signature-sexp
signature-subject signature-subject
@ -83,10 +84,14 @@ element in KEYS must be a canonical sexp with type 'public-key'."
(mkdir-p (dirname %acl-file)) (mkdir-p (dirname %acl-file))
(with-atomic-file-output %acl-file (with-atomic-file-output %acl-file
(lambda (port) (lambda (port)
(display (canonical-sexp->string (write-acl (public-keys->acl (list public-key))
(public-keys->acl (list public-key)))
port))))))) port)))))))
(define (write-acl acl port)
"Write ACL to PORT in canonical-sexp format."
(let ((sexp (sexp->canonical-sexp acl)))
(display (canonical-sexp->string sexp) port)))
(define (current-acl) (define (current-acl)
"Return the current ACL." "Return the current ACL."
(ensure-acl) (ensure-acl)

View File

@ -288,9 +288,7 @@ the input port."
(let ((acl (public-keys->acl (cons key (acl->public-keys acl))))) (let ((acl (public-keys->acl (cons key (acl->public-keys acl)))))
(mkdir-p (dirname %acl-file)) (mkdir-p (dirname %acl-file))
(with-atomic-file-output %acl-file (with-atomic-file-output %acl-file
(lambda (port) (cut write-acl acl <>)))))
(display (canonical-sexp->string (sexp->canonical-sexp acl))
port))))))
(define (guix-archive . args) (define (guix-archive . args)
(define (parse-options) (define (parse-options)