From d58cb1016ab3dd182f2aae9bef7dc39d55a542c7 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 17 Feb 2023 20:55:02 +0100 Subject: sq: Avoid deprecated chrono interfaces. - Also bump chrono to 0.4.23 so that we can use DateTime::date_naive. - The bump was necessary because cargo publish will use the newest version as opposed to the one recorded in Cargo.lock. The locked version neither has DateTime::date_naive, nor does it deprecate the old interface. --- Cargo.lock | 112 +++++++++++++++++++++++++++++++++++++++++++-- sq/src/commands/certify.rs | 6 ++- sq/src/commands/inspect.rs | 3 +- sq/src/commands/key.rs | 3 +- sq/src/commands/revoke.rs | 2 +- sq/src/sq.rs | 2 +- sq/src/sq_cli/types.rs | 5 +- 7 files changed, 120 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6a6f3bd..7d1a6ffb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,6 +57,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -384,12 +393,12 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ + "iana-time-zone", "js-sys", - "libc", "num-integer", "num-traits", "time 0.1.43", @@ -487,6 +496,16 @@ dependencies = [ "dbl", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "const-oid" version = "0.5.2" @@ -689,6 +708,50 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cxx" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -1453,6 +1516,30 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "idea" version = "0.3.0" @@ -1613,9 +1700,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.124" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libloading" @@ -1633,6 +1720,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -2655,6 +2751,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" + [[package]] name = "security-framework" version = "2.6.1" diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs index d3121dd8..1a1c62d0 100644 --- a/sq/src/commands/certify.rs +++ b/sq/src/commands/certify.rs @@ -45,7 +45,8 @@ pub fn certify(config: Config, c: certify::Command) let time = if let Some(t) = c.time { let time = SystemTime::from( - crate::parse_iso8601(&t, chrono::NaiveTime::from_hms(0, 0, 0)) + crate::parse_iso8601( + &t, chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap()) .context(format!("Parsing --time {}", t))?); Some(time) } else { @@ -122,7 +123,8 @@ pub fn certify(config: Config, c: certify::Command) let now = builder.signature_creation_time() .unwrap_or_else(std::time::SystemTime::now); let expiration = SystemTime::from( - crate::parse_iso8601(&t, chrono::NaiveTime::from_hms(0, 0, 0))?); + crate::parse_iso8601( + &t, chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap())?); let validity = expiration.duration_since(now)?; builder = builder.set_signature_creation_time(now)? .set_signature_validity_period(validity)?; diff --git a/sq/src/commands/inspect.rs b/sq/src/commands/inspect.rs index fe6007c3..bd4285e7 100644 --- a/sq/src/commands/inspect.rs +++ b/sq/src/commands/inspect.rs @@ -28,7 +28,8 @@ pub fn inspect(c: inspect::Command, policy: &dyn Policy, output: &mut dyn io::Wr let time = if let Some(t) = c.time { let time = SystemTime::from( - crate::parse_iso8601(&t, chrono::NaiveTime::from_hms(0, 0, 0)) + crate::parse_iso8601( + &t, chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap()) .context(format!("Parsing --time {}", t))?, ); Some(time) diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs index d428ceb0..6d0b01e5 100644 --- a/sq/src/commands/key.rs +++ b/sq/src/commands/key.rs @@ -72,7 +72,8 @@ fn generate( let now = builder.creation_time() .unwrap_or_else(std::time::SystemTime::now); let expiration = SystemTime::from( - crate::parse_iso8601(&t, chrono::NaiveTime::from_hms(0, 0, 0))?); + crate::parse_iso8601( + &t, chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap())?); let validity = expiration.duration_since(now)?; builder = builder.set_creation_time(now) .set_validity_period(validity); diff --git a/sq/src/commands/revoke.rs b/sq/src/commands/revoke.rs index c07b3497..5496812f 100644 --- a/sq/src/commands/revoke.rs +++ b/sq/src/commands/revoke.rs @@ -314,7 +314,7 @@ a revocation certificate for that User ID anyways, specify '--force'")); k.fingerprint().to_hex(), chrono::DateTime:: ::from(k.creation_time()) - .date(), + .date_naive(), k.key_flags().unwrap_or_else(KeyFlags::empty)); } if ! have_valid { diff --git a/sq/src/sq.rs b/sq/src/sq.rs index f96b32cd..b2321a05 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -793,7 +793,7 @@ fn parse_iso8601(s: &str, pad_date_with: chrono::NaiveTime) #[test] fn test_parse_iso8601() { - let z = chrono::NaiveTime::from_hms(0, 0, 0); + let z = chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap(); parse_iso8601("2017-03-04T13:25:35Z", z).unwrap(); parse_iso8601("2017-03-04T13:25:35+08:30", z).unwrap(); parse_iso8601("2017-03-04T13:25:35", z).unwrap(); diff --git a/sq/src/sq_cli/types.rs b/sq/src/sq_cli/types.rs index e5ee306e..3d13a9a6 100644 --- a/sq/src/sq_cli/types.rs +++ b/sq/src/sq_cli/types.rs @@ -141,7 +141,8 @@ impl std::str::FromStr for Time { fn from_str(s: &str) -> anyhow::Result