From nobody Mon Feb 9 01:22:04 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=1613139633; cv=none; d=zohomail.com; s=zohoarc; b=cAOX7CBgDzvjmHCZjqxqR31rFJu8cndHKTglXOJvpZnlIsbyl6bpsj6sRoC+21TatdqfvdnUCo4QssvOMuzUJu1u9hd+yDY4GCjZ+9ATMOazimSd8JG/kQoGWDOYileVzXiU6tBZMpS5OgP6feFH+ntbD6I+whNVOUqNvpsK/iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613139633; 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=2eFDFDvjWbmkxGcHgOwIDV6Bm92tLN6ty1rhOlIGUSI=; b=QTniTwlfcqoemjyOqDfpB3Uq00oi8G1gPwYvCCrsk+UDLdONvnmEB06vkRQ38Nc4ZVqq0bRPr/bKfkMrXw9xCL6gLdJOftvAVeBsZw5JfnbuZyVHfyDPNpP4bHNbAozU1Opx9oU+och7ECwoRaPNo/9ntIy8OdXEHfgzDoIzMvM= 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 1613139633576904.913783279974; Fri, 12 Feb 2021 06:20:33 -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-200-OG5WmRCaN3iZRIler09Q0g-1; Fri, 12 Feb 2021 09:20:30 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFB432FD17; Fri, 12 Feb 2021 14:20:07 +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 E800F6D0A7; Fri, 12 Feb 2021 14:20:06 +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 9B07C18095C9; Fri, 12 Feb 2021 14:20:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CEJu2Z015680 for ; Fri, 12 Feb 2021 09:19:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 651CD669F3; Fri, 12 Feb 2021 14:19:56 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1FDE62A24; Fri, 12 Feb 2021 14:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613139632; 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=2eFDFDvjWbmkxGcHgOwIDV6Bm92tLN6ty1rhOlIGUSI=; b=gHT56XeM1eZ6FGypfWqTts+64qy/sdcuFf+iPmkibozUByAbC2SVHwiyjAYGj5FVrFf+6p cRmhiILnxAYQJF5cFglTkN738RRGtF03XkqoSUk+GhYGoU0d8QbTyrs/tYysJWFWcEZYrN bU0kHe+K6UBTGnQavldgma+1plFJ3dU= X-MC-Unique: OG5WmRCaN3iZRIler09Q0g-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/4] ci: Makefile: Expose the CI_USER_LOGIN variable for users to use Date: Fri, 12 Feb 2021 15:19:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.14 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 in 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 Reviewed-by: Andrea Bolognani --- ci/Makefile | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/ci/Makefile b/ci/Makefile index 9308738d2d..05a50c021c 100644 --- a/ci/Makefile +++ b/ci/Makefile @@ -45,15 +45,15 @@ CI_CLEAN =3D 1 # preserved env 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) - -# We also need the user's login and home directory to prepare the +# We 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)") + +# We also 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_USER_LOGIN)") +CI_GID =3D $(shell id -g "$(CI_USER_LOGIN)") =20 CI_ENGINE =3D auto # Container engine we are going to use, can be overridden per make @@ -124,14 +124,16 @@ ifeq ($(CI_ENGINE),podman) CI_UID_OTHER_RANGE =3D $(shell echo $$(($(CI_MAX_UID)-$(CI_UID)))) CI_GID_OTHER_RANGE =3D $(shell echo $$(($(CI_MAX_GID)-$(CI_GID)))) =20 - CI_PODMAN_ARGS =3D \ - --uidmap 0:1:$(CI_UID) \ - --uidmap $(CI_UID):0:1 \ - --uidmap $(CI_UID_OTHER):$(CI_UID_OTHER):$(CI_UID_OTHER_RANGE) \ - --gidmap 0:1:$(CI_GID) \ - --gidmap $(CI_GID):0:1 \ - --gidmap $(CI_GID_OTHER):$(CI_GID_OTHER):$(CI_GID_OTHER_RANGE) \ - $(NULL) + ifneq ($(CI_UID), 0) + CI_PODMAN_ARGS =3D \ + --uidmap 0:1:$(CI_UID) \ + --uidmap $(CI_UID):0:1 \ + --uidmap $(CI_UID_OTHER):$(CI_UID_OTHER):$(CI_UID_OTHER_RANGE) \ + --gidmap 0:1:$(CI_GID) \ + --gidmap $(CI_GID):0:1 \ + --gidmap $(CI_GID_OTHER):$(CI_GID_OTHER):$(CI_GID_OTHER_RANGE) \ + $(NULL) + endif endif =20 # Args to use when cloning a git repo. @@ -239,6 +241,7 @@ ci-help: @echo " CI_CLEAN=3D0 - do not delete '$(CI_SCRATCHDIR)' after= completion" @echo " CI_REUSE=3D1 - re-use existing '$(CI_SCRATCHDIR)' con= tent" @echo " CI_ENGINE=3Dauto - container engine to use (podman, docke= r)" + @echo " CI_USER_LOGIN=3D$$USER - which user should run in the con= tainer" @echo " CI_MESON_ARGS=3D - extra arguments passed to meson" @echo " CI_NINJA_ARGS=3D - extra arguments passed to ninja" @echo --=20 2.29.2