diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-07-27 11:03:14 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-07-27 12:06:35 +0200 |
| commit | a396dd01bc6e90ae512001350d1afa471e01661d (patch) | |
| tree | 40aecd0a2915f01736e4ee94a7b965e801b292f9 /gnu/machine/ssh.scm | |
| parent | 9296a2e511311d23dc49c4e4b3cbb9341ea82bb3 (diff) | |
machine: ssh: Check for potential system downgrades.
This is a followup to 8e31736b0a60919cc1bfc5dc22c395b09243484a.
* guix/scripts/system/reconfigure.scm (check-forward-update): Add
#:current-channels. Use it instead of OLD.
* gnu/services.scm (sexp->system-provenance): New procedure.
(system-provenance): Use it.
* gnu/machine/ssh.scm (<machine-ssh-configuration>)[allow-downgrades?]:
New field.
(machine-check-forward-update): New procedure.
(check-deployment-sanity)[assertions]: Call it.
* doc/guix.texi (Invoking guix deploy): Document 'allow-downgrades?'
field.
Diffstat (limited to 'gnu/machine/ssh.scm')
| -rw-r--r-- | gnu/machine/ssh.scm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 641e8718618..4e31baa4b96 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #:use-module (gnu system) | 24 | #:use-module (gnu system) |
| 25 | #:use-module (gnu system file-systems) | 25 | #:use-module (gnu system file-systems) |
| 26 | #:use-module (gnu system uuid) | 26 | #:use-module (gnu system uuid) |
| 27 | #:use-module ((gnu services) #:select (sexp->system-provenance)) | ||
| 27 | #:use-module (guix diagnostics) | 28 | #:use-module (guix diagnostics) |
| 28 | #:use-module (guix gexp) | 29 | #:use-module (guix gexp) |
| 29 | #:use-module (guix i18n) | 30 | #:use-module (guix i18n) |
| @@ -55,6 +56,7 @@ | |||
| 55 | machine-ssh-configuration-host-name | 56 | machine-ssh-configuration-host-name |
| 56 | machine-ssh-configuration-build-locally? | 57 | machine-ssh-configuration-build-locally? |
| 57 | machine-ssh-configuration-authorize? | 58 | machine-ssh-configuration-authorize? |
| 59 | machine-ssh-configuration-allow-downgrades? | ||
| 58 | machine-ssh-configuration-port | 60 | machine-ssh-configuration-port |
| 59 | machine-ssh-configuration-user | 61 | machine-ssh-configuration-user |
| 60 | machine-ssh-configuration-host-key | 62 | machine-ssh-configuration-host-key |
| @@ -83,6 +85,8 @@ | |||
| 83 | (default #t)) | 85 | (default #t)) |
| 84 | (authorize? machine-ssh-configuration-authorize? ; boolean | 86 | (authorize? machine-ssh-configuration-authorize? ; boolean |
| 85 | (default #t)) | 87 | (default #t)) |
| 88 | (allow-downgrades? machine-ssh-configuration-allow-downgrades? ; boolean | ||
| 89 | (default #f)) | ||
| 86 | (port machine-ssh-configuration-port ; integer | 90 | (port machine-ssh-configuration-port ; integer |
| 87 | (default 22)) | 91 | (default 22)) |
| 88 | (user machine-ssh-configuration-user ; string | 92 | (user machine-ssh-configuration-user ; string |
| @@ -271,6 +275,27 @@ not available in the initrd." | |||
| 271 | 275 | ||
| 272 | (map missing-modules file-systems)) | 276 | (map missing-modules file-systems)) |
| 273 | 277 | ||
| 278 | (define* (machine-check-forward-update machine) | ||
| 279 | "Check whether we are making a forward update for MACHINE. Depending on its | ||
| 280 | 'allow-upgrades?' field, raise an error or display a warning if we are | ||
| 281 | potentially downgrading it." | ||
| 282 | (define config | ||
| 283 | (machine-configuration machine)) | ||
| 284 | |||
| 285 | (define validate-reconfigure | ||
| 286 | (if (machine-ssh-configuration-allow-downgrades? config) | ||
| 287 | warn-about-backward-reconfigure | ||
| 288 | ensure-forward-reconfigure)) | ||
| 289 | |||
| 290 | (remote-let ((provenance #~(call-with-input-file | ||
| 291 | "/run/current-system/provenance" | ||
| 292 | read))) | ||
| 293 | (define channels | ||
| 294 | (sexp->system-provenance provenance)) | ||
| 295 | |||
| 296 | (check-forward-update validate-reconfigure | ||
| 297 | #:current-channels channels))) | ||
| 298 | |||
| 274 | (define (machine-check-building-for-appropriate-system machine) | 299 | (define (machine-check-building-for-appropriate-system machine) |
| 275 | "Raise a '&message' error condition if MACHINE is configured to be built | 300 | "Raise a '&message' error condition if MACHINE is configured to be built |
| 276 | locally and the 'system' field does not match the '%current-system' reported | 301 | locally and the 'system' field does not match the '%current-system' reported |
| @@ -289,7 +314,8 @@ by MACHINE." | |||
| 289 | 'system' declaration would fail." | 314 | 'system' declaration would fail." |
| 290 | (define assertions | 315 | (define assertions |
| 291 | (append (machine-check-file-system-availability machine) | 316 | (append (machine-check-file-system-availability machine) |
| 292 | (machine-check-initrd-modules machine))) | 317 | (machine-check-initrd-modules machine) |
| 318 | (list (machine-check-forward-update machine)))) | ||
| 293 | 319 | ||
| 294 | (define aggregate-exp | 320 | (define aggregate-exp |
| 295 | ;; Gather all the expressions so that a single round-trip is enough to | 321 | ;; Gather all the expressions so that a single round-trip is enough to |
| @@ -491,3 +517,7 @@ connection to the host."))) | |||
| 491 | for environment of type '~a'") | 517 | for environment of type '~a'") |
| 492 | config | 518 | config |
| 493 | environment))))) | 519 | environment))))) |
| 520 | |||
| 521 | ;; Local Variables: | ||
| 522 | ;; eval: (put 'remote-let 'scheme-indent-function 1) | ||
| 523 | ;; End: | ||
