From nobody Fri Oct 18 06:18:35 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 1716886219596390.2052747029052; Tue, 28 May 2024 01:50:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 772F81B73; Tue, 28 May 2024 04:50:18 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 16DA21B03; Tue, 28 May 2024 04:49:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F23941A6F; Tue, 28 May 2024 04:49:38 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 8586B1A40 for ; Tue, 28 May 2024 04:49:38 -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-350-IYvrRoqoMueXWrdvYDz0-A-1; Tue, 28 May 2024 04:49:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 53791101A52C for ; Tue, 28 May 2024 08:49:36 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3C132870 for ; Tue, 28 May 2024 08:49:35 +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.6 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,T_SCC_BODY_TEXT_LINE 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=1716886178; 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=pPPLkeSNIrl6SZYReyhmP6JKxDfoqOAQVmhPO4+FPPY=; b=N0XBbSp2GJeQm/o6H5BdlJWIv299aHIcNENGgrBjL6RJ+pnNISxb9A+cuvyRlZYxpw3s4w NvyDmxN5UfejUbKjeMrkXGFG77ek1iP3Ud6KZN8VdLeBRk3dsoXpakLQMvB7v6MIglSgT8 aNJPNTRjMT6ebqMp7u5uKOHVOcr0anE= X-MC-Unique: IYvrRoqoMueXWrdvYDz0-A-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH v2] run.in: Detect binaries in builddir properly Date: Tue, 28 May 2024 10:49:34 +0200 Message-ID: <7245522a0cd115f1154246cdf6b9d7aff373063e.1716886077.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5QZUKAUT52DD5OHP75ACD4NUV3JBT5RV X-Message-ID-Hash: 5QZUKAUT52DD5OHP75ACD4NUV3JBT5RV 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: 1716886221051100001 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 Reviewed-by: Jiri Denemark --- v2 of: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/UZ6F= 7MWEJBUMUUBODXGAXQW4NY2UEEVF/ diff to v1: - error out if binary to run can't be identified (i.e. 'which' returns None). run.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run.in b/run.in index 5b89b3dcd5..cada74dfcd 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)) @@ -187,6 +187,10 @@ else: try: dorestorecon =3D False progpath =3D shutil.which(prog) + if not progpath: + raise Exception("Can't find executable {}" + .format(prog)) + progpath =3D os.path.abspath(progpath) if len(try_stop_units): print("Temporarily stopping systemd units...") =20 --=20 2.44.1