From patchwork Thu May 30 05:25:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 1107559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Dwyz2j1Qz9s00 for ; Thu, 30 May 2019 15:25:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="TB5CUecQ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="10ofcn8W"; 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 45Dwyz1dR1zDqTW for ; Thu, 30 May 2019 15:25:47 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.29; helo=out5-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="TB5CUecQ"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="10ofcn8W"; dkim-atps=neutral Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45Dwyq00qYzDqSn for ; Thu, 30 May 2019 15:25:38 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id BBBF7220CB; Thu, 30 May 2019 01:25:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 30 May 2019 01:25:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=fm3; bh=wsPZpabQoEM2c+oLzliMgV9+W4txTZg6iU4rme+mHso=; b=TB5CU ecQBjdKVE7vZjmzrLDpxEgpfNg7hbOdGfNdJ6T8Co9STWVFSrfLFrFwoBtR4duE/ O/XSYNJJzzsRZxlKl9ymhMS5aEOHqjENvo9udFF/7r+iL2YWwHL9Ub+96vNvUW25 XK8NZXE9mTEHa2DuIslE0CcYqhcpNeaZISGGPbtXB9wtpVWQUX78JBKsGwZa5XHm c0zmpZyFChtTAWrxnQDovslu3kj9xR8lZMx8BexgHJFkg7+JQKbwLYBZBxW033TF cWeoxnjU/WNc+BGVMmHjfdEfAQxDJX/xU3m0ZGBGIAJQCFuvz38TdYzjvzwL2o7R 9WdZJhmGlydszQ6gg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=wsPZpabQoEM2c+oLzliMgV9+W4txTZg6iU4rme+mHso=; b=10ofcn8W BAGM7XXq1z67vludKD8Yup8sALSA7gZGXo03/s7SOJPcT6n5fp9/DzYLAYklCnJz p8x3lqIYJCAAbgY6QZX7g2Weo5hpFYlcVo/F0K1q9AOyAxzQuJmTCZq5/E0doa6b sjqSwpBU9A8wSVhzpsKn/uv8Jn8YbrhTw7MQw8owoZp8wgJNAmf3zi3HGo+BvfVR K7K7rsLjwynnRPLTFQp0yLLnKA1OcPdaQ10HCPeIfhE7ahr31CJMn7mGf9ajvdgZ L9WK+VZ64dTck9dLlonHMo9zGfq6ST7G7k5MHrni/7u2lrzTsG5/6B9fenGkbKfP wP+B+CJA2tRtWA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddvkedgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepufgrmhhuvghlucfovghnughoiigrqdflohhnrghsuceoshgr mhesmhgvnhguohiirghjohhnrghsrdgtohhmqeenucfkphepuddvvddrleelrdekvddrud dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmsehmvghnughoiigrjhhonhgrshdr tghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 5F16280061; Thu, 30 May 2019 01:25:35 -0400 (EDT) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 2/2] utils: Optionally run utilities as root Date: Thu, 30 May 2019 15:25:25 +1000 Message-Id: <20190530052525.5598-2-sam@mendozajonas.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530052525.5598-1-sam@mendozajonas.com> References: <20190530052525.5598-1-sam@mendozajonas.com> MIME-Version: 1.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" In particular this fixes running pb-plugin executables from the UI since the wrapper requires root to set up the environment. Signed-off-by: Samuel Mendoza-Jonas --- utils/pb-exec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/utils/pb-exec b/utils/pb-exec index bfe13f6b..f1d22e6c 100755 --- a/utils/pb-exec +++ b/utils/pb-exec @@ -1,7 +1,17 @@ #!/bin/sh +PREFIX="" + +# Check if root required +if [[ "$(id -u)" != "0" ]]; then + read -n 1 -r -p "Running as user $(id -un), run as root? (y/N)" key + if [ "$key" == "y" ]; then + PREFIX="sudo" + fi +fi + # Run a program specified by Petitboot. -$@ +$PREFIX $@ echo "$0 ran '$@'" # Wait for the user to exit back to Petitboot.