From patchwork Sun Aug 26 22:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Grandbois, Brett" X-Patchwork-Id: 962293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41z8Xk47V6z9s1c for ; Mon, 27 Aug 2018 08:17:58 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=opengear.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=opengear.com header.i=@opengear.com header.b="HYy19MQA"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41z8Xk2b5bzDrTP for ; Mon, 27 Aug 2018 08:17:58 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=opengear.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=opengear.com header.i=@opengear.com header.b="HYy19MQA"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=opengear.com (client-ip=40.107.72.46; helo=nam05-co1-obe.outbound.protection.outlook.com; envelope-from=brett.grandbois@opengear.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=opengear.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=opengear.com header.i=@opengear.com header.b="HYy19MQA"; dkim-atps=neutral Received: from NAM05-CO1-obe.outbound.protection.outlook.com (mail-eopbgr720046.outbound.protection.outlook.com [40.107.72.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41z8XZ3VR0zDr5Y for ; Mon, 27 Aug 2018 08:17:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=opengear.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+4gPH/lhQ+ka1c9PGSJ4Y2OSbSnFYGLXkVqjBlOcYPg=; b=HYy19MQAqtKRcMGy5QREsBjZ4bOcubg1ayOMJ3BXbocXosPts/NEevwSJwYLMTbW5fTbyx0Cb3ErVQFtTe6rfW/Ob/tK4iBeov3wC7KCcZ1+kKL40JorSfT2RKmNhQuRpQ/t41c/KnAjk/owafZtwQarNdO6vlsgt7VJuqccBsI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brett.grandbois@opengear.com; Received: from opengear.com (59.167.150.161) by BL0PR1501MB2049.namprd15.prod.outlook.com (2603:10b6:207:32::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Sun, 26 Aug 2018 22:17:42 +0000 From: Brett Grandbois To: petitboot@lists.ozlabs.org Subject: [PATCH] ui/ncurses: in lockdown ensure system reboot in ncurses menu exit Date: Mon, 27 Aug 2018 08:17:20 +1000 Message-Id: <20180826221720.30982-1-brett.grandbois@opengear.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [59.167.150.161] X-ClientProxiedBy: ME2PR01CA0176.ausprd01.prod.outlook.com (2603:10c6:220:20::20) To BL0PR1501MB2049.namprd15.prod.outlook.com (2603:10b6:207:32::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf66b43a-332f-4362-28f7-08d60ba1be58 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BL0PR1501MB2049; X-Microsoft-Exchange-Diagnostics: 1; BL0PR1501MB2049; 3:/1o8yV9qelgl2CoAaLviv8iQVIVShn2HNTbF5eJk4KXk1tPax/4aA1PdJf4w6wBWOEy+hMXQwJG4cHWOA3WwHjICrg6D+kY/PoXn4IfsWhfbicKJaVStAvmX4dhDSyf7ifR+j8gAKdSCH1xRoWdDdFXxYWu6CvTtMK74nNIlALt4SlBxHp91lfdmbfFbJe983sBMXeYXJIUJm3HeeQ08X3OCCMMRhrO8Xk5WmzAaZvE2m10gDExuqjQSk9Savi2k; 25:IFhX5U+9TE+jFcsXkH7Z0SRoRwnpIuLZu8+EC3Tj+U7wMJSbIgW3nMmwbY7FWxKphWjMohpXtrA3WhKnUk2lh1McnBtSPM4T2YhSUf7sMv0yvMoAwsNMBY8OdZFzil2r6GGG/jzdLbXSmYed3EHq90xAt3lJjapdFDzmg09fGRs8VhsdaBpskfZAc4HOxkLBPjoPMIk9zfZ9YemBysY3EkKoVXRQQYKDHOkVrX8I5G+Qij3oI5B2as0sK2FdXdQYwtYGktLyqXo0MzlFYuHuv6v48tFT4WR3jw+A1JwThur69oxZe+IREq/hs5+yDfTbdrkQqpgsLIcxRqb3+ryZew==; 31:T6akQvLLxDxoTcOQWiDBDMw/5eGmJ3sgLEdDDk2eDRF20BX1oRjttg1n3XCqTk1cfhsrUTozwWZQOOJNrF/K9dMWp/Ak1l2XyAUr+fh1l8rADJm2hPgS1F0C2fOiwjQ/ofu0VVO9suRYklzUdZVt5Jg6F4FO8/BuFBzygJ8Ry9CEL0uq8pt54Y/C/37CmXR7cB2hgOKoQBfPwSgMsd0lQkpO5FhepFT4aWZuQjN5oH8= X-MS-TrafficTypeDiagnostic: BL0PR1501MB2049: X-Microsoft-Exchange-Diagnostics: 1; BL0PR1501MB2049; 20:L4RKAd9lAcYLqIVUiWGwqNpIG90ez97QKJOw5f9xsz0EfGiaT58Pe8t8KBTvdY9eusDOBWqksIT/d/PyPYcceGBJV7Oc2XWlQrJYEymqAuWfNOFD7WCzyqxOQB0KeBmogSTBzTYjCIkwvbU2gGjvrkyhcjyShlk1pFWMxL/f+f4=; 4:9vMMK7y3QYJkljIYqU0gsG8qxvY2cdPEgU+9KeHEHafc0KmDam76mKq0ykMz8iVmwKQShuDzTVM01xAmIPTJvD9DftWDpUy4Locp4EXZCDs4RQBuT48lcD9WHbY0NXNNPKQS5vcPGtmLW2IqeK0TfUo2iXmbv2GDg8ikZWyR66zdp2STt9b+7PszzdkYp0ghUc08LuRmkfBE+oGduGQRZgCJNiIA/GZj9twUdU/EGd1Av4fa7SotWUJVKy89TBBHoQhepv2fCWaf6wPve4sJ8A60vcfYmGXY9MGexra1zwSxChxfQiax4Uj0o6ZwWycE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699016); SRVR:BL0PR1501MB2049; BCL:0; PCL:0; RULEID:; SRVR:BL0PR1501MB2049; X-Forefront-PRVS: 0776C39A48 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(376002)(39830400003)(346002)(199004)(189003)(36756003)(69596002)(55016002)(86362001)(53936002)(2361001)(1076002)(478600001)(105586002)(106356001)(7736002)(305945005)(25786009)(2351001)(81156014)(6116002)(44832011)(97736004)(316002)(47776003)(8936002)(50226002)(66066001)(2906002)(8676002)(50466002)(3846002)(186003)(81166006)(68736007)(14444005)(33026002)(26005)(5660300001)(52116002)(51416003)(16526019)(48376002)(16586007)(7696005)(1857600001)(386003)(6916009)(2616005)(6666003)(956004)(21086003)(476003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR1501MB2049; H:opengear.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: opengear.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL0PR1501MB2049; 23:X65+m4//YyfP+c1pobDXWwPsooaXmATuI7gRzsh?= bkXBv2b3HutZ0TTZK2l0/Md3si3kjGw2yGWq7T3qp3L7DBhahDz2eHwMZSMOZqGQG3tkY+CqWiF7vRVa+pf8+Iba93/e5E2+QfLfRd4rYXRtYi+vGrPXdrxsm9PQZ14OG7PAOIgj12UEgb3ubPFKYUj4FmRUWkmpTv7JeKxX5vwhltKcxPBRdTGTp/cdTb3Rt7HyumYb8u7goyfDOQ62SfgMQVUNOlS8bayMWCCBCibq6uhae+Wy8OFoxYlau9JLgI2jTAPj+7X5kl609Je8jaHJdqtKbh6VO6e8tJVYdQse5vaM9TeB9WgyLdhXUMbDPiRJfz4jx490NpmS3fAXhlVUHBn+5mjNZBSeGtJ+y2WqbuN9nEtufOE9eZJsgyQ7W7fH2GL24EHXCqX+pkBD7sPqv0k5dW4uKKfWajkt8+Jh1/4Noajg8sTeYH28HpnfiSmDgs2G6HUcbdx8uhe+WLSYGtFmOrRHCHrPJzLIFKxUPYZU5V+Ll8VcS0uliF3b6Oy6OosKopL3raeQ13BU3SOU860skrL7lGC2me7BnMfP+eq6sHN7xqflSRZTPfbfkdaAnGzqqt55pgHAeETZ1W42cqNqNUq4EIqYDYuP7ERQFE64s76CFlDZkXHkFPWqaHNhlRkftqmMzmyfgBk3tyYmzOqmAOI8CFYYmlzonS9kgybbwbxI2AZtoN5mywH2YjwVayKAganPZxMy9/XYrVd6Z//8oaHcotA2Qf43ZnTjFqSDgqbq0J/6TmQ6zNbk7JDI4lUjbQl/dhGe0epTL45b5vESQjx4JRXS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saDuUwtmt9rB5vrbZGQvO/tHq9pSiPJiEIE0h1PihAntkRwpBqeWBvhcJWREIGpmJJnZEhFT3ed8rNRWqeRHPKf+tNCShAI79TNZ3wUjqOp40gttA6N2HZvNt99J70qUElLZ++QnoWasKGwqW2RpZMo/it2UxhH9DRXbZIukxpt8VhHEoFyN4pqFCQJO2866BjagbVFoGr9lEgn7puxHNdER9noduKnPi3SuTi3DSBa6K81tSC33Z3ohGP9DvX3GE0mckqig3dg==; 5:xjTwwbp173Hwo/CZemdDfTzRswOSNeOMXLlpvReJVKaChHwPUf5OUgUtGbBLZ1J8Z0N6g59LIZEwPpKjOvvbawhsO/Yi56Qtk6TGtViyyeV9Hvg6n7giPK4IlGWGEjhZaXJ3wqmTh4ejiFz906cmc28H7saGSqvsD0JnXwjeg9I=; 7:Iym4an7KLcbN0FmM21+cWZKKaxVClfU2lgVIANUWZ6R3qIKt7qK+Z2qJnSfAytJCXvho5TZmHcl++BOWRPpIjJliYtxmYC8Bte4g6tH7wWnVV7EjXxv4cQSmJ6dzMNbi93KC9P56x3+BUepsMD3DZOG4iXh0OYIW1rBE0+zqDbrG955ALlElCS/IPr5qwI/scidQUPfOSfDsWGNRu01GwN9aOSz5B25ioH5mc6HFNCozzbq9U9lnGrRS7k/BROzf SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: opengear.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2018 22:17:42.0165 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf66b43a-332f-4362-28f7-08d60ba1be58 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a6251c26-d21f-4164-a225-1f4eaebf5f9a X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR1501MB2049 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" In a lockdown situation in the ncurses menu there is a switch to replace the 'Exit to shell' option with 'Reboot', so the intent seems to be to not allow the user the option to exit to shell in a lockdown situation. However the associated foreced reboot logic is in the process atexit so is only triggered when completely exiting the menu system. The default menu item logic to exit to shell is still in place though so the menu exit never occurs and shell access is still available. Add a switch to a different menu exit callback to force a menu abort using the same mechanism as a signal in lockdown situations so the shell can never be entered. This also affects the 'x' or esc shortcut keys. Signed-off-by: Brett Grandbois --- ui/ncurses/nc-cui.c | 13 ++++++++++++- ui/ncurses/nc-cui.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 3abeac3..d3e00aa 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -219,6 +219,17 @@ void cui_on_exit(struct pmenu *menu) talloc_free(sh_cmd); } +/** + * cui_abort_on_exit - Force an exit of the main loop on menu exit. + * This is mainly for lockdown situations where + * the exit then triggers an expected reboot. + */ +void cui_abort_on_exit(struct pmenu *menu) +{ + struct cui *cui = cui_from_pmenu(menu); + cui->abort = 1; +} + /** * cui_run_cmd - A generic cb to run the supplied command. */ @@ -1298,7 +1309,7 @@ static struct pmenu *main_menu_init(struct cui *cui) int result; bool lockdown = lockdown_active(); - m = pmenu_init(cui, 9, cui_on_exit); + m = pmenu_init(cui, 9, lockdown ? cui_abort_on_exit : cui_on_exit); if (!m) { pb_log_fn("failed\n"); return NULL; diff --git a/ui/ncurses/nc-cui.h b/ui/ncurses/nc-cui.h index 4997f4b..d26883b 100644 --- a/ui/ncurses/nc-cui.h +++ b/ui/ncurses/nc-cui.h @@ -107,6 +107,7 @@ void cui_send_reinit(struct cui *cui); void cui_abort(struct cui *cui); void cui_resize(struct cui *cui); void cui_on_exit(struct pmenu *menu); +void cui_abort_on_exit(struct pmenu *menu); void cui_on_open(struct pmenu *menu); int cui_run_cmd(struct cui *cui, const char **cmd_argv); int cui_run_cmd_from_item(struct pmenu_item *item);