[SERVER-20359] result of terseCurrentTime(false) is not ISO 8601 compatible Created: 10/Sep/15  Updated: 14/Sep/20  Resolved: 14/Sep/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 4.8.0

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Sara Golemon
Resolution: Done Votes: 0
Labels: move-sec
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-43631 "--logRotate reopen --logappend" trun... Closed
related to SERVER-42720 implement --logAppend Closed
is related to SERVER-20354 key store path should not contain colon Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Security 2020-09-21
Participants:

 Description   

The time component of a UTC date time object may be separated with : (for the extended format), or with nothing (the basic format).

When called with the default argument of 'true' the terseCurrentTime function produces the extended format. However, the extended format's use of : as a separator makes it invalid as a filename.

When called with 'false', terseCurrentTime uses the '-' character to separate the time components, which results in a format which is not compatible with ISO 8601.

We should either fix the function to remove any separator in the time component when the function is called with 'false', or update the documentation of the function to make clear that it does not produce UTC date times in that case.

Note that our log file extension currently reflects the results of calling terseCurrentTime with 'false'.



 Comments   
Comment by Githook User [ 14/Sep/20 ]

Author:

{'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com', 'username': 'sgolemon'}

Message: SERVER-20359 Rename terse(UTC)CurrentTime to terseCurrentTimeForFilename()
Branch: master
https://github.com/mongodb/mongo/commit/ec929e17993ade6e0258aab73fd8024d1cb6180f

Comment by Githook User [ 14/Sep/20 ]

Author:

{'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com', 'username': 'sgolemon'}

Message: SERVER-20359 Rename terse(UTC)CurrentTime to terseCurrentTimeForFilename()
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/a79fb58d8fb1bc497aa4c350001a82c5a2867eaa

Comment by Sara Golemon [ 11/Sep/20 ]

Checking through v3.6 through master, it doesn't appear as though we ever call terseCurrentTime(true) (or terseCurrentTime() which uses the default true).

Given that, and given that it seems to only be used for creating filenames, I'll remove the argument (simplifying it), and update the comment to reflect that it produces timestamps appropriate for use in filenames.

More disturbing is a wrapper of this function: terseUTCCurrentTime() which implies it's returning a UTC time (and appends a 'Z' to the string to attest to that), but since the underlying implementation uses stftime(), it's actually returning a time in the locally configured timezone (based on env var 'TZ').  Since we're already using timelib, it would make sense to have that give us a properly formatted time that is ACTUALLY in UTC, or not pretend to use UTC at all. 

Edit to reflect that we have a call to gmtime_r() hidden in time_t_to_Struct() which resolves this.  So it is expressed in UTC, even if not in ISO8601.

Generated at Thu Feb 08 03:53:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.