Subject: [bug#53063] [PATCH wip-harden-installer 09/14] installer: Use the command capturing facility for guix init.

From: Josselin Poiret <[email-masked]>
Date: Thu, 6 Jan 2022 23:48:07 +0100

* gnu/installer/newt/final.scm (run-install-shell): Remove procedure,
as run-command-in-installer now takes care of everything.
(run-final-page): Directly use install-system.
* gnu/installer/final.scm (install-system): Restore PATH inside the
container, and use run-command-in-installer.
---
 gnu/installer/final.scm      | 17 +++--------------
 gnu/installer/newt/final.scm | 10 +---------
 2 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index fbfac1f692..ba39dad354 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -169,6 +169,7 @@ (define (assert-exit x)
          (database-dir    "/var/guix/db")
          (database-file   (string-append database-dir "/db.sqlite"))
          (saved-database  (string-append database-dir "/db.save"))
+         (path (getenv "PATH"))
          (ret             #f))
     (mkdir-p (%installer-target-dir))
 
@@ -205,20 +206,8 @@ (define (assert-exit x)
              (stop-service 'guix-daemon)
              (start-service 'guix-daemon (list (number->string (getpid))))
 
-             (setvbuf (current-output-port) 'none)
-             (setvbuf (current-error-port) 'none)
-
-             ;; If there are any connected clients, assume that we are running
-             ;; installation tests. In that case, dump the standard and error
-             ;; outputs to syslog.
-             (set! ret
-                   (if (not (null? (current-clients)))
-                       (with-output-to-file "/dev/console"
-                         (lambda ()
-                           (with-error-to-file "/dev/console"
-                             (lambda ()
-                               (run-command install-command)))))
-                       (run-command install-command))))
+             (setenv "PATH" path)
+             (set! ret (apply (run-command-in-installer) install-command)))
            (lambda ()
              ;; Restart guix-daemon so that it does no keep the MNT namespace
              ;; alive.
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index efe422f4f4..07e8cf3864 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -98,14 +98,6 @@ (define (run-install-failed-page)
      (send-to-clients '(installation-failure))
      #t)))
 
-(define* (run-install-shell locale
-                            #:key (users '()))
-  (clear-screen)
-  (newt-suspend)
-  (let ((install-ok? (install-system locale #:users users)))
-    (newt-resume)
-    install-ok?))
-
 (define (run-final-page result prev-steps)
   (define (wait-for-clients)
     (unless (null? (current-clients))
@@ -129,7 +121,7 @@ (define (wait-for-clients)
            user-partitions
            (configuration->file configuration)
            (run-config-display-page #:locale locale)
-           (run-install-shell locale #:users users))))
+           (install-system locale #:users users))))
     (if install-ok?
         (run-install-success-page)
         (run-install-failed-page))))
-- 
2.34.0