Allow excluding xattrs at restore time#5129
Conversation
0b9b66c to
82b3562
Compare
MichaelEischer
left a comment
There was a problem hiding this comment.
The changes look good so far. To get this over the finishing line the PR definitely needs a changelog entry and ideally also a short section in the restorer documentation.
ebf2305 to
00212fa
Compare
|
@MichaelEischer Thanks very much for your review - I've had to rebase to get the latest, hopefully I did everything correctly. Latest updates
For the last one is this ok? Let me know if you would prefer to keep the default of restoring all xattrs for Linux as well. |
For: restic#5089 Signed-off-by: Tesshu Flower <tflower@redhat.com>
- also other platforms - move xattr include/exclude filter parsing into separate func Signed-off-by: Tesshu Flower <tflower@redhat.com>
Signed-off-by: Tesshu Flower <tflower@redhat.com>
* On Linux restore only user.* xattrs by default * restore all for other OSs * Update docs and changelog about the new restore flags --exclude-xattr and --include-xattr Signed-off-by: Tesshu Flower <tflower@redhat.com>
Signed-off-by: Tesshu Flower <tflower@redhat.com>
Signed-off-by: Tesshu Flower <tflower@redhat.com>
MichaelEischer
left a comment
There was a problem hiding this comment.
Sorry for the long review delay. I found a few further small nits, but besides that the PR is ready. Although you'll have to rebase one last time 🙈 .
cmd/restic/cmd_restore.go
Outdated
|
|
||
| // no includes or excludes, set default of including all xattrs | ||
| // User has not specified any xattr includes or excludes | ||
| if runtime.GOOS == "linux" { |
There was a problem hiding this comment.
I've thought a bit more about this and by now I think that keeping the old behavior of restoring all xattrs by default makes more sense. Users expect that restic restores POSIX ACLs and per-file capabilities by default. Those are part of the system.* namespace, so they shouldn't be excluded by default. So let's just include all xattrs on all OS by default.
There was a problem hiding this comment.
Thanks, that makes sense to me - I've also updated the docs to indicate all xattrs are restored by default.
There was a problem hiding this comment.
Maybe a default exclude during restore only and backup all since the issue identified 'security.*', 'trusted.*', and 'system.*' as problematic on restore? Seems safer to me. No issue reading the security.* xattr from testing, just a problem on restore.
If the exclude default is on restore than at least it is still in the repo from the backup if needed.
I fully admit to not knowing enough about SELinux works to say with any confidence other than a suggestion to consider for someone more knowledgeable.
Sorry to just come out of nowhere, I recently ran into this same issue on OpenShift with restic.
There was a problem hiding this comment.
Backup always includes all xattrs. This won't change with this PR.
I fully admit to not knowing enough about SELinux works to say with any confidence other than a suggestion to consider for someone more knowledgeable.
I don't know enough about SELinux either to clarify the exact conditions that are necessary to write the selinux xattrs. As such making a backwards incompatible change without proper understanding sounds like the wrong approach to me. If someone can provide clarity here, we can discuss for example whether it would make sense to exclude the SELinux xattr by default. Feel free to open a follow-up issue for that.
Maybe a default exclude during restore only and backup all since the issue identified
'security.*','trusted.*', and'system.*'as problematic on restore?
Most if not all of those xattrs can be restored by root without issues. And I'm rather sure that some of them can even be written be regular users (in particular posix acls).
00212fa to
cd84fe0
Compare
Head branch was pushed to by a user without write access
|
@MichaelEischer sorry I think the failed test is because I added a random xattr (not in one of the supported linux namespaces) into one of the tests at one point and forgot to remove it. I pushed another commit to roll that part back. |
|
The test on Windows still fails.
|
a9f06d1 to
5e8654c
Compare
Thanks for fixing that and getting it merged! 🥳 |
For: #5089
What does this PR change? What problem does it solve?
This introduces new command line flags for restic restore:
--exclude-xattrand--include-xattr. These are mutually exclusive, similar to --exclude and --include.Was the change previously discussed in an issue or on the forum?
Fixes #5089
Checklist
changelog/unreleased/that describes the changes for our users (see template).gofmton the code in all commits.