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

Fix: Continue sync and lock timer during system sleep #207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

poettig
Copy link

@poettig poettig commented Sep 22, 2024

This commit fixes a bug were the timers for sync and vault lock did not "continue" during system sleep because of the use of tokio::time::sleep which uses the monotonic clock.

Did only test on Linux, although according to https://doc.rust-lang.org/std/time/struct.SystemTime.html#platform-specific-behavior, SystemTime works on all platforms.

As SystemTime can be manipulated by the user, the timers elapse completely when time went backwards for security reasons.

…leep

Also added jetbrains project folders to .gitignore
@doy
Copy link
Owner

doy commented Dec 26, 2024

i'm not really a fan of switching this to polling every second (that's pretty bad from a power usage perspective), and while this does fix the issue of tracking elapsed time during sleep, it instead opens up the possibility of someone keeping the vault unlocked by repeatedly setting the time backwards (this code would catch that if it set it back further than the current second, but you could easily do a thing which runs more frequently than that and still fiddles with the time while not getting caught by that check).

ideally tokio would provide a call that used a boot time clock directly (relevant issue is here tokio-rs/tokio#3185) but until that happens, i'd rather see an implementation which used an AsyncFd wrapper around a timerfd which is configured to use CLOCK_BOOTTIME (on linux, falling back to the existing tokio::time::sleep implementation on other platforms).

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.

2 participants