diff options
| author | Marius Bakke <marius@gnu.org> | 2022-11-20 07:49:11 +0100 |
|---|---|---|
| committer | Marius Bakke <marius@gnu.org> | 2022-11-20 07:49:11 +0100 |
| commit | 7d5e045a691fcdbbfb1e75e4f4660396403c1d8d (patch) | |
| tree | fab0d21a5bc004969f9011ce60907754244c218a /gnu/machine | |
| parent | b187864f36e7f8ce584a002d28b275c6bf9fced2 (diff) | |
| parent | 8cef05bab6251978018ccab7bb44883676ce8f6c (diff) | |
Merge branch 'master' into staging
Diffstat (limited to 'gnu/machine')
| -rw-r--r-- | gnu/machine/ssh.scm | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 1230b1ec0dd..343cf747484 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -42,6 +42,7 @@ #:use-module ((guix inferior) #:select (inferior-exception? inferior-exception-arguments)) + #:use-module ((guix platform) #:select (systems)) #:use-module (gcrypt pk-crypto) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -86,7 +87,8 @@ machine-ssh-configuration? this-machine-ssh-configuration (host-name machine-ssh-configuration-host-name) ; string - (system machine-ssh-configuration-system) ; string + (system machine-ssh-configuration-system ; string + (sanitize validate-system-type)) (build-locally? machine-ssh-configuration-build-locally? ; boolean (default #t)) (authorize? machine-ssh-configuration-authorize? ; boolean @@ -109,6 +111,32 @@ (host-key machine-ssh-configuration-host-key ; #f | string (default #f))) +(define-with-syntax-properties (validate-system-type (value properties)) + ;; Raise an error if VALUE is not a valid system type. + (unless (string? value) + (raise (make-compound-condition + (condition + (&error-location + (location (source-properties->location properties)))) + (formatted-message + (G_ "~a: invalid system type; must be a string") + value)))) + (unless (member value (systems)) + (raise (apply make-compound-condition + (condition + (&error-location + (location (source-properties->location properties)))) + (formatted-message (G_ "~a: unknown system type") value) + (let ((closest (string-closest value (systems) + #:threshold 5))) + (if closest + (list (condition + (&fix-hint + (hint (format #f (G_ "Did you mean @code{~a}?") + closest))))) + '()))))) + value) + (define (open-machine-ssh-session config) "Open an SSH session for CONFIG, a <machine-ssh-configuration> record." (let ((host-name (machine-ssh-configuration-host-name config)) |
