From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6KnLH6/R4mGIxwAAgWs5BA (envelope-from ) for ; Sat, 15 Jan 2022 14:52:47 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id uKxGHa/R4mHCTQAA9RJhRA (envelope-from ) for ; Sat, 15 Jan 2022 14:52:47 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1B3E92A10D for ; Sat, 15 Jan 2022 14:52:47 +0100 (CET) Received: from localhost ([::1]:40030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8jU6-0006T2-7K for larch@yhetil.org; Sat, 15 Jan 2022 08:52:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8jSV-0005Eo-77 for guix-patches@gnu.org; Sat, 15 Jan 2022 08:51:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8jST-0004FU-Cv for guix-patches@gnu.org; Sat, 15 Jan 2022 08:51:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8jST-0001rJ-Cn for guix-patches@gnu.org; Sat, 15 Jan 2022 08:51:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53063] [PATCH v2 wip-harden-installer 08/18] installer: Add installer-specific run command process. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 15 Jan 2022 13:51:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53063 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Mathieu Othacehe Cc: 53063@debbugs.gnu.org, ludo@gnu.org, Josselin Poiret Received: via spool by 53063-submit@debbugs.gnu.org id=B53063.16422546437022 (code B ref 53063); Sat, 15 Jan 2022 13:51:05 +0000 Received: (at 53063) by debbugs.gnu.org; 15 Jan 2022 13:50:43 +0000 Received: from localhost ([127.0.0.1]:39510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jS6-0001p6-9I for submit@debbugs.gnu.org; Sat, 15 Jan 2022 08:50:43 -0500 Received: from jpoiret.xyz ([206.189.101.64]:48812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jRu-0001md-I5 for 53063@debbugs.gnu.org; Sat, 15 Jan 2022 08:50:31 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id D4D72184F80; Sat, 15 Jan 2022 13:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1642254630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FsbknpGBFmZ5SSimoDNsxDI3hBbYL2EBu1X8xGCZ+TE=; b=bXVpnsByqH/CDl4J219ktRUmJUzvFlVY9r2IPM6vp04e7Uxbf1mlrQ7LUcMBajDEITakrU BVi8jPbPyPi5G4wgQCeSX06bXCF8bbaxZbcDxOqGxUqpFxQVPznHvFeJdo6HaHUzJgfVIW y1ndq2ZWrzsA33sQx/eXn/famQSts2JD2XDS5qUH6mMtmsOgVZ57K4InJ3d1zXj3qJ6K5O kxngeS0RXUpMkyIL0JLFBKPi4xUh73AMzHEccM71Ejj7/NTdvHRn+vWGBfusP+fhpiyaV3 D1pf8xa7RR6sIu5uOwtAoCZpwsHwybhLibFlEXw1T7tPxe1H4cljBuiC49BLtA== Date: Sat, 15 Jan 2022 14:50:01 +0100 Message-Id: <20220115135011.5817-9-dev@jpoiret.xyz> In-Reply-To: <20220115135011.5817-1-dev@jpoiret.xyz> References: <8735lz4xsv.fsf@gnu.org> <20220115135011.5817-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches From: Josselin Poiret via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642254767; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=FsbknpGBFmZ5SSimoDNsxDI3hBbYL2EBu1X8xGCZ+TE=; b=t9VAGpxnVIWGTiz4MIfpJfDOKHZZkmhaXfDImEr+McjCrE0DWbjOoaDMXh115DGsXse3ll PbB+2B2bdO+jB2Lg1wIt+z7+LLT9JU3G4t7hYMgzXlYugUFlDmXpKG+raxp1Vc9eCcaQhQ 1w9cwMvj2OnaRkB1K6yaEaJxZBZ8k4HTsGjePYbwytSNy1c1VfS0KsiWaAEiXP6Atw/LTD epZPYUPbpdbVvbGwQoWXH+r5cnWUUKyKylDT1Vv3WDacqKl5PHcGzfe7AB30zIbCOD61uE CAbADO2qFg6YwaOpNZ9sMCJVU4SXmeguVL6PbQA4FTo/ktCrig/Watn5Fv3XBQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642254767; a=rsa-sha256; cv=none; b=o7RQnRiUGf/CQMNJ2na5RNg7noSHarCz0MezPdxWsS2zKXtyBe/s3psvsr4ZQUY71XH+cj LLzuu/QZ/ghsFDPbFcFJc99eptlIWhdWRAmzWL1/Y4zyiAYSyoagq3/tq2BPDBYneIHw/k tzaRMIrsOcefhZhxVyzAplCfTY7SIGdxnTUGZKPb7eGJOVz/tcbUslOuphJLuRGazO5/9s bNWMskeT9rIQWmwqz8/vQwwJniXuI+h+MX3s7E6kqnkJ786hekt6nKjqWKPP8CxFYXDszU 9Bqw3phxDOpeLxvdyAkz6Tj8LBObM+ozxp0YmPqWEGyn9SlxLnn6IBWiOTpvKw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=bXVpnsBy; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=bXVpnsBy; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1B3E92A10D X-Spam-Score: -3.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: mChlgmOPcgo0 * gnu/installer/record.scm (installer)[run-command]: Add field. * gnu/installer/utils.scm (run-command-in-installer): Add parameter. * gnu/installer.scm (installer-program): Parameterize run-command-in-installer with current installer's run-command. * gnu/installer/newt.scm (newt-run-command): New variable. (newt-installer): Use it. --- gnu/installer.scm | 79 +++++++++++++++++++++------------------- gnu/installer/newt.scm | 10 ++++- gnu/installer/record.scm | 7 +++- gnu/installer/utils.scm | 10 +++++ 4 files changed, 65 insertions(+), 41 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index d0d012f04b..3cc5c79d4e 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -416,44 +416,47 @@ (define current-installer newt-installer) (define steps (#$steps current-installer)) ((installer-init current-installer)) - (catch #t - (lambda () - (define results - (run-installer-steps - #:rewind-strategy 'menu - #:menu-proc (installer-menu-page current-installer) - #:steps steps)) - - (match (result-step results 'final) - ('success - ;; We did it! Let's reboot! - (sync) - (stop-service 'root)) - (_ - ;; The installation failed, exit so that it is restarted - ;; by login. - #f))) - (const #f) - (lambda (key . args) - (installer-log-line "crashing due to uncaught exception: ~s ~s" - key args) - (let ((error-file "/tmp/last-installer-error") - (dump-archive "/tmp/dump.tgz")) - (call-with-output-file error-file - (lambda (port) - (display-backtrace (make-stack #t) port) - (print-exception port - (stack-ref (make-stack #t) 1) - key args))) - (make-dump dump-archive - #:result %current-result - #:backtrace error-file) - (let ((report - ((installer-dump-page current-installer) - dump-archive))) - ((installer-exit-error current-installer) - error-file report key args))) - (primitive-exit 1))) + (parameterize + ((run-command-in-installer + (installer-run-command current-installer))) + (catch #t + (lambda () + (define results + (run-installer-steps + #:rewind-strategy 'menu + #:menu-proc (installer-menu-page current-installer) + #:steps steps)) + + (match (result-step results 'final) + ('success + ;; We did it! Let's reboot! + (sync) + (stop-service 'root)) + (_ + ;; The installation failed, exit so that it is restarted + ;; by login. + #f))) + (const #f) + (lambda (key . args) + (installer-log-line "crashing due to uncaught exception: ~s ~s" + key args) + (let ((error-file "/tmp/last-installer-error") + (dump-archive "/tmp/dump.tgz")) + (call-with-output-file error-file + (lambda (port) + (display-backtrace (make-stack #t) port) + (print-exception port + (stack-ref (make-stack #t) 1) + key args))) + (make-dump dump-archive + #:result %current-result + #:backtrace error-file) + (let ((report + ((installer-dump-page current-installer) + dump-archive))) + ((installer-exit-error current-installer) + error-file report key args))) + (primitive-exit 1)))) ((installer-exit current-installer)))))) diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm index 61fb9cf2ca..fc851339d1 100644 --- a/gnu/installer/newt.scm +++ b/gnu/installer/newt.scm @@ -79,6 +79,13 @@ (define (exit-error file report key args) (newt-finish) (clear-screen)) +(define (newt-run-command . args) + (newt-suspend) + (clear-screen) + (define result (run-command args)) + (newt-resume) + result) + (define (final-page result prev-steps) (run-final-page result prev-steps)) @@ -150,4 +157,5 @@ (define newt-installer (welcome-page welcome-page) (parameters-menu parameters-menu) (parameters-page parameters-page) - (dump-page dump-page))) + (dump-page dump-page) + (run-command newt-run-command))) diff --git a/gnu/installer/record.scm b/gnu/installer/record.scm index e7cd45ee83..23db3edd70 100644 --- a/gnu/installer/record.scm +++ b/gnu/installer/record.scm @@ -42,7 +42,8 @@ (define-module (gnu installer record) installer-welcome-page installer-parameters-menu installer-parameters-page - installer-dump-page)) + installer-dump-page + installer-run-command)) ;;; @@ -94,4 +95,6 @@ (define-record-type* ;; procedure (keyboard-layout-selection) -> void (parameters-page installer-parameters-page) ;; procedure (dump) -> void - (dump-page installer-dump-page)) + (dump-page installer-dump-page) + ;; procedure command -> bool + (run-command installer-run-command)) diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index 9cfff0054b..4f7c691690 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -25,6 +25,7 @@ (define-module (gnu installer utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:use-module (ice-9 control) #:use-module (ice-9 match) #:use-module (ice-9 popen) @@ -39,6 +40,7 @@ (define-module (gnu installer utils) run-external-command-with-handler run-external-command-with-line-hooks run-command + run-command-in-installer syslog-port %syslog-line-hook @@ -167,6 +169,14 @@ (define succeeded? (pause) succeeded?) +(define run-command-in-installer + (make-parameter + (lambda (. args) + (raise + (condition + (&serious) + (&message (message "run-command-in-installer not set"))))))) + ;;; ;;; Logging. -- 2.34.0