From nobody Fri Nov 22 04:58:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1716391967846922.065921741773; Wed, 22 May 2024 08:32:47 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9274F1A19; Wed, 22 May 2024 11:32:46 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3BEE519EC; Wed, 22 May 2024 11:32:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 00E821927; Wed, 22 May 2024 11:32:07 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 86D6219BB for ; Wed, 22 May 2024 11:32:07 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-FzNuMK9-NWW2aY8gIKiBHA-1; Wed, 22 May 2024 11:32:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E267B185A780 for ; Wed, 22 May 2024 15:31:55 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DC8640C6EB7 for ; Wed, 22 May 2024 15:31:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716391927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Wd1mWIMQ9tj7H+Fhgc1fSZqJiZckXORrXjZZxQ5U1rk=; b=TbzjkPKECXe0LMUAaxyWGHzhrV0DN9Az4DXCvHv+WOXccK7ZjXQUDOa5KsBbFKlUkWKcrU ZwjREyYrT8i9hjjKgUCpAtmj9G3TR6mzzGq4XdCkx0xBhFpu458ZnkSniRgEPLgzmXhs2x PDx0PZVztA3YTbNBj/d0NG8rid5cka0= X-MC-Unique: FzNuMK9-NWW2aY8gIKiBHA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] run.in: Detect binaries in builddir properly Date: Wed, 22 May 2024 17:31:54 +0200 Message-ID: <20970257bf6feaa25bd3e74411ab3fe69a4aaa9d.1716391914.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UZ6F7MWEJBUMUUBODXGAXQW4NY2UEEVF X-Message-ID-Hash: UZ6F7MWEJBUMUUBODXGAXQW4NY2UEEVF X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1716391968437100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When attempting to run: libvirt.git/_build # ./run --selinux ./src/libvirtd the following error is thrown: Refusing to change selinux context of file './src/libvirtd' outside build= directory which is obviously wrong. The problem is 'being inside of build directory' is detected by simple progpath.startswith(builddir). While builddir is an absolute path, progpath isn't necessarily. And while looking into the code, I've noticed chcon() function accessing variable outside its scope when printing out the path it's working on. Signed-off-by: Michal Privoznik --- run.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.in b/run.in index 5b89b3dcd5..87cf39a920 100644 --- a/run.in +++ b/run.in @@ -138,7 +138,7 @@ def change_unit(name, action): =20 =20 def chcon(path, user, role, type): - print("Setting file context of {} to u=3D{}, r=3D{}, t=3D{}...".format= (progpath, + print("Setting file context of {} to u=3D{}, r=3D{}, t=3D{}...".format= (path, user, role, type)) @@ -186,7 +186,7 @@ else: =20 try: dorestorecon =3D False - progpath =3D shutil.which(prog) + progpath =3D os.path.abspath(shutil.which(prog) or prog) if len(try_stop_units): print("Temporarily stopping systemd units...") =20 --=20 2.44.1