Closed devegied-lamabpo closed 1 year ago
That is unfortunate. llistxattr()
and friends return these fake extended attributes.
Can you test this? See also if it does not break things with filesystems supporting xattrs.
You will need to recreate the images.
diff --git a/src/oper_save.c b/src/oper_save.c
index ec540a9..8cdd3f9 100644
--- a/src/oper_save.c
+++ b/src/oper_save.c
@@ -615,9 +615,14 @@ int createar_save_file(csavear *save, char *root, char *relpath, struct stat64 *
}
// ---- backup other file attributes (xattr + winattr)
- if (createar_item_xattr(save, root, relpath, statbuf, dicoattr)!=0)
- { msgprintf(MSG_STACK, "backup_item_xattr() failed: cannot prepare xattr-dico for item %s\n", relpath);
- attrerrors++;
+ // selinux can present fake xattrs
+ // do not try to save them if not supported by the filesystem, otherwise restoration will fail
+ if (filesys[save->fstype].support_for_xattr==true)
+ {
+ if (createar_item_xattr(save, root, relpath, statbuf, dicoattr)!=0)
+ { msgprintf(MSG_STACK, "backup_item_xattr() failed: cannot prepare xattr-dico for item %s\n", relpath);
+ attrerrors++;
+ }
}
if (filesys[save->fstype].winattr==true)
(updated patch)
I compiled fsarchiver-0.8.6 from source with patch applied. I made Oracle Linux 7.9 /boot (xfs) and /boot/efi (fat) filesystems backup with patched fsarchiver. I restored new archive with unpatched fsarchiver (0.8.6). There was no error messages and restore command finished with exit code 0. Files in /boot (xfs) filesystem were restored with correct extended attributes (at least I can see the same SELinux attributes after I boot restored system). I think functionality of this patch should be a part of next fsarchiver release.
@fdupoux What do you think?
@marcosfrm Yes I think this is the right thing to do. Can you please raise a pull request ?
SELinux can add file labeling to files even for filesystems that does not support any extended attributes (File System Labeling Statements). FSArchiver saves this labeling information in archive (as provided by OS). When archive is restored FSArchiver tries to apply these saved extended attributes to files and directories but fails because underlying file system does not support extended attributes. For example, in /dev/sda1 is EFI system partition (formatted as FAT16) and I am archiving live system (with active SELinux)
When restoring this archive in SystemRescue environment I get these errors
exit code from
fsarchiver
is 1 and there is no way to use it in automated restore because any error gives such exit code. FSArchiver already have optionthat allows not to save attributes when filesystem mounted without options that exposes these attributes.
It would be nice to have option to do not restore attributes if underlying filesystem does not support them. Or the option to ignore and do not report attribute restoration errors (at line 214 in oper_restore.c)