From patchwork Tue May 18 09:06:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 441167 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp36456jac; Tue, 18 May 2021 02:12:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJwrHMB8HM28Etyja03Qfl8xdz/cPoT7fMMkWEd6krT6EewBxXk8dRLCdT+68RbA6B+E9g X-Received: by 2002:a67:2ec9:: with SMTP id u192mr4730274vsu.57.1621329129469; Tue, 18 May 2021 02:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621329129; cv=none; d=google.com; s=arc-20160816; b=yl9JfJrL6/o/lpW0NvJkoyaxmatS7Qsm8DoUe+tu9BXvcq8K8EAIYAoXcDmDqXaqKy p+j+lAWHUB3vVgIVdmluN4kfEFKcWn85aru7hb2d2akYEQUuGvISortoCP3UMxTeDILY Fy3bBmSanVTRrUueGF9FlL0RM87cv81qi3aA1KbcOxpF77BmAxuo1WIRpx+ubPlfsMCs V7CtMBVpbi8xaradOlFmLZoW68XLqfgUk0hl+SSRmGRx/NWGRlw9iz/hfPiM/0b2y93G c/fQZdetyYoPdS5Ayedzf9HVsiy2GlQCfOK9/9ZRbMsbTn1yIX4wz668TlpjUyX86h9d Ub2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=k3GgIZwo1ALDw7AyuDX5LfQUKo52ZHvXcuy3wRBGlmI=; b=cCQK0cmx7N1iM+175JxmsF8v5Mdrht7Q0Fqgn6PBh3TOQbZyRsv9d1TMxNz8mYFfoA GN+dJ4hnzSLtlqNAsqtugyCcu0UMPUvPvj8Wh1NDb9aFipZsSyB6PEpwmgUMSQS62dm0 oOOKpvGMGbbdIcOCl/Ijhxu9XGjORn+yzEaf+9Ez8bvTXp4Hxyxu//T/cOxnXT6Ib7xE YYr6ZXkbjLZdFNuY7qq4G1dT2PmXbyToMRygNQXGnStrgQ56rgeO8GVEJdyavv3mP8sF YcAtEHHpZCixIdH5dGa6SZ0081NdtNaZSaoQ6mVlN9gkWls/cutrwEQ8ktaBHsLsPzYL WfzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=T1Ke2WSA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v125si9132805vkf.22.2021.05.18.02.12.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 May 2021 02:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=T1Ke2WSA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1livlo-0004yk-TC for patch@linaro.org; Tue, 18 May 2021 05:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1livhJ-0007n8-4J for qemu-devel@nongnu.org; Tue, 18 May 2021 05:07:29 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:54861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1livhH-0005Qo-Cf for qemu-devel@nongnu.org; Tue, 18 May 2021 05:07:28 -0400 Received: by mail-wm1-x334.google.com with SMTP id o127so4979519wmo.4 for ; Tue, 18 May 2021 02:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k3GgIZwo1ALDw7AyuDX5LfQUKo52ZHvXcuy3wRBGlmI=; b=T1Ke2WSA+sKRz1V1wNjsW35K4N3kKn6JOCvD77u9/KQ7rqi1p7nVA97kFLrGfpHLhD oL5dnJAnYhI8dukQ6o7wuslvMuxabzj7VuKsCdC6V4PES0wFSYCJUXHY2xYVW+SMDYqm ElqNwo8wdv7JiIlSt/aPY9elcp5pWLc429P0ZtLc0zppNioM/1BQJSxTCr3C4WOm1Fhm qkwRbIxpsEZI9Ped0k2e1V76lDdtQ8sYjyG5xmuboLnWnIu3B/jefC8iOEBvNdgQQ7qI EtvAuYO1vAx07qXMZPk4S4xuzLrp5fhK3MYHeqSotBNWEUET4l1C+21eOxmd/rF/LIQi akdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k3GgIZwo1ALDw7AyuDX5LfQUKo52ZHvXcuy3wRBGlmI=; b=Ze1qbadBRwWe/1/YCOCH9KjGYusN+c3nlM5fR2lIGa81FuUgFzREsqUeOi3Jk6BHqU cwELuJ9qgZKRR/oD96eRgSNRCtaxYeyWb5dRpfkhCiOGiOVjRcL3uscgYitfltBv3eWn FOnnvYNlQovds0Yzco3te8FWw4fQOkLptsI0wSIvh0ZazsQKw0o6NENHn1gmOJRJ0WvO v8cNOSSJr6j7xp+X5NVMYPZuldJk9i2FjjWnD03NtEQRLoRaMHIF7eWuztCbaHoxwDpO vojhaCmwIbiGT7/FL+Lag3GoK1wvprLiHA87ZdJQsnReqsnRoFFuXEEuZ84I56LORc69 4gtw== X-Gm-Message-State: AOAM5311/HZprSjnT7qW2In6ADOcY9Gf3yeL3wwwyHsXORBQXYr4Jcun bhiPxxbXqcH/MvDCX+H6OBQaZA== X-Received: by 2002:a7b:cb85:: with SMTP id m5mr926923wmi.118.1621328845970; Tue, 18 May 2021 02:07:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x13sm10604875wro.31.2021.05.18.02.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 02:07:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3A7D81FF8F; Tue, 18 May 2021 10:07:21 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL v2 03/29] tests/docker: allow "update" to add the current user Date: Tue, 18 May 2021 10:06:54 +0100 Message-Id: <20210518090720.21915-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210518090720.21915-1-alex.bennee@linaro.org> References: <20210518090720.21915-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-devel@nongnu.org, Wainer dos Santos Moschetta , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Willian Rampazzo , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The current user functionality is used for cross compiling to avoid complications with permissions when building test programs. However for images that come from the registry we still need the ability to add the user after the fact. Reviewed-by: Willian Rampazzo Signed-off-by: Alex Bennée Message-Id: <20210512102051.12134-5-alex.bennee@linaro.org> -- 2.20.1 diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 9b3425fec2..7a14058801 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -517,7 +517,7 @@ def run(self, args, argv): class UpdateCommand(SubCommand): - """ Update a docker image with new executables. Args: """ + """ Update a docker image. Args: """ name = "update" def args(self, parser): @@ -525,6 +525,9 @@ def args(self, parser): help="Image Tag") parser.add_argument("--executable", help="Executable to copy") + parser.add_argument("--add-current-user", "-u", dest="user", + action="store_true", + help="Add the current user to image's passwd") def run(self, args, argv): # Create a temporary tarball with our whole build context and @@ -564,6 +567,13 @@ def run(self, args, argv): df.write(u"ADD . /\n") + if args.user: + uid = os.getuid() + uname = getpwuid(uid).pw_name + df.write("\n") + df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" % + (uname, uid, uname)) + df_bytes = BytesIO(bytes(df.getvalue(), "UTF-8")) df_tar = TarInfo(name="Dockerfile")