update to proxmox-sys 0.2 crate
- imported pbs-api-types/src/common_regex.rs from old proxmox crate - use hex crate to generate/parse hex digest - remove all reference to proxmox crate (use proxmox-sys and proxmox-serde instead) Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
@ -11,6 +11,7 @@ base64 = "0.13"
|
||||
crc32fast = "1"
|
||||
endian_trait = { version = "0.6", features = [ "arrays" ] }
|
||||
futures = "0.3"
|
||||
hex = "0.4.3"
|
||||
lazy_static = "1.4"
|
||||
libc = "0.2"
|
||||
log = "0.4"
|
||||
@ -25,14 +26,13 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
pathpatterns = "0.1.2"
|
||||
pxar = "0.10.1"
|
||||
|
||||
proxmox = "0.15.3"
|
||||
proxmox-borrow = "1"
|
||||
proxmox-io = "1"
|
||||
proxmox-lang = "1"
|
||||
proxmox-schema = { version = "1", features = [ "api-macro" ] }
|
||||
proxmox-time = "1"
|
||||
proxmox-uuid = "1"
|
||||
proxmox-sys = "0.1.2"
|
||||
proxmox-sys = "0.2"
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -81,7 +81,7 @@ impl BackupGroup {
|
||||
let mut path = base_path.to_owned();
|
||||
path.push(self.group_path());
|
||||
|
||||
pbs_tools::fs::scandir(
|
||||
proxmox_sys::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
&path,
|
||||
&BACKUP_DATE_REGEX,
|
||||
@ -110,7 +110,7 @@ impl BackupGroup {
|
||||
let mut path = base_path.to_owned();
|
||||
path.push(self.group_path());
|
||||
|
||||
pbs_tools::fs::scandir(
|
||||
proxmox_sys::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
&path,
|
||||
&BACKUP_DATE_REGEX,
|
||||
@ -369,7 +369,7 @@ impl BackupInfo {
|
||||
pub fn list_backup_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
pbs_tools::fs::scandir(
|
||||
proxmox_sys::fs::scandir(
|
||||
libc::AT_FDCWD,
|
||||
base_path,
|
||||
&BACKUP_TYPE_REGEX,
|
||||
@ -377,7 +377,7 @@ impl BackupInfo {
|
||||
if file_type != nix::dir::Type::Directory {
|
||||
return Ok(());
|
||||
}
|
||||
pbs_tools::fs::scandir(
|
||||
proxmox_sys::fs::scandir(
|
||||
l0_fd,
|
||||
backup_type,
|
||||
&BACKUP_ID_REGEX,
|
||||
@ -411,7 +411,7 @@ fn list_backup_files<P: ?Sized + nix::NixPath>(
|
||||
) -> Result<Vec<String>, Error> {
|
||||
let mut files = vec![];
|
||||
|
||||
pbs_tools::fs::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
|
||||
proxmox_sys::fs::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
|
||||
if file_type != nix::dir::Type::File {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ use anyhow::Error;
|
||||
use futures::ready;
|
||||
use tokio::io::{AsyncRead, AsyncSeek, ReadBuf};
|
||||
|
||||
use proxmox::io_format_err;
|
||||
use proxmox::sys::error::io_err_other;
|
||||
use proxmox_sys::io_format_err;
|
||||
use proxmox_sys::error::io_err_other;
|
||||
|
||||
use pbs_tools::async_lru_cache::{AsyncCacher, AsyncLruCache};
|
||||
|
||||
|
@ -5,9 +5,9 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use proxmox::tools::fs::{CreateOptions, create_path, create_dir};
|
||||
use proxmox_sys::fs::{CreateOptions, create_path, create_dir};
|
||||
use proxmox_sys::process_locker::{ProcessLocker, ProcessLockSharedGuard, ProcessLockExclusiveGuard};
|
||||
use proxmox_sys::worker_task_context::WorkerTaskContext;
|
||||
use proxmox_sys::WorkerTaskContext;
|
||||
use proxmox_sys::task_log;
|
||||
use pbs_api_types::GarbageCollectionStatus;
|
||||
|
||||
@ -96,7 +96,7 @@ impl ChunkStore {
|
||||
|
||||
// create lock file with correct owner/group
|
||||
let lockfile_path = Self::lockfile_path(&base);
|
||||
proxmox::tools::fs::replace_file(lockfile_path, b"", options.clone(), false)?;
|
||||
proxmox_sys::fs::replace_file(lockfile_path, b"", options.clone(), false)?;
|
||||
|
||||
// create 64*1024 subdirs
|
||||
let mut last_percentage = 0;
|
||||
@ -194,7 +194,7 @@ impl ChunkStore {
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
) -> Result<
|
||||
impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
|
||||
impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
|
||||
Error
|
||||
> {
|
||||
use nix::dir::Dir;
|
||||
@ -212,7 +212,7 @@ impl ChunkStore {
|
||||
})?;
|
||||
|
||||
let mut done = false;
|
||||
let mut inner: Option<pbs_tools::fs::ReadDir> = None;
|
||||
let mut inner: Option<proxmox_sys::fs::ReadDir> = None;
|
||||
let mut at = 0;
|
||||
let mut percentage = 0;
|
||||
Ok(std::iter::from_fn(move || {
|
||||
@ -256,7 +256,7 @@ impl ChunkStore {
|
||||
let subdir: &str = &format!("{:04x}", at);
|
||||
percentage = (at * 100) / 0x10000;
|
||||
at += 1;
|
||||
match pbs_tools::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
|
||||
match proxmox_sys::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
|
||||
Ok(dir) => {
|
||||
inner = Some(dir);
|
||||
// start reading:
|
||||
@ -382,7 +382,7 @@ impl ChunkStore {
|
||||
digest: &[u8; 32],
|
||||
) -> Result<(bool, u64), Error> {
|
||||
|
||||
//println!("DIGEST {}", proxmox::tools::digest_to_hex(digest));
|
||||
//println!("DIGEST {}", hex::encode(digest));
|
||||
|
||||
let (chunk_path, digest_str) = self.chunk_path(digest);
|
||||
|
||||
@ -440,7 +440,7 @@ impl ChunkStore {
|
||||
let mut chunk_path = self.chunk_dir.clone();
|
||||
let prefix = digest_to_prefix(digest);
|
||||
chunk_path.push(&prefix);
|
||||
let digest_str = proxmox::tools::digest_to_hex(digest);
|
||||
let digest_str = hex::encode(digest);
|
||||
chunk_path.push(&digest_str);
|
||||
(chunk_path, digest_str)
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ impl <W: Write> CryptWriter<W> {
|
||||
|
||||
pub fn new(writer: W, config: Arc<CryptConfig>) -> Result<Self, Error> {
|
||||
let mut iv = [0u8; 16];
|
||||
proxmox::sys::linux::fill_with_random_data(&mut iv)?;
|
||||
proxmox_sys::linux::fill_with_random_data(&mut iv)?;
|
||||
let block_size = config.cipher().block_size();
|
||||
|
||||
let crypter = config.data_crypter(&iv, openssl::symm::Mode::Encrypt)?;
|
||||
|
@ -347,7 +347,7 @@ impl DataBlob {
|
||||
) -> Result<([u8;16], [u8;16]), Error> {
|
||||
|
||||
let mut iv = [0u8; 16];
|
||||
proxmox::sys::linux::fill_with_random_data(&mut iv)?;
|
||||
proxmox_sys::linux::fill_with_random_data(&mut iv)?;
|
||||
|
||||
let mut tag = [0u8; 16];
|
||||
|
||||
|
@ -9,13 +9,13 @@ use std::time::Duration;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, file_read_optional_string, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, file_read_optional_string, CreateOptions};
|
||||
use proxmox_sys::process_locker::ProcessLockSharedGuard;
|
||||
use proxmox_sys::worker_task_context::WorkerTaskContext;
|
||||
use proxmox_sys::WorkerTaskContext;
|
||||
use proxmox_sys::{task_log, task_warn};
|
||||
use proxmox_sys::fs::{lock_dir_noblock, DirLockGuard};
|
||||
|
||||
use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus, HumanByte};
|
||||
use pbs_tools::fs::{lock_dir_noblock, DirLockGuard};
|
||||
use pbs_config::{open_backup_lockfile, BackupLockGuard};
|
||||
|
||||
use crate::DataBlob;
|
||||
@ -127,7 +127,7 @@ impl DataStore {
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
) -> Result<
|
||||
impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)>,
|
||||
impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>,
|
||||
Error
|
||||
> {
|
||||
self.chunk_store.get_chunk_iterator()
|
||||
@ -199,7 +199,7 @@ impl DataStore {
|
||||
map_err(|err| {
|
||||
format_err!(
|
||||
"fast_index_verification error, stat_chunk {} failed - {}",
|
||||
proxmox::tools::digest_to_hex(&info.digest),
|
||||
hex::encode(&info.digest),
|
||||
err,
|
||||
)
|
||||
})?;
|
||||
@ -232,7 +232,7 @@ impl DataStore {
|
||||
wanted_files.insert(CLIENT_LOG_BLOB_NAME.to_string());
|
||||
manifest.files().iter().for_each(|item| { wanted_files.insert(item.filename.clone()); });
|
||||
|
||||
for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
|
||||
for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
|
||||
if let Ok(item) = item {
|
||||
if let Some(file_type) = item.file_type() {
|
||||
if file_type != nix::dir::Type::File { continue; }
|
||||
@ -272,7 +272,7 @@ impl DataStore {
|
||||
|
||||
let full_path = self.group_path(backup_group);
|
||||
|
||||
let _guard = pbs_tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
||||
let _guard = proxmox_sys::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
|
||||
|
||||
log::info!("removing backup group {:?}", full_path);
|
||||
|
||||
@ -358,7 +358,7 @@ impl DataStore {
|
||||
let mut full_path = self.base_path();
|
||||
full_path.push(backup_group.group_path());
|
||||
full_path.push("owner");
|
||||
let owner = proxmox::tools::fs::file_read_firstline(full_path)?;
|
||||
let owner = proxmox_sys::fs::file_read_firstline(full_path)?;
|
||||
Ok(owner.trim_end().parse()?) // remove trailing newline
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ impl DataStore {
|
||||
task_warn!(
|
||||
worker,
|
||||
"warning: unable to access non-existent chunk {}, required by {:?}",
|
||||
proxmox::tools::digest_to_hex(digest),
|
||||
hex::encode(digest),
|
||||
file_name,
|
||||
);
|
||||
|
||||
|
@ -9,7 +9,7 @@ use std::task::Context;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use proxmox::tools::mmap::Mmap;
|
||||
use proxmox_sys::mmap::Mmap;
|
||||
use proxmox_io::ReadExt;
|
||||
use proxmox_uuid::Uuid;
|
||||
use proxmox_sys::process_locker::ProcessLockSharedGuard;
|
||||
@ -467,7 +467,7 @@ impl DynamicChunkWriter {
|
||||
chunk_size,
|
||||
(compressed_size * 100) / (chunk_size as u64),
|
||||
is_duplicate,
|
||||
proxmox::tools::digest_to_hex(&digest)
|
||||
hex::encode(&digest)
|
||||
);
|
||||
self.index.add_chunk(self.chunk_offset as u64, &digest)?;
|
||||
self.chunk_buffer.truncate(0);
|
||||
|
@ -424,7 +424,7 @@ impl FixedIndexWriter {
|
||||
chunk_len,
|
||||
(compressed_size * 100) / (chunk_len as u64),
|
||||
is_duplicate,
|
||||
proxmox::tools::digest_to_hex(digest)
|
||||
hex::encode(digest)
|
||||
);
|
||||
|
||||
if is_duplicate {
|
||||
|
@ -18,6 +18,7 @@ pub const ENCRYPTED_KEY_BLOB_NAME: &str = "rsa-encrypted.key.blob";
|
||||
|
||||
mod hex_csum {
|
||||
use serde::{self, Deserialize, Serializer, Deserializer};
|
||||
use hex::FromHex;
|
||||
|
||||
pub fn serialize<S>(
|
||||
csum: &[u8; 32],
|
||||
@ -26,7 +27,7 @@ mod hex_csum {
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let s = proxmox::tools::digest_to_hex(csum);
|
||||
let s = hex::encode(csum);
|
||||
serializer.serialize_str(&s)
|
||||
}
|
||||
|
||||
@ -37,7 +38,7 @@ mod hex_csum {
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
proxmox::tools::hex_to_digest(&s).map_err(serde::de::Error::custom)
|
||||
<[u8; 32]>::from_hex(&s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +191,7 @@ impl BackupManifest {
|
||||
|
||||
if let Some(crypt_config) = crypt_config {
|
||||
let sig = self.signature(crypt_config)?;
|
||||
manifest["signature"] = proxmox::tools::digest_to_hex(&sig).into();
|
||||
manifest["signature"] = hex::encode(&sig).into();
|
||||
let fingerprint = &Fingerprint::new(crypt_config.fingerprint());
|
||||
manifest["unprotected"]["key-fingerprint"] = serde_json::to_value(fingerprint)?;
|
||||
}
|
||||
@ -240,7 +241,7 @@ impl BackupManifest {
|
||||
|
||||
if let Some(ref crypt_config) = crypt_config {
|
||||
if let Some(signature) = signature {
|
||||
let expected_signature = proxmox::tools::digest_to_hex(&Self::json_signature(&json, crypt_config)?);
|
||||
let expected_signature = hex::encode(&Self::json_signature(&json, crypt_config)?);
|
||||
|
||||
let fingerprint = &json["unprotected"]["key-fingerprint"];
|
||||
if fingerprint != &Value::Null {
|
||||
@ -318,7 +319,7 @@ fn test_manifest_signature() -> Result<(), Error> {
|
||||
assert_eq!(signature, "d7b446fb7db081662081d4b40fedd858a1d6307a5aff4ecff7d5bf4fd35679e9");
|
||||
|
||||
let manifest: BackupManifest = serde_json::from_value(manifest)?;
|
||||
let expected_signature = proxmox::tools::digest_to_hex(&manifest.signature(&crypt_config)?);
|
||||
let expected_signature = hex::encode(&manifest.signature(&crypt_config)?);
|
||||
|
||||
assert_eq!(signature, expected_signature);
|
||||
|
||||
|
@ -247,7 +247,7 @@ fn generate_qr_code(output_type: &str, lines: &[String]) -> Result<Vec<u8>, Erro
|
||||
.wait_with_output()
|
||||
.map_err(|_| format_err!("Failed to read stdout"))?;
|
||||
|
||||
let output = pbs_tools::command_output(output, None)?;
|
||||
let output = proxmox_sys::command::command_output(output, None)?;
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
|
@ -6,13 +6,14 @@ use std::fs::File;
|
||||
use anyhow::{bail, Error};
|
||||
use nix::dir::Dir;
|
||||
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
|
||||
use crate::backup_info::BackupDir;
|
||||
use crate::index::IndexFile;
|
||||
use crate::fixed_index::FixedIndexReader;
|
||||
use crate::dynamic_index::DynamicIndexReader;
|
||||
use crate::manifest::{archive_type, ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
|
||||
use crate::DataStore;
|
||||
use pbs_tools::fs::lock_dir_noblock_shared;
|
||||
|
||||
/// Helper to access the contents of a datastore backup snapshot
|
||||
///
|
||||
|
Reference in New Issue
Block a user