avoid chrono dependency, depend on proxmox 0.3.8

- remove chrono dependency

- depend on proxmox 0.3.8

- remove epoch_now, epoch_now_u64 and epoch_now_f64

- remove tm_editor (moved to proxmox crate)

- use new helpers from proxmox 0.3.8
  * epoch_i64 and epoch_f64
  * parse_rfc3339
  * epoch_to_rfc3339_utc
  * strftime_local

- BackupDir changes:
  * store epoch and rfc3339 string instead of DateTime
  * backup_time_to_string now return a Result
  * remove unnecessary TryFrom<(BackupGroup, i64)> for BackupDir

- DynamicIndexHeader: change ctime to i64

- FixedIndexHeader: change ctime to i64
This commit is contained in:
Dietmar Maurer
2020-09-12 15:10:47 +02:00
parent 58169da46a
commit 6a7be83efe
37 changed files with 198 additions and 380 deletions

View File

@ -11,7 +11,6 @@ use openssl::sign::{Signer, Verifier};
use percent_encoding::{percent_decode_str, percent_encode, AsciiSet};
use crate::api2::types::Userid;
use crate::tools::epoch_now_u64;
pub const TICKET_LIFETIME: i64 = 3600 * 2; // 2 hours
@ -69,7 +68,7 @@ where
Ok(Self {
prefix: Cow::Borrowed(prefix),
data: data.to_string(),
time: epoch_now_u64()? as i64,
time: proxmox::tools::time::epoch_i64(),
signature: None,
_type_marker: PhantomData,
})
@ -174,7 +173,7 @@ where
None => bail!("invalid ticket without signature"),
};
let age = epoch_now_u64()? as i64 - self.time;
let age = proxmox::tools::time::epoch_i64() - self.time;
if age < time_frame.start {
bail!("invalid ticket - timestamp newer than expected");
}
@ -272,7 +271,6 @@ mod test {
use super::Ticket;
use crate::api2::types::Userid;
use crate::tools::epoch_now_u64;
fn simple_test<F>(key: &PKey<Private>, aad: Option<&str>, modify: F)
where
@ -314,7 +312,7 @@ mod test {
false
});
simple_test(&key, None, |t| {
t.change_time(epoch_now_u64().unwrap() as i64 + 0x1000_0000);
t.change_time(proxmox::tools::time::epoch_i64() + 0x1000_0000);
false
});
}