filesystem = Filesystem::create(*config_info, root_prefix);
- syncSelinuxContexts();
+ // With btrfs backend, it's useless try syncing snapshot RO subvolumes
+ syncSelinuxContexts(filesystem->fstype() == "btrfs");
bool sync_acl;
if (config_info->getValue(KEY_SYNC_ACL, sync_acl) && sync_acl == true)
void
- Snapper::syncSelinuxContexts() const
+ Snapper::syncSelinuxContexts(bool skip_snapshot_dir) const
{
#ifdef ENABLE_SELINUX
try
if (infos_dir.restorecon(selabel_handle))
{
- syncSelinuxContextsInInfosDir();
+ syncSelinuxContextsInInfosDir(skip_snapshot_dir);
}
else
{
SnapperContexts scons;
if (infos_dir.fsetfilecon(scons.subvolume_context()))
- syncSelinuxContextsInInfosDir();
+ syncSelinuxContextsInInfosDir(skip_snapshot_dir);
}
}
catch (const SelinuxException& e)
void
- Snapper::syncSelinuxContextsInInfosDir() const
+ Snapper::syncSelinuxContextsInInfosDir(bool skip_snapshot_dir) const
{
#ifdef ENABLE_SELINUX
Regex rx("^[0-9]+$");
SFile info(info_dir, "info.xml");
info.restorecon(selabel_handle);
- SFile snapshot_dir(info_dir, "snapshot");
- snapshot_dir.restorecon(selabel_handle); // this usually fails w/ btrfs backend (it's RO)
+ if (!skip_snapshot_dir)
+ {
+ SFile snapshot_dir(info_dir, "snapshot");
+ snapshot_dir.restorecon(selabel_handle);
+ }
vector<string> info_content = info_dir.entries();
for (vector<string>::const_iterator it2 = info_content.begin(); it2 != info_content.end(); ++it2)
void syncAcl(const vector<uid_t>& uids, const vector<gid_t>& gids) const;
- void syncSelinuxContexts() const;
- void syncSelinuxContextsInInfosDir() const;
+ void syncSelinuxContexts(bool skip_snapshot_dir) const;
+ void syncSelinuxContextsInInfosDir(bool skip_snapshot_dir) const;
void syncInfoDir(SDir& dir) const;
ConfigInfo* config_info;