From: Arvin Schnell Date: Tue, 16 Oct 2018 12:04:45 +0000 (+0200) Subject: - ignore requests to delete special snapshots X-Git-Tag: v0.7.1~4^2~1 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=3b0744433f58ac007f02ccca0aba030cee3f472b;p=thirdparty%2Fsnapper.git - ignore requests to delete special snapshots --- diff --git a/LIBVERSION b/LIBVERSION index 80895903..f77856a6 100644 --- a/LIBVERSION +++ b/LIBVERSION @@ -1 +1 @@ -4.3.0 +4.3.1 diff --git a/doc/dbus-protocol.txt b/doc/dbus-protocol.txt index b4801a4e..94dbd451 100644 --- a/doc/dbus-protocol.txt +++ b/doc/dbus-protocol.txt @@ -69,3 +69,7 @@ hexadecimal as "\x??". As a consequence "\" must be encoded as "\\". Due to security concerns there are no methods to get, compare or revert files. This can be done in the client. + + +Some snapshots cannot be deleted (current, default and active). Delete +requests for these are ignored. diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 6c705523..c01961ab 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -174,16 +174,14 @@ namespace snapper bool Filesystem::isDefault(unsigned int num) const { - SN_THROW(UnsupportedException()); - __builtin_unreachable(); + return false; } std::pair Filesystem::getDefault() const { - SN_THROW(UnsupportedException()); - __builtin_unreachable(); + return std::make_pair(false, 0); } @@ -198,16 +196,14 @@ namespace snapper std::pair Filesystem::getActive() const { - SN_THROW(UnsupportedException()); - __builtin_unreachable(); + return std::make_pair(false, 0); } bool Filesystem::isActive(unsigned int num) const { - SN_THROW(UnsupportedException()); - __builtin_unreachable(); + return false; } diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index 5a0e10fb..43c6da2d 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -420,11 +420,15 @@ namespace snapper Hooks::delete_config(snapper->subvolumeDir(), snapper->getFilesystem()); Snapshots& snapshots = snapper->getSnapshots(); + + Snapshots::const_iterator default_snapshot = snapshots.getDefault(); + Snapshots::const_iterator active_snapshot = snapshots.getActive(); + for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); ) { Snapshots::iterator tmp = it++; - if (tmp->isCurrent()) + if (tmp->isCurrent() || tmp == default_snapshot || tmp == active_snapshot) continue; try diff --git a/snapper/Snapshot.cc b/snapper/Snapshot.cc index 985440f1..900e4ef2 100644 --- a/snapper/Snapshot.cc +++ b/snapper/Snapshot.cc @@ -573,9 +573,6 @@ namespace snapper void Snapshot::deleteFilesystemSnapshot() const { - if (isCurrent()) - SN_THROW(IllegalSnapshotException()); - snapper->getFilesystem()->umountSnapshot(num); snapper->getFilesystem()->deleteSnapshot(num); } @@ -734,7 +731,8 @@ namespace snapper void Snapshots::deleteSnapshot(iterator snapshot) { - if (snapshot == entries.end() || snapshot->isCurrent()) + if (snapshot == entries.end() || snapshot->isCurrent() || snapshot->isDefault() || + snapshot->isActive()) SN_THROW(IllegalSnapshotException()); snapshot->deleteFilesystemSnapshot();