"Could not determine the UTC offset on this system" and defaulting to UTC timestamps #66
borntyping
started this conversation in
Known issues
Replies: 2 comments 4 replies
-
A potential solution to this could be to save the offset while starting the program, which works fine, and save it globally. I personally use static OFFSET: Lazy<UtcOffset> = Lazy::new(|| {
UtcOffset::local_offset_at(OffsetDateTime::now_utc()).unwrap_or_else(|_| {
warn!("Failed to determine local offset, UTC will be used instead");
UtcOffset::UTC
})
});
pub fn get_now() -> OffsetDateTime {
OffsetDateTime::now_utc().to_offset(*OFFSET)
} |
Beta Was this translation helpful? Give feedback.
3 replies
-
Since unsafe {
time::util::local_offset::set_soundness(time::util::local_offset::Soundness::Unsound);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current defaults are to format timestamps using the local timezone. Since switching to the
time
crate to avoid unsafe code inchrono
(CVE-2020-26235), a lot of users usesimple_logger
in scenarios wheretime
refuses to fetch the local timezone to avoid running unsafe code (time-rs/time#293). This usually affects users running a multithreaded application, astime
assumes it's safe to get the local timezone when running in a single-threaded environment where there's no risk of an environment variable being set by a different thread.Support for UTC timestamps has been added to
simple_logger
, but I'm currently trying to work out the best way to safely change the default away from local timestamps in a way that doesn't risk silently changing user's logs from one timezone to another with no way to tell the difference.If this issue is affecting you, there are a few approaches you can take:
simple_logger
2.0.0This breaking change switches to UTC timestamps in RFC 3339 format.
Use UTC via
.with_utc_timestamps()
like in examples/timestamps_utc.rs.Use a static UTC offset via
.with_utc_offset(...)
like in examples/timestamps_utc_offset.rs.Don't display timestamps at all via
.without_timestamps()
like in examples/timestamps_none.rs.time
crate's unsafe featuresExport
RUSTFLAGS="--cfg unsound_local_offset"
when compiling (docs).Issues related to this are all tagged CVE-2020-26235. Tagging #51, #48, #47, #44, #43, #35.
Beta Was this translation helpful? Give feedback.
All reactions