Skip to content

Cleanup old 'time' dependency and make local time available #188

Closed
@Byron

Description

@Byron

The motivation for this is to provide a way to obtain the local time in seconds since epoch along with a timezone offset for use in git-actor::Signature, providing something similar to git2::Signature::now().

What is just a few innocent looking lines of code in C ) actually is a can full of worms, best summarized with with this comment:

quininer says

setenv and getenv are not thread-safe, and localtime_r will call getenv, which cause to data races if setenv and localtime_r occur at same time.

To be more specific, getenv will return a pointer, and after setenv the pointer may point to an invalid address.

In order to fix this for gitoxide, the following should be done

  • prodash relies on an outdated version of time with unsound behaviour to make its local-time feature work.
    • In time 0.3 handling this is greatly improved as it exposes the unsound behaviour exploited here in a compiler flag, placing support for this into the hands of the one compiling the binary. This is fair and we should do it like that
  • The above allows to remove an exemption from deny.toml and upgrade to prodash 16
  • configure binary builds to add the unsound_local_offset config flag
  • Add a libc implementation based on [libgit2](libgit2-offset] (not portable) Wrap the time implementation for now, knowing that one day it can be done properly
    • It's interesting that it also excludes windows, which might work very differently and was never discussed in the the time issue - it doesn't actually, it's a unix-only issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions