From nobody Sun Apr 28 23:00:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1594124105; cv=none; d=zohomail.com; s=zohoarc; b=NYgvpThK8N6ooXa7uwVa1hN6Uc2Bl7Rl6DTuEOVqWsfiy1AnSk9GT6rGldez1XEjbgfTdbMR65mEWHezQeJNs4aYC+Ge7AFGNH5dgYo0anDjb6hG2y490ssIpGwMuNlT6073xtd8C/7g1RwQSu1QFIwyXv3LYN0c9v2HDVhm2do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594124105; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=SkKbrdNBOgr/WH4zDZqbu6ri7oJZQLXYtznnYfZ3pXM=; b=KwXlTOoGFFLnXKU/jZ5KsXDDl+e3kqUyLVyMl0COdpEpEMs++cNPcCx2iKVkyysRM7epJcViwd/HbO77st5N7aFKQgrNHDaAmo0LTklisnTn69jVOiVi2FeSHLPCHXCtKf0jakiA3Z5bhUhShkRYFGoJKG+VSWFajwRjhcnoMxc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1594124105916349.55122436308443; Tue, 7 Jul 2020 05:15:05 -0700 (PDT) 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-277-V3uMQ1E0ODOxnLC3JPWlhw-1; Tue, 07 Jul 2020 08:15:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A2401902EA7; Tue, 7 Jul 2020 12:14:56 +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 E89F560C87; Tue, 7 Jul 2020 12:14:55 +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 65C2F1809547; Tue, 7 Jul 2020 12:14:53 +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 067CEqGh013064 for ; Tue, 7 Jul 2020 08:14:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D200C006E; Tue, 7 Jul 2020 12:14:52 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id C095CC006D for ; Tue, 7 Jul 2020 12:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594124104; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SkKbrdNBOgr/WH4zDZqbu6ri7oJZQLXYtznnYfZ3pXM=; b=BvWYNbjkYbPEcopx29B5cqnnt8ssN7KySDd5j7YGNo6Ed/0m6X6InKWEgmFZ/1/2lgdPe/ Fxw9Ok+J6ukBxW882pSSF8iH2yvp79KU9v4CgaR1a3JJRrWSOl6+/2B13c5jyY5CORu5gU Qa+dveziCqL+5bbZW8R8A9HMGWs1RRk= X-MC-Unique: V3uMQ1E0ODOxnLC3JPWlhw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] util: fix accessibility check for hook directory Date: Tue, 7 Jul 2020 14:14:46 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) virFileIsAccessible does not return true on accessible directories. Check whether it set EISDIR and only then assume the directory is inaccessible. Return 0 (not found) instead of 1 (found), since the bridge driver taints the network based on this return value, not whether the hook actually ran. Remove the bogus check from virHookCall, since it already checks the virHooksFound bitmap that was filled before by virHookCheck. Signed-off-by: J=C3=A1n Tomko Fixes: 7fa7f7eeb6e969e002845928e155914da2fc8cd0 Closes: https://gitlab.com/libvirt/libvirt/-/issues/47 Reviewed-by: Daniel Henrique Barboza --- src/util/virhook.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/virhook.c b/src/util/virhook.c index d1ac518c24..119ad1aae6 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -172,9 +172,9 @@ virHookCheck(int no, const char *driver) =20 dir_path =3D g_strdup_printf("%s.d", path); =20 - if (!virFileIsExecutable(dir_path)) { + if (!virFileIsExecutable(dir_path) && errno !=3D EISDIR) { VIR_DEBUG("Hook dir %s is not accessible", dir_path); - return 1; + return 0; } =20 if ((ret =3D virDirOpenIfExists(&dir, dir_path)) < 0) @@ -422,9 +422,6 @@ virHookCall(int driver, =20 dir_path =3D g_strdup_printf("%s.d", path); =20 - if (!virFileIsExecutable(dir_path)) - return script_ret; - if ((ret =3D virDirOpenIfExists(&dir, dir_path)) < 0) return -1; =20 --=20 2.25.4