From patchwork Wed May 12 10:20:24 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: 435475 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4685813jao; Wed, 12 May 2021 03:21:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvwiOFwRqcy1Yi0K9XEgQMsqdwOZwCmcRb1ipdC4wNstuccsCqpdupeLXQG/ZWfeA1ikKy X-Received: by 2002:a67:8751:: with SMTP id j78mr30874408vsd.21.1620814883542; Wed, 12 May 2021 03:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620814883; cv=none; d=google.com; s=arc-20160816; b=fd07TU4Bb8bnVlSP3ooqzMkEPNumNFCdjsE+to0L4wAois0r8vfRVxZnDW8nrWW0G1 9UHPrcZykQIpyMCSCyDDmeCHzo7+3JdmCLRms4kSx5VvwD+RY3LOPJ+lUVK6F3NjimNO OkhRDrxOnAL4wEWEEfnytrawOYD2UEccp/0wokJoks4Ersb9fI1UCJYWZTy1sEr7LlU0 iILztlOIAFl3PkMPQ/cvK7Z6yt8QeZn673aS2NSHuxZfQtUHQsiAlbwI1F3aJN4WQZjb f54RDObpewfoGpA1QUIZJi3jW2ubQKeuPhsfnHctPTlIWb5qRdIk6HOqgZozSUSVp2w+ zPoQ== 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=itDJZjFFgEhRSTkYYv8ljT67JkqTdrMRXTGjjJSCeDY=; b=jWVn4jUf0CxyJNeY3zyZWQuWvWj7sOhYdVfyrfiaJ9iqDB+HBl+TmZQ6W/yJF00LaY LNMX8AOk60n9Rr2rGklTvyTZ5Cljjln4+093pff8r0rUwo/M3Y5uMrHygGhA+3/+C8SF T88zvkolwh0HuG0VvIzS3z43KMd1vqKOyhFW/gm/2dblPQvhFIRtRZ9nrZWAGqfMmUvc 6ssIrnL3iujfgGD5vqU/DO94XTP62j/AHtKFfiKGc59Krs9RanhdQLLz6xW+6cHr5pRF 61FAXg62JyAp9rP8whuV+jjc40mEyFTYvxYXY3xpxJt1hJO+Eeq7FYL8xat9cWTT1PKV cltQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FvRdj5Oi; 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 t24si1890078vsj.267.2021.05.12.03.21.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 May 2021 03:21:23 -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=FvRdj5Oi; 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]:38410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lglzW-0003Ng-Kt for patch@linaro.org; Wed, 12 May 2021 06:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lglzC-0003HH-O7 for qemu-devel@nongnu.org; Wed, 12 May 2021 06:21:02 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:42752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lglzA-0003Yg-K8 for qemu-devel@nongnu.org; Wed, 12 May 2021 06:21:02 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 4-20020a05600c26c4b0290146e1feccd8so2757058wmv.1 for ; Wed, 12 May 2021 03:21:00 -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=itDJZjFFgEhRSTkYYv8ljT67JkqTdrMRXTGjjJSCeDY=; b=FvRdj5OiLxfzxL5ZlmpkLUyY3w7NNegSF+WNrcflIt0m0cz2BKNfWQIYMFuGQGP1po CnICvdpnFpuRQwnGA1Po5iqSBCVEOVfPBGuZyG/82CnIC3Qf30+vccrJ5doutHH8meYJ rMIgYksvXJN1GTMCXW0zgdMwGnx3hyQ+Cwe7J/m1QRzN9qgCSMBAwFRBOMDPdtAqAYtS Sxk2Q4sxO7OrAhUd23suSetfrAfA7FJfeT9sCV33RhjB6n5K+3ELzHciyyhd+VZWHFt4 SIqj9PcTPlCFyeOL0vaW4sOGvyz7NGsTKu6y45IqUj8IvzTGx8tJ1zbFmWxM2LIAjKBp SWYA== 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=itDJZjFFgEhRSTkYYv8ljT67JkqTdrMRXTGjjJSCeDY=; b=BlIF91gCIBjb36SVuAHCUVxZLhMNZkuuLftelatIbX62MEqoOwBdYD36G+1K4QVn62 AlHrHx7nZfFEzN7fCtUaH0RNrWl+gUr7/QS48+MN82WJzSFxEluYKXsvos6iutWZ6q4T 3Ez8zKTDdl0Km5MXl6OLDl3vEqi9ZtC9nY2+3vwUSlKVGSiFn6k50FwmYfnYbNsozHsL pzThZArEJeuZvyJZcVshOfKP3fXw3ZqgP152jMVI7VvVkZgIdNZOwHh5x+CZIJgPcRyT SP9+u6sDB7A6IS7NkRuYJ0V02qzeo+X8dtIl0zfEWELTzod7fOEXGv0zEGw9EtWjDyXc 54ew== X-Gm-Message-State: AOAM5305pG7YoML631kuzwE6pH4aLTRz9q9hk+9QcvAXLyco/FkUb2ua 2LfmVA8ngh3QzceR6mRK5C9kCQ== X-Received: by 2002:a7b:cd98:: with SMTP id y24mr11014321wmj.4.1620814859211; Wed, 12 May 2021 03:20:59 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s7sm5659562wmh.35.2021.05.12.03.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 03:20:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7D98A1FF90; Wed, 12 May 2021 11:20:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 04/31] tests/docker: allow "update" to add the current user Date: Wed, 12 May 2021 11:20:24 +0100 Message-Id: <20210512102051.12134-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210512102051.12134-1-alex.bennee@linaro.org> References: <20210512102051.12134-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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: fam@euphon.net, Thomas Huth , berrange@redhat.com, f4bug@amsat.org, Wainer dos Santos Moschetta , Willian Rampazzo , stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net 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 --- tests/docker/docker.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 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")