Skip to content

Commit 1d45a64

Browse files
authored
Merge pull request #385 from foundriesio/v94-forbid-downgrade
main: Forbid target downgrade
2 parents 04a6955 + e10e23d commit 1d45a64

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,13 @@ static int daemon_main(LiteClient& client, const bpo::variables_map& variables_m
332332
// installed, if so then skip an update to the such version/Target
333333
bool is_rollback_target = client.isRollback(target_to_install);
334334

335-
if (!is_rollback_target && !client.isTargetActive(target_to_install)) {
335+
const bool is_downgrade{Target::Version(target_to_install.custom_version()) <
336+
Target::Version(current.custom_version())};
337+
if (is_downgrade) {
338+
LOG_WARNING << "Downgrade detected; from " << current.custom_version() << " to "
339+
<< target_to_install.custom_version() << ", keep running " << current.custom_version();
340+
}
341+
if (!is_rollback_target && !client.isTargetActive(target_to_install) && !is_downgrade) {
336342
if (!rollback) {
337343
LOG_INFO << "Found new and valid Target to update to: " << target_to_install.filename()
338344
<< ", sha256: " << target_to_install.sha256Hash();

0 commit comments

Comments
 (0)