From nobody Sun Feb 8 18:08:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612976529; cv=none; d=zohomail.com; s=zohoarc; b=KJAcBKCcnr2hwmm1LNkKCG2lSDqmih1cbtnql4zOrXxyBEDmcPt+7UQADpPxcgZRmzxMeHGQ9SgzoEjTOyyyiyctqQDaDM9OpfyjrfGN8Rzms/ThVkSbJDYiuW3c9OAzlAESVgCe4zyRm+Iexcx96CJ8bHmTNburd84aTgmna+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612976529; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UmNhtUfYVaYZn8zGO0wdPIC2zWU8PmOAqid3AESyT1c=; b=VW4ygWhTr62+m6Ijk+Pa7Z/R7vBkY7qwfl52s7kxVSHv0QLn8INWxHk10iw+RBAgAlt9VvIggaNhcJr6SyDT5JR2RhrKyzbmg+1vbkjtIWMbZgP3v2AUp9CmhnUif42y5HJ0obyTnk1ALQtkClXCJyHTVjBEtOVkszNWfr+hvJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 16129765284931007.5457786031063; Wed, 10 Feb 2021 09:02:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-HH87sBTiOOyQ6K56m6I21w-1; Wed, 10 Feb 2021 12:02:04 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 858D88F54C7; Wed, 10 Feb 2021 17:01:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE47057; Wed, 10 Feb 2021 17:00:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BC2AF18095C9; Wed, 10 Feb 2021 17:00:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11AH0twB014664 for ; Wed, 10 Feb 2021 12:00:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 608A67D573; Wed, 10 Feb 2021 17:00:55 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.192.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34A6C722CA; Wed, 10 Feb 2021 17:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612976526; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UmNhtUfYVaYZn8zGO0wdPIC2zWU8PmOAqid3AESyT1c=; b=PhcuCvBsKBUN0wz1viQmaaj4wLpr+ZYga9C4nBScvdhnL8U3sgKOi5CIAg3LZEJqVhk8C3 nEKge729o8Y6k8Zac90/ZAuw3BhxgNWwbT8agQ47eXVLjUHHNlI2R8pDbI5Wh/z5cJWE9N 4xOAU2etzynwIn5VpoHOVIgFbrVgYR0= X-MC-Unique: HH87sBTiOOyQ6K56m6I21w-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] ci: Expose CI_USER_LOGIN as a Makefile variable for users to use Date: Wed, 10 Feb 2021 18:00:43 +0100 Message-Id: <5a9da8e2091c887c58a50ec7a592e3fdfdcb293e.1612976435.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" More often than not I find myself debugging the containers which means that I need to have root inside, but without manually tweaking the Makefile each time the execution would simply fail thanks to the uid/gid mapping we do. What if we expose the CI_USER_LOGIN variable, so that when needed, the root can be simply passed with this variable and voila - you have a root shell inside the container with CWD=3D~root. Signed-off-by: Erik Skultety --- ci/Makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/Makefile b/ci/Makefile index 1a376a7f0c..84f2f77526 100644 --- a/ci/Makefile +++ b/ci/Makefile @@ -47,13 +47,13 @@ CI_REUSE =3D 0 =20 # We need the container process to run with current host IDs # so that it can access the passed in build directory -CI_UID =3D $(shell id -u) -CI_GID =3D $(shell id -g) +CI_UID =3D $(shell id -u $(CI_USER_LOGIN)) +CI_GID =3D $(shell id -g $(CI_USER_LOGIN)) =20 # We also need the user's login and home directory to prepare the # environment the way some programs expect it -CI_USER_LOGIN =3D $(shell echo "$$USER") -CI_USER_HOME =3D $(shell echo "$$HOME") +CI_USER_LOGIN =3D $(shell whoami) +CI_USER_HOME =3D $(shell eval echo "~$(CI_USER_LOGIN)") =20 CI_ENGINE =3D auto # Container engine we are going to use, can be overridden per make @@ -132,6 +132,13 @@ ifeq ($(CI_ENGINE),podman) --gidmap $(CI_GID):0:1 \ --gidmap $(CI_GID_OTHER):$(CI_GID_OTHER):$(CI_GID_OTHER_RANGE) \ $(NULL) + + # In case we want to debug in the container, having root is actually + # preferable, so reset the CI_PODMAN_ARGS and don't actually perform + # any uid/gid mapping + ifeq ($(CI_UID), 0) + CI_PODMAN_ARGS=3D + endif endif =20 # Args to use when cloning a git repo. @@ -238,6 +245,7 @@ ci-help: @echo @echo " CI_CLEAN=3D0 - do not delete '$(CI_SCRATCHDIR)' after= completion" @echo " CI_REUSE=3D1 - re-use existing '$(CI_SCRATCHDIR)' con= tent" + @echo " CI_USER_LOGIN=3D - which user should run in the container= (default is $$USER)" @echo " CI_ENGINE=3Dauto - container engine to use (podman, docke= r)" @echo " CI_MESON_ARGS=3D - extra arguments passed to meson" @echo " CI_NINJA_ARGS=3D - extra arguments passed to ninja" --=20 2.29.2