Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extended attributes on symlinks #4379

Merged
merged 6 commits into from
Jul 8, 2023
Merged

Add support for extended attributes on symlinks #4379

merged 6 commits into from
Jul 8, 2023

Conversation

chenxiaolong
Copy link
Contributor

What does this PR change? What problem does it solve?

Linux allows the use of non-user. extended attributes on symlinks. One of the main users of this functionality is SELinux's security.selinux xattr for storing a path's label. By storing symlink xattrs, restic is now suitable for backing up the root filesystem on Linux distributions that use SELinux.

This commit adds support for symlink xattrs when backing up data, restoring data, and mounting snapshots via a fuse mount. All calls to the xattr library have been updated to the use L variants of the various functions, which always operate on the path given, without following symlinks.

Was the change previously discussed in an issue or on the forum?

Fixes: #4375

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

Linux allows the use of non-`user.` extended attributes on symlinks. One
of the main users of this functionality is SELinux's `security.selinux`
xattr for storing a path's label. By storing symlink xattrs, restic is
now suitable for backing up the root filesystem on Linux distributions
that use SELinux.

This commit adds support for symlink xattrs when backing up data,
restoring data, and mounting snapshots via a fuse mount. All calls to
the xattr library have been updated to the use `L` variants of the
various functions, which always operate on the path given, without
following symlinks.

Fixes: #4375

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@greatroar
Copy link
Contributor

LGTM. Looks like we previously backed up the wrong xattrs for symlinks (the ones for the target file).

Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I've added amount of test coverage for extended attributes. The tests in restic/node only use files/dirs+xattrs as we can't write arbitrary xattrs for symlinks. Thus the tests somewhat miss the point, but should be close enough to ensure that this works.

Regarding other operating systems except for Windows, Linux and macOS we'll just have to wait and see whether this change causes problems.

@MichaelEischer MichaelEischer added this pull request to the merge queue Jul 8, 2023
Merged via the queue into restic:master with commit 4d43509 Jul 8, 2023
10 of 11 checks passed
@chenxiaolong chenxiaolong deleted the symlink_xattrs branch July 8, 2023 17:30
@chenxiaolong
Copy link
Contributor Author

Thank you!

@MichaelEischer MichaelEischer mentioned this pull request Jul 8, 2023
8 tasks
@MichaelEischer
Copy link
Member

Looks like I've been to quick in merging the PR, #4401 fixes the windows build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Linux] xattrs, like security.selinux, are not backed up for symlinks
3 participants