From patchwork Thu Aug 22 13:47:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 11109329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CA5C13B1 for ; Thu, 22 Aug 2019 13:50:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6D882233FD for ; Thu, 22 Aug 2019 13:50:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D882233FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:43304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0nTy-00005T-SF for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Aug 2019 09:50:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44869) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0nRK-0006UL-O2 for qemu-devel@nongnu.org; Thu, 22 Aug 2019 09:47:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0nRJ-00061Z-Po for qemu-devel@nongnu.org; Thu, 22 Aug 2019 09:47:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0nRJ-000616-K1 for qemu-devel@nongnu.org; Thu, 22 Aug 2019 09:47:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E854611A06; Thu, 22 Aug 2019 13:47:44 +0000 (UTC) Received: from localhost (ovpn-116-85.phx2.redhat.com [10.3.116.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EAE060605; Thu, 22 Aug 2019 13:47:35 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= To: qemu-devel@nongnu.org Date: Thu, 22 Aug 2019 17:47:20 +0400 Message-Id: <20190822134725.32479-2-marcandre.lureau@redhat.com> In-Reply-To: <20190822134725.32479-1-marcandre.lureau@redhat.com> References: <20190822134725.32479-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 22 Aug 2019 13:47:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/6] docker.py: add --run-as-current-user 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 Zheng , peter.maydell@linaro.org, =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= , alex.bennee@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" (podman will need further tweaks) Suggested-by: Paolo Bonzini Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Daniel P. Berrangé --- tests/docker/Makefile.include | 2 +- tests/docker/docker.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index dbd58e548c..582846a587 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -212,7 +212,7 @@ docker-run: docker-qemu-src " COPYING $(EXECUTABLE) to $(IMAGE)")) $(call quiet-command, \ $(DOCKER_SCRIPT) run \ - $(if $(NOUSER),,-u $(shell id -u)) \ + $(if $(NOUSER),,--run-as-current-user) \ --security-opt seccomp=unconfined \ $(if $V,,--rm) \ $(if $(DEBUG),-ti,) \ diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 53a8c9c801..f15545aeea 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -333,8 +333,13 @@ class RunCommand(SubCommand): def args(self, parser): parser.add_argument("--keep", action="store_true", help="Don't remove image when command completes") + parser.add_argument("--run-as-current-user", action="store_true", + help="Run container using the current user's uid") def run(self, args, argv): + if args.run_as_current_user: + uid = os.getuid() + argv = [ "-u", str(uid) ] + argv return Docker().run(argv, args.keep, quiet=args.quiet)