From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gGD0BzLS4mG7wAAAgWs5BA (envelope-from ) for ; Sat, 15 Jan 2022 14:54:58 +0100 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id oOzSBDLS4mF2LwEAauVa8A (envelope-from ) for ; Sat, 15 Jan 2022 14:54:58 +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 aspmx2.migadu.com (Postfix) with ESMTPS id B0A313618A for ; Sat, 15 Jan 2022 14:54:57 +0100 (CET) Received: from localhost ([::1]:44508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8jWC-00017c-R3 for larch@yhetil.org; Sat, 15 Jan 2022 08:54:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8jTc-00067b-I4 for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:16 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8jTO-0004RG-TS for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:14 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8jTO-0001uW-TM for guix-patches@gnu.org; Sat, 15 Jan 2022 08:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53063] [PATCH v2 wip-harden-installer 16/18] installer: Use dynamic-wind to setup installer. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 15 Jan 2022 13:52:02 +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.16422546757237 (code B ref 53063); Sat, 15 Jan 2022 13:52:02 +0000 Received: (at 53063) by debbugs.gnu.org; 15 Jan 2022 13:51:15 +0000 Received: from localhost ([127.0.0.1]:39541 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jSc-0001sZ-Rw for submit@debbugs.gnu.org; Sat, 15 Jan 2022 08:51:15 -0500 Received: from jpoiret.xyz ([206.189.101.64]:49868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8jS3-0001oE-15 for 53063@debbugs.gnu.org; Sat, 15 Jan 2022 08:50:40 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 248C3185147; Sat, 15 Jan 2022 13:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1642254638; 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=BOAk/vlMLDBj4I3CkbJ9WnydFu0uFGXy77b8BIlkFbQ=; b=drvOvfL/RZdRmhMkX9JP+dt44pfkdsrcQB+/FbtAH+jDixCA2nm31IErkD+7YoL8CNF8H2 cjt7/dtDYPwLZHjpBlpYjKMV4UpbhHE0ut7E+ZZjg+goLekB52pGbXM5Pdos7XiI9qycqg ld5lKrckCA74ueqptGNUeMOv3CEUk/B4WExN+aZ3YgU93XnR1ox+PIOWdSj6BYGru/bqn5 Et7GpP1ZLQO9TzLC72FvY50sy27OdD9X00PyLZxlEz9KozxbdMP3fSUasgubuXTQv+eFXz LkAPaN08k7CkZ3RvLNxjXXQfa/LcE+lDq4FuRB9AoZiRAAqM+D5HGdDGnY3x9w== Date: Sat, 15 Jan 2022 14:50:09 +0100 Message-Id: <20220115135011.5817-17-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=1642254897; 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=BOAk/vlMLDBj4I3CkbJ9WnydFu0uFGXy77b8BIlkFbQ=; b=UWr75ch2wmZgEf0vvWqvga/qhE8fV2TyASW8/QnYEsD2LYj19JX0nEX3IjbBEX/cJzN7iB 7LhjRtmQB+Jd1DpYVxu+lMcion90vf9ByjR0Jrp9VSM57pCUvOuECbe+KZc3dzDgR1KTtj LjSfiloXa088axL3qziriMOWvlcYKhBZVFibGxurezQOvjlhAkE7HL4Xb5vuHYJdF2D/yx lfBzj4FD9QRnWjq1D5gK9P/yMWvkwb89nkMLQRqrDd73j8KCz7myBlxVyOYAp+MqYKa2g4 jw5AYPDG2RSLyxIf/NCHmJuZapvUAsWT6kaQBYpWlK0L/703JFBoLtx0hXnz2A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642254897; a=rsa-sha256; cv=none; b=pQHD7wUr9PmKytfnwFLsBmTLy64RRJU3U1YwojpyzREPwuNVwzSg8XcAZTYzVRQxDLlXZE uBlq57uWQkmqMi0tn1vil6sIxrg+8+6oUsc0WLXryFIJ0VorRWHKVSl/FjcJooRQeg0k/y 5MITLlKypjNkp0BSA7l6cr7sMXayQSTlAIGrh0gAzgVxNRlF5+JaSXSXmRJAUW6Vc3AiEg dtPWuqVySdon4voJslC3Va03JxfCuFdkI0mBYleUaZVrIeV8aG0Pc778XnsEgMmbHKddF8 IsIYGSjV+4ceO2Gc4s7lA8dBL/ZAjmaDpipupyLPajiVqdIaQGiNw2QVz78fnQ== ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b="drvOvfL/"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx2.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: aspmx2.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b="drvOvfL/"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx2.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: B0A313618A X-Spam-Score: -3.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: w0sCwDCf3Rk3 * gnu/installer.scm (installer-program): Use dynamic-wind, so that completely uncaught exceptions can be printed properly. --- gnu/installer.scm | 92 ++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/gnu/installer.scm b/gnu/installer.scm index c7e0921a19..86495a067b 100644 --- a/gnu/installer.scm +++ b/gnu/installer.scm @@ -416,51 +416,53 @@ (define installer-builder (define current-installer newt-installer) (define steps (#$steps current-installer)) - ((installer-init current-installer)) - - (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)))))) + (dynamic-wind + (installer-init current-installer) + + (lambda () + (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)))))) (program-file "installer" -- 2.34.0