update to first proxmox crate split
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -15,7 +15,7 @@ endian_trait = { version = "0.6", features = ["arrays"] }
|
||||
flate2 = "1.0"
|
||||
foreign-types = "0.3"
|
||||
futures = "0.3"
|
||||
hex = "0.4"
|
||||
hex = "0.4.3"
|
||||
lazy_static = "1.4"
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
@ -33,9 +33,9 @@ walkdir = "2"
|
||||
zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
|
||||
proxmox = { version = "0.14.0", default-features = false, features = [ "tokio" ] }
|
||||
proxmox-io = { version = "1.0.0" }
|
||||
proxmox-lang = { version = "1.0.0" }
|
||||
proxmox-time = { version = "1.0.0" }
|
||||
proxmox-io = { version = "1", features = [ "tokio" ] }
|
||||
proxmox-lang = { version = "1" }
|
||||
proxmox-time = { version = "1" }
|
||||
|
||||
pbs-buildcfg = { path = "../pbs-buildcfg" }
|
||||
pbs-runtime = { path = "../pbs-runtime" }
|
||||
|
@ -24,7 +24,7 @@ fn asn1_time_to_unix(time: &openssl::asn1::Asn1TimeRef) -> Result<i64, Error> {
|
||||
bail!("failed to parse ASN1 time");
|
||||
}
|
||||
let mut c_tm = unsafe { c_tm.assume_init() };
|
||||
proxmox::tools::time::timegm(&mut c_tm)
|
||||
Ok(proxmox_time::timegm(&mut c_tm)?)
|
||||
}
|
||||
|
||||
pub struct CertInfo {
|
||||
@ -66,10 +66,11 @@ impl CertInfo {
|
||||
|
||||
pub fn fingerprint(&self) -> Result<String, Error> {
|
||||
let fp = self.x509.digest(openssl::hash::MessageDigest::sha256())?;
|
||||
let fp_string = proxmox::tools::digest_to_hex(&fp);
|
||||
let fp_string = fp_string.as_bytes().chunks(2).map(|v| std::str::from_utf8(v).unwrap())
|
||||
.collect::<Vec<&str>>().join(":");
|
||||
Ok(fp_string)
|
||||
Ok(hex::encode(&fp)
|
||||
.as_bytes()
|
||||
.chunks(2)
|
||||
.map(|v| std::str::from_utf8(v).unwrap())
|
||||
.collect::<Vec<&str>>().join(":"))
|
||||
}
|
||||
|
||||
pub fn public_key(&self) -> Result<PKey<Public>, Error> {
|
||||
|
@ -10,7 +10,7 @@ use futures::stream::Stream;
|
||||
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||
|
||||
use proxmox::io_format_err;
|
||||
use proxmox::tools::byte_buffer::ByteBuffer;
|
||||
use proxmox_io::ByteBuffer;
|
||||
|
||||
const BUFFER_SIZE: usize = 8192;
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub fn render_epoch(value: &Value, _record: &Value) -> Result<String, Error> {
|
||||
if value.is_null() { return Ok(String::new()); }
|
||||
let text = match value.as_i64() {
|
||||
Some(epoch) => {
|
||||
if let Ok(epoch_string) = proxmox::tools::time::strftime_local("%c", epoch as i64) {
|
||||
if let Ok(epoch_string) = proxmox_time::strftime_local("%c", epoch as i64) {
|
||||
epoch_string
|
||||
} else {
|
||||
epoch.to_string()
|
||||
@ -104,14 +104,16 @@ impl From<u64> for HumanByte {
|
||||
}
|
||||
|
||||
pub fn as_fingerprint(bytes: &[u8]) -> String {
|
||||
proxmox::tools::digest_to_hex(bytes)
|
||||
hex::encode(bytes)
|
||||
.as_bytes()
|
||||
.chunks(2)
|
||||
.map(|v| std::str::from_utf8(v).unwrap())
|
||||
.map(|v| unsafe { std::str::from_utf8_unchecked(v) }) // it's a hex string
|
||||
.collect::<Vec<&str>>().join(":")
|
||||
}
|
||||
|
||||
pub mod bytes_as_fingerprint {
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
use serde::{Deserialize, Serializer, Deserializer};
|
||||
|
||||
pub fn serialize<S>(
|
||||
@ -131,9 +133,14 @@ pub mod bytes_as_fingerprint {
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
// TODO: more efficiently implement with a Visitor implementing visit_str using split() and
|
||||
// hex::decode by-byte
|
||||
let mut s = String::deserialize(deserializer)?;
|
||||
s.retain(|c| c != ':');
|
||||
proxmox::tools::hex_to_digest(&s).map_err(serde::de::Error::custom)
|
||||
let mut out = MaybeUninit::<[u8; 32]>::uninit();
|
||||
hex::decode_to_slice(s.as_bytes(), unsafe { &mut (*out.as_mut_ptr())[..] })
|
||||
.map_err(serde::de::Error::custom)?;
|
||||
Ok(unsafe { out.assume_init() })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,12 @@ use std::io::Read;
|
||||
|
||||
use anyhow::Error;
|
||||
|
||||
use proxmox_io::vec;
|
||||
|
||||
/// Calculate the sha256sum from a readable object.
|
||||
pub fn sha256(file: &mut dyn Read) -> Result<([u8; 32], u64), Error> {
|
||||
let mut hasher = openssl::sha::Sha256::new();
|
||||
let mut buffer = proxmox::tools::vec::undefined(256 * 1024);
|
||||
let mut buffer = vec::undefined(256 * 1024);
|
||||
let mut size: u64 = 0;
|
||||
|
||||
loop {
|
||||
|
@ -13,8 +13,8 @@ use futures::future::FutureExt;
|
||||
use futures::stream::Stream;
|
||||
|
||||
use proxmox::io_format_err;
|
||||
use proxmox::tools::byte_buffer::ByteBuffer;
|
||||
use proxmox::sys::error::io_err_other;
|
||||
use proxmox_io::ByteBuffer;
|
||||
|
||||
use pbs_runtime::block_in_place;
|
||||
|
||||
|
@ -66,7 +66,7 @@ where
|
||||
Ok(Self {
|
||||
prefix: Cow::Borrowed(prefix),
|
||||
data: data.to_string(),
|
||||
time: proxmox::tools::time::epoch_i64(),
|
||||
time: proxmox_time::epoch_i64(),
|
||||
signature: None,
|
||||
_type_marker: PhantomData,
|
||||
})
|
||||
@ -171,7 +171,7 @@ where
|
||||
None => bail!("invalid ticket without signature"),
|
||||
};
|
||||
|
||||
let age = proxmox::tools::time::epoch_i64() - self.time;
|
||||
let age = proxmox_time::epoch_i64() - self.time;
|
||||
if age < time_frame.start {
|
||||
bail!("invalid ticket - timestamp newer than expected");
|
||||
}
|
||||
@ -325,7 +325,7 @@ mod test {
|
||||
false
|
||||
});
|
||||
simple_test(&key, None, |t| {
|
||||
t.change_time(proxmox::tools::time::epoch_i64() + 0x1000_0000);
|
||||
t.change_time(proxmox_time::epoch_i64() + 0x1000_0000);
|
||||
false
|
||||
});
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ use std::os::unix::io::RawFd;
|
||||
|
||||
use nix::errno::Errno;
|
||||
|
||||
use proxmox::c_str;
|
||||
use proxmox::tools::vec;
|
||||
use proxmox_io::vec;
|
||||
use proxmox_lang::c_str;
|
||||
|
||||
/// `"security.capability"` as a CStr to avoid typos.
|
||||
///
|
||||
@ -187,7 +187,7 @@ mod tests {
|
||||
|
||||
use nix::errno::Errno;
|
||||
|
||||
use proxmox::c_str;
|
||||
use proxmox_lang::c_str;
|
||||
|
||||
#[test]
|
||||
fn test_fsetxattr_fgetxattr() {
|
||||
|
@ -20,7 +20,7 @@ use futures::ready;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf};
|
||||
|
||||
use crc32fast::Hasher;
|
||||
use proxmox::tools::time::gmtime;
|
||||
use proxmox_time::gmtime;
|
||||
|
||||
use crate::compression::{DeflateEncoder, Level};
|
||||
|
||||
|
Reference in New Issue
Block a user