[PATCH] tools: Fix dry run of libvirt_recover_xattrs.sh

Michal Privoznik posted 1 patch 3 years ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5bd9e35b9b7882b010882d93b8dee33fd3a4c44f.1614617601.git.mprivozn@redhat.com
tools/libvirt_recover_xattrs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools: Fix dry run of libvirt_recover_xattrs.sh
Posted by Michal Privoznik 3 years ago
The libvirt_recover_xattrs.sh script can be used to remove stale
XATTRs that were left behind by secdrivers (which should happen
only if there' an imbalance between set and restore calls).
Anyway, the script has '-n' switch which is supposed to perform
just a dry run, i.e. just to report which files have XATTRs set
without any attempt to remove them.

But, when rewriting the script a few months ago a typo was
introduced which made the script report no files even if there
were files with XATTRs.

Fixes: 5377177f80da40ee7d47601400b50835f093715a
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 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 59f1f3f476..be6ee84b5f 100755
--- a/tools/libvirt_recover_xattrs.sh
+++ b/tools/libvirt_recover_xattrs.sh
@@ -90,7 +90,7 @@ fix_xattrs() {
 
     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:"
+            getfattr -d -m ${XATTR_PREFIX} --absolute-names $i
             continue
         fi
 
-- 
2.26.2

Re: [PATCH] tools: Fix dry run of libvirt_recover_xattrs.sh
Posted by Ján Tomko 3 years ago
On a Monday in 2021, Michal Privoznik wrote:
>The libvirt_recover_xattrs.sh script can be used to remove stale
>XATTRs that were left behind by secdrivers (which should happen
>only if there' an imbalance between set and restore calls).

*there's

>Anyway, the script has '-n' switch which is supposed to perform
>just a dry run, i.e. just to report which files have XATTRs set
>without any attempt to remove them.
>
>But, when rewriting the script a few months ago a typo was
>introduced which made the script report no files even if there
>were files with XATTRs.
>
>Fixes: 5377177f80da40ee7d47601400b50835f093715a
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> tools/libvirt_recover_xattrs.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano