From nobody Sat Feb 7 18:51:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1606905875; cv=none; d=zohomail.com; s=zohoarc; b=AJJwJdkTxXIw/U/DBo/xaXHAFJXMN5XDnFuqrtbpdfSv9CawyjMopPFktmtDDpKzmkSDaqsN1Q19ukAZ1nXnJ/L70xzKW6gQv1oz0/nq5MX9T/MkiJq8t7sCVlmf5iWFe7KrNqSkl2NdHfikI4B9BWuPf8ywElUFtyHSvfss684= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606905875; h=Content-Type:Content-Transfer-Encoding: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=GktLiSgL3H8zTgmHXuKlMiKFnspKNMTVDVsdh+CqPqA=; b=ZaPWALWLensQ8uYtVVwV9Zfual7zAiHRtfL4xyDYCkXnSNLrrqeziFaeqrPdiadtcAnsCPAiJ9YoQaSyRv2qM4BRwb3FjYOsY33MVuxgXIyqEl0YyQgI4+V8nfj/yeFyCm1tVoUP9luJDcfpRAlAqIGFpC3D7L0kAGBKpyLptx8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606905875291633.5589463117858; Wed, 2 Dec 2020 02:44:35 -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-319-u_1ID79wPTu8XA-boWaHLw-1; Wed, 02 Dec 2020 05:44:32 -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 D54611005E5B; Wed, 2 Dec 2020 10:44:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B17F65C1B4; Wed, 2 Dec 2020 10:44:25 +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 730BA5002D; Wed, 2 Dec 2020 10:44:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2AhHBC013774 for ; Wed, 2 Dec 2020 05:43:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 79A0F19D9F; Wed, 2 Dec 2020 10:43:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id D28C319C48 for ; Wed, 2 Dec 2020 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606905874; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GktLiSgL3H8zTgmHXuKlMiKFnspKNMTVDVsdh+CqPqA=; b=SjuYCIJP2nKy/yf99ox2gKuhU+LEH4T66pkuoLNZlmk7ItDGr+AHHdcFNG5VV2lXUyjZ4y SxInkEB3lr+52E21SqMCpLGE2kQPPhVX8y6Au83lW2qh4LOMXnsDVoUAT6oYpMoF0Uq0ab I5jlsRupqEIdN12AfwN49++ce/v4GRM= X-MC-Unique: u_1ID79wPTu8XA-boWaHLw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] libvirt_recover_xattrs: Avoid backticks for subshell Date: Wed, 2 Dec 2020 11:43:08 +0100 Message-Id: <990d074bae08cb979a0fa0956390df151059c96a.1606905624.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.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" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/libvirt_recover_xattrs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs= .sh index 3907413c63..cb98497732 100755 --- a/tools/libvirt_recover_xattrs.sh +++ b/tools/libvirt_recover_xattrs.sh @@ -34,7 +34,7 @@ URI=3D("qemu:///system" LIBVIRT_XATTR_PREFIXES=3D("trusted.libvirt.security" "system.libvirt.security") -if [ `whoami` !=3D "root" ]; then +if [ $(whoami) !=3D "root" ]; then die "Must be run as root" fi --=20 2.28.0 From nobody Sat Feb 7 18:51:48 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=1606905871; cv=none; d=zohomail.com; s=zohoarc; b=QYN/k1GhUu3Fah0Cy+5nIHrho5YPtJwMcezWYANz9MQEkeYkG/bMYt6dlaDAcBKEXbugfWdpewmEsGM9kxnoCir2NxOFbE64+6J/aydCJbnUDg3hcdxUdvgak90I+CJFIXqxsE5G2pnv1oWSkbo9I/HeM7IOM8igc+JLSNEgqxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606905871; h=Content-Type:Content-Transfer-Encoding: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=k54M/nfAn+QDNYVYTGZFCpT1YPpb8TyV9XDJXYU6Snk=; b=Zeb0CQ0VpqtKwzZfUubNNOO6BA2uXNZ44pKjZvozZGbSDqs4/PTQo+UH7LtDvcYpWo0xYOfiqz24rLWLIXO4pbB5iXRwXKDKA+/TbwnL8vKT8RdDG2cAmBzDon4DUfOOd1gMeWJgKtJzxQFgfkZwDiYpoNlLxAF6eBist2ra1XY= 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 1606905871107960.7823162302504; Wed, 2 Dec 2020 02:44:31 -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-228-fiYD8lNIM7ylamOPJJvXrA-1; Wed, 02 Dec 2020 05:44:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85D4D8049C0; Wed, 2 Dec 2020 10:44:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56B8C10023AE; Wed, 2 Dec 2020 10:44:21 +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 DB8894EA6C; Wed, 2 Dec 2020 10:44:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2AhI2B013784 for ; Wed, 2 Dec 2020 05:43:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8C1AF19D9F; Wed, 2 Dec 2020 10:43:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDFEA19C48 for ; Wed, 2 Dec 2020 10:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606905870; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=k54M/nfAn+QDNYVYTGZFCpT1YPpb8TyV9XDJXYU6Snk=; b=B8KHhu59zASPhJpyW8LBMlCtbMJINu4E/T0BKjh1jd1lfYTQ1ecGx6CnJ40dP19NYeLeSF tTvOYZQCj9iNcdlNYHoOemAA6xLBf4cWZJZMasfWLEFk37AI0x7h2+9cq7eXnDi3/RT7QK A9i7K3iCFk51TDvgIat5jTEFgWPcs0g= X-MC-Unique: fiYD8lNIM7ylamOPJJvXrA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] libvirt_recover_xattrs: Use only the correct xattr prefix Date: Wed, 2 Dec 2020 11:43:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.84 on 10.5.11.22 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" Linux and FreeBSD have different prefix. In the current state we've tried to reset the labels for both systems which resulted in errors like this: Fixing /tmp/bitmaps2.qcow2 setfattr: /tmp/bitmaps2.qcow2: Operation not supported setfattr: /tmp/bitmaps2.qcow2: Operation not supported setfattr: /tmp/bitmaps2.qcow2: Operation not supported setfattr: /tmp/bitmaps2.qcow2: Operation not supported setfattr: /tmp/bitmaps2.qcow2: Operation not supported setfattr: /tmp/bitmaps2.qcow2: Operation not supported The 6 failed 'setfattrs' correspond to the wrong prefix. Select the correct prefix based on the kernel name and modify the code appropriately. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/libvirt_recover_xattrs.sh | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs= .sh index cb98497732..b7a8c05cf4 100755 --- a/tools/libvirt_recover_xattrs.sh +++ b/tools/libvirt_recover_xattrs.sh @@ -29,11 +29,6 @@ DIR=3D"/" URI=3D("qemu:///system" "lxc:///system") -# On Linux we use 'trusted' namespace, on FreeBSD we use 'system' -# as there is no 'trusted'. -LIBVIRT_XATTR_PREFIXES=3D("trusted.libvirt.security" - "system.libvirt.security") - if [ $(whoami) !=3D "root" ]; then die "Must be run as root" fi @@ -62,6 +57,21 @@ if [ $# -gt 0 ]; then DIR=3D$1 fi +case $(uname -s) in + Linux) + XATTR_PREFIX=3D"trusted.libvirt.security" + ;; + + FreeBSD) + XATTR_PREFIX=3D"system.libvirt.security" + ;; + + *) + die "$0 is not supported on this platform" + ;; +esac + + if [ ${DRY_RUN} -eq 0 ]; then for u in ${URI[*]} ; do if [ -n "`virsh -q -c $u list 2>/dev/null`" ]; then @@ -73,24 +83,20 @@ fi declare -a XATTRS for i in "dac" "selinux"; do - for p in ${LIBVIRT_XATTR_PREFIXES[@]}; do - XATTRS+=3D("$p.$i" "$p.ref_$i" "$p.timestamp_$i") - done + XATTRS+=3D("$XATTR_PREFIX.$i" "$XATTR_PREFIX.ref_$i" "$XATTR_PREFIX.ti= mestamp_$i") done -for p in ${LIBVIRT_XATTR_PREFIXES[*]}; do - for i in $(getfattr -R -d -m ${p} --absolute-names ${DIR} 2>/dev/null = | grep "^# file:" | cut -d':' -f 2); do - echo $i; - if [ ${DRY_RUN} -ne 0 ]; then - getfattr -d -m $p --absolute-names $i | grep -v "^# file:" - continue - fi - if [ ${QUIET} -eq 0 ]; then - echo "Fixing $i"; - fi - for x in ${XATTRS[*]}; do - setfattr -x $x $i - done +for i in $(getfattr -R -d -m ${XATTR_PREFIX} --absolute-names ${DIR} 2>/de= v/null | grep "^# file:" | cut -d':' -f 2); do + if [ ${DRY_RUN} -ne 0 ]; then + getfattr -d -m $p --absolute-names $i | grep -v "^# file:" + continue + fi + + if [ ${QUIET} -eq 0 ]; then + echo "Fixing $i"; + fi + for x in ${XATTRS[*]}; do + setfattr -x $x $i done done --=20 2.28.0 From nobody Sat Feb 7 18:51:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1606905907; cv=none; d=zohomail.com; s=zohoarc; b=kgpGpo7Fo+HYzAwrhvTt9N3FNolxdJsHQm9zqRIdOjhbKvwKYgzVEuQ1XiTGRADHLhtt1srUDGVyJsSogIWbIkKlfYY0+rKstXsuATrY6RqaUs8/Hvz3iaF0dvD1UAuXv8mAoBetvB88Y15VZ+9X5DKIoUFOuQ0lhOQ1mxyAv6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606905907; h=Content-Type:Content-Transfer-Encoding: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=fpwlHg5MWTKkYS0G6ju4GwrPW52Pb99geecG0muYaf4=; b=Qv7Yk3RTsFhxRmGNlJiMHa0UjIw0yQWE82ECu6hA8Lafg53RG5DIBlatlHYlAdvzsjtXZwQV/gnl1V1HcjVAZ/7TpzGeT1hp5a9J/E8Bzn4vDbIq3+XDrPOqaQKRNb0+QjMcaJTQLZYBR6Ck1hgkqLTRCb2ODqQ1ex3AbAWK6Gs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606905907455849.819546066248; Wed, 2 Dec 2020 02:45:07 -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-1-V7nucaxCOqKRmJVy02fE5A-1; Wed, 02 Dec 2020 05:44:37 -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 01C75803F4C; Wed, 2 Dec 2020 10:44:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2DD35D9CA; Wed, 2 Dec 2020 10:44:30 +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 9DECC5002F; Wed, 2 Dec 2020 10:44:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2AhJCU013795 for ; Wed, 2 Dec 2020 05:43:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9998B19D9F; Wed, 2 Dec 2020 10:43:19 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0335619C48 for ; Wed, 2 Dec 2020 10:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606905906; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fpwlHg5MWTKkYS0G6ju4GwrPW52Pb99geecG0muYaf4=; b=dOK/XGjmB8abVkiX6OTt2Xn6m7FPRIUIiMuWDRyxvfm1kksH687NWkCLexQ9wWhMEK8eBw GBV0VRjTey+JROBjbXWRdpsWqO6j0T+IM+FaOy2n7Gy7TtbObZb2yESJynS/UgRlJt6sKB 9lC+9mRKcAvKQQP5yzA21Vc21TwrjmI= X-MC-Unique: V7nucaxCOqKRmJVy02fE5A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] libvirt_recover_xattrs: Add unsafe operation mode Date: Wed, 2 Dec 2020 11:43:10 +0100 Message-Id: <8928f82ce46845a87fc0d2165d9f611a0a1663a3.1606905624.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.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" In some cases you want to fix a certain directory while you don't really care whether there are other VMs running. Add a option to disable the check. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/libvirt_recover_xattrs.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs= .sh index b7a8c05cf4..bb5f23cff0 100755 --- a/tools/libvirt_recover_xattrs.sh +++ b/tools/libvirt_recover_xattrs.sh @@ -7,7 +7,7 @@ function die { function show_help { cat << EOF -Usage: ${0##*/} -[hqn] [PATH] +Usage: ${0##*/} -[hqnu] [PATH] Clear out any XATTRs set by libvirt on all files that have them. The idea is to reset refcounting, should it break. @@ -15,6 +15,7 @@ The idea is to reset refcounting, should it break. -h display this help and exit -q quiet (don't print which files are being fixed) -n dry run; don't remove any XATTR just report the file name + -u unsafe; don't check whether there are running VMs; PATH must be sp= ecified PATH can be specified to refine search to only to given path instead of whole root ('/'), which is the default. @@ -23,6 +24,7 @@ EOF QUIET=3D0 DRY_RUN=3D0 +UNSAFE=3D0 DIR=3D"/" # So far only qemu and lxc drivers use security driver. @@ -33,7 +35,7 @@ if [ $(whoami) !=3D "root" ]; then die "Must be run as root" fi -while getopts hqn opt; do +while getopts hqnu opt; do case $opt in h) show_help @@ -45,6 +47,9 @@ while getopts hqn opt; do n) DRY_RUN=3D1 ;; + u) + UNSAFE=3D1 + ;; *) show_help >&2 exit 1 @@ -55,6 +60,10 @@ done shift $((OPTIND - 1)) if [ $# -gt 0 ]; then DIR=3D$1 +else + if [ ${UNSAFE} -eq 1 ]; then + die "Unsafe mode (-u) requires explicit 'PATH' argument" + fi fi case $(uname -s) in @@ -72,7 +81,7 @@ case $(uname -s) in esac -if [ ${DRY_RUN} -eq 0 ]; then +if [ ${DRY_RUN} -eq 0 ] && [ ${UNSAFE} -eq 0 ]; then for u in ${URI[*]} ; do if [ -n "`virsh -q -c $u list 2>/dev/null`" ]; then die "There are still some domains running for $u" --=20 2.28.0 From nobody Sat Feb 7 18:51:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1606906076; cv=none; d=zohomail.com; s=zohoarc; b=BvlZqPKool8bfZTqH6CDuRoUMYadh7hgeQIiYy8ETGHBhtDVWBJ92YsxwOxEzT42WP/gJqUGDHWmZXS2dKMpBqBO1TKk8hMBvsPDaRAfCU3tiNAS/c6NyThVHhMrkEb5o8LCXd07dU9MTt+/P5kvjC72cyjZsHDh9y2gglQYaPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606906076; h=Content-Type:Content-Transfer-Encoding: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=J8Uk9K7Pv+NXIsNY6f5UFAOgjqzn0Un7X7C2+Pz6kp4=; b=Y0qgpo1Oqkqx9p0swyWLhCO2Z8CgCblRGkTvd9HMpiRXXCGe3c+UXFLoZkzqrpaDSY/HHoaRONTcHmhUggmhiEGMMxkV6VHCIMQzJgIn7S4U4ME9DC1a2PKXAEejQ7frnrZ69kFNVjHg6inKg6h1Hz8zU/dRuQ6aYMCh11tpjek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 160690607678576.9964917057033; Wed, 2 Dec 2020 02:47:56 -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-583-SGb3LWRGP-mw8-1Gl4kk-Q-1; Wed, 02 Dec 2020 05:47:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9AB3A1007B05; Wed, 2 Dec 2020 10:47:46 +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 746715D6AC; Wed, 2 Dec 2020 10:47:46 +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 072F2180954D; Wed, 2 Dec 2020 10:47:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2AhKGP013810 for ; Wed, 2 Dec 2020 05:43:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id A5C8119D9F; Wed, 2 Dec 2020 10:43:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05D8919C48 for ; Wed, 2 Dec 2020 10:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606906075; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=J8Uk9K7Pv+NXIsNY6f5UFAOgjqzn0Un7X7C2+Pz6kp4=; b=hMrj6IBW673z7184y26FXXudx15c9yH5rLSGbm+gnR1RNXtWMR2YJ9QfGYuigS9HCg3yY+ tfDCtGWwFpmrgwRUiu+KhN4IKcwrJT59eZPEzLNbe/qDd0qmwg3VSqTWBXJoO9V6MwhEe/ q/7hvd6cHNl/WyI9464FXEqLMCl0JIo= X-MC-Unique: SGb3LWRGP-mw8-1Gl4kk-Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] libvirt_recover_xattrs: Allow fixing multiple PATHs Date: Wed, 2 Dec 2020 11:43:11 +0100 Message-Id: <61d9e7c1fa3321586d97d1171659df4c10b64a5d.1606905624.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.15 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" Loop for multiple PATH arguments to support shell pattern expansion. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tools/libvirt_recover_xattrs.sh | 51 +++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/tools/libvirt_recover_xattrs.sh b/tools/libvirt_recover_xattrs= .sh index bb5f23cff0..59f1f3f476 100755 --- a/tools/libvirt_recover_xattrs.sh +++ b/tools/libvirt_recover_xattrs.sh @@ -7,7 +7,7 @@ function die { function show_help { cat << EOF -Usage: ${0##*/} -[hqnu] [PATH] +Usage: ${0##*/} -[hqnu] [PATH ...] Clear out any XATTRs set by libvirt on all files that have them. The idea is to reset refcounting, should it break. @@ -25,7 +25,6 @@ EOF QUIET=3D0 DRY_RUN=3D0 UNSAFE=3D0 -DIR=3D"/" # So far only qemu and lxc drivers use security driver. URI=3D("qemu:///system" @@ -57,15 +56,6 @@ while getopts hqnu opt; do esac done -shift $((OPTIND - 1)) -if [ $# -gt 0 ]; then - DIR=3D$1 -else - if [ ${UNSAFE} -eq 1 ]; then - die "Unsafe mode (-u) requires explicit 'PATH' argument" - fi -fi - case $(uname -s) in Linux) XATTR_PREFIX=3D"trusted.libvirt.security" @@ -95,17 +85,34 @@ for i in "dac" "selinux"; do XATTRS+=3D("$XATTR_PREFIX.$i" "$XATTR_PREFIX.ref_$i" "$XATTR_PREFIX.ti= mestamp_$i") done +fix_xattrs() { + local DIR=3D"$1" -for i in $(getfattr -R -d -m ${XATTR_PREFIX} --absolute-names ${DIR} 2>/de= v/null | grep "^# file:" | cut -d':' -f 2); do - if [ ${DRY_RUN} -ne 0 ]; then - getfattr -d -m $p --absolute-names $i | grep -v "^# file:" - continue - fi + for i in $(getfattr -R -d -m ${XATTR_PREFIX} --absolute-names ${DIR} 2= >/dev/null | grep "^# file:" | cut -d':' -f 2); do + if [ ${DRY_RUN} -ne 0 ]; then + getfattr -d -m $p --absolute-names $i | grep -v "^# file:" + continue + fi - if [ ${QUIET} -eq 0 ]; then - echo "Fixing $i"; - fi - for x in ${XATTRS[*]}; do - setfattr -x $x $i + if [ ${QUIET} -eq 0 ]; then + echo "Fixing $i"; + fi + for x in ${XATTRS[*]}; do + setfattr -x $x $i + done done -done +} + + +shift $((OPTIND - 1)) +if [ $# -gt 0 ]; then + while [ $# -gt 0 ]; do + fix_xattrs "$1" + shift $((OPTIND - 1)) + done +else + if [ ${UNSAFE} -eq 1 ]; then + die "Unsafe mode (-u) requires explicit 'PATH' argument" + fi + fix_xattrs "/" +fi --=20 2.28.0