mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-26 22:38:07 -05:00
authenticate: Consistently use 'leave' for fatal error reporting.
* guix/scripts/authenticate.scm (guix-authenticate): Replace all uses of 'format' + 'exit' with 'leave'.
This commit is contained in:
parent
6fc04984d2
commit
c909dab269
1 changed files with 9 additions and 17 deletions
|
@ -61,7 +61,8 @@ (define (guix-authenticate . args)
|
||||||
(public-key (if (string-suffix? ".sec" key)
|
(public-key (if (string-suffix? ".sec" key)
|
||||||
(read-canonical-sexp
|
(read-canonical-sexp
|
||||||
(string-append (string-drop-right key 4) ".pub"))
|
(string-append (string-drop-right key 4) ".pub"))
|
||||||
(leave (_ "cannot find public key for secret key '~a'")
|
(leave
|
||||||
|
(_ "cannot find public key for secret key '~a'~%")
|
||||||
key)))
|
key)))
|
||||||
(data (read-hash-data hash-file))
|
(data (read-hash-data hash-file))
|
||||||
(signature (signature-sexp data secret-key public-key)))
|
(signature (signature-sexp data secret-key public-key)))
|
||||||
|
@ -82,21 +83,12 @@ (define (guix-authenticate . args)
|
||||||
(display (bytevector->base16-string
|
(display (bytevector->base16-string
|
||||||
(hash-data->bytevector data)))
|
(hash-data->bytevector data)))
|
||||||
#t) ; success
|
#t) ; success
|
||||||
(begin
|
(leave (_ "error: invalid signature: ~a~%")
|
||||||
(format (current-error-port)
|
(canonical-sexp->string signature)))
|
||||||
"error: invalid signature: ~a~%"
|
(leave (_ "error: unauthorized public key: ~a~%")
|
||||||
(canonical-sexp->string signature))
|
(canonical-sexp->string public-key)))
|
||||||
(exit 1)))
|
(leave (_ "error: corrupt signature data: ~a~%")
|
||||||
(begin
|
(canonical-sexp->string sig+data)))))
|
||||||
(format (current-error-port)
|
|
||||||
"error: unauthorized public key: ~a~%"
|
|
||||||
(canonical-sexp->string public-key))
|
|
||||||
(exit 1)))
|
|
||||||
(begin
|
|
||||||
(format (current-error-port)
|
|
||||||
"error: corrupt signature data: ~a~%"
|
|
||||||
(canonical-sexp->string sig+data))
|
|
||||||
(exit 1)))))
|
|
||||||
(("--help")
|
(("--help")
|
||||||
(display (_ "Usage: guix authenticate OPTION...
|
(display (_ "Usage: guix authenticate OPTION...
|
||||||
Sign or verify the signature on the given file. This tool is meant to
|
Sign or verify the signature on the given file. This tool is meant to
|
||||||
|
|
Loading…
Reference in a new issue