update to first proxmox crate split

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-10-08 11:19:37 +02:00
parent e3f3359c86
commit 6ef1b649d9
265 changed files with 880 additions and 1036 deletions

View File

@ -58,6 +58,7 @@ thiserror = "1.0"
futures = "0.3"
h2 = { version = "0.3", features = [ "stream" ] }
handlebars = "3.0"
hex = "0.4.3"
http = "0.2"
hyper = { version = "0.14", features = [ "full" ] }
lazy_static = "1.4"
@ -96,11 +97,20 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
pathpatterns = "0.1.2"
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
proxmox = { version = "0.14.0", features = [ "sortable-macro", "api-macro", "cli", "router", "tfa" ] }
proxmox-acme-rs = "0.2.1"
proxmox-apt = "0.7.0"
proxmox = { version = "0.14.0", features = [ "sortable-macro" ] }
proxmox-http = { version = "0.5.0", features = [ "client", "http-helpers", "websocket" ] }
proxmox-openid = "0.7.0"
proxmox-io = "1"
proxmox-lang = "1"
proxmox-router = { version = "1", features = [ "cli" ] }
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-section-config = "1"
proxmox-tfa = { version = "1", features = [ "u2f" ] }
proxmox-time = "1"
proxmox-uuid = "1"
proxmox-acme-rs = "0.2.1"
proxmox-apt = "0.8.0"
proxmox-openid = "0.8.0"
pbs-api-types = { path = "pbs-api-types" }
pbs-buildcfg = { path = "pbs-buildcfg" }

View File

@ -1,4 +1,4 @@
use anyhow::{Error};
use anyhow::Error;
// chacha20-poly1305

View File

@ -1,6 +1,7 @@
use anyhow::{Error};
use proxmox::api::{*, cli::*};
use proxmox_schema::*;
use proxmox_router::cli::*;
#[api(
input: {

View File

@ -1,6 +1,6 @@
use std::io::Write;
use anyhow::{Error};
use anyhow::Error;
use pbs_api_types::Authid;
use pbs_client::{HttpClient, HttpClientOptions, BackupReader};
@ -34,7 +34,7 @@ async fn run() -> Result<(), Error> {
let client = HttpClient::new(host, 8007, auth_id, options)?;
let backup_time = proxmox::tools::time::parse_rfc3339("2019-06-28T10:49:48Z")?;
let backup_time = proxmox_time::parse_rfc3339("2019-06-28T10:49:48Z")?;
let client = BackupReader::start(client, None, "store2", "host", "elsa", backup_time, true)
.await?;

View File

@ -1,9 +1,9 @@
use anyhow::{bail, Error};
use std::thread;
use std::path::PathBuf;
use std::io::Write;
use anyhow::{bail, Error};
// tar handle files that shrink during backup, by simply padding with zeros.
//
// this binary run multiple thread which writes some large files, then truncates

View File

@ -16,7 +16,7 @@ async fn upload_speed() -> Result<f64, Error> {
let client = HttpClient::new(host, 8007, auth_id, options)?;
let backup_time = proxmox::tools::time::epoch_i64();
let backup_time = proxmox_time::epoch_i64();
let client = BackupWriter::start(client, None, datastore, "host", "speedtest", backup_time, false, true).await?;

View File

@ -14,7 +14,11 @@ openssl = "0.10"
regex = "1.2"
serde = { version = "1.0", features = ["derive"] }
proxmox = "0.14.0"
proxmox-lang = "1.0.0"
proxmox-schema = { version = "1.0.0", features = [ "api-macro" ] }
proxmox-time = "1.0.0"
proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
proxmox-rrd-api-types = { path = "../proxmox-rrd-api-types" }
proxmox-systemd = { path = "../proxmox-systemd" }

View File

@ -1,13 +1,12 @@
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use serde::de::{value, IntoDeserializer};
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox::api::schema::{
ApiStringFormat, BooleanSchema, EnumEntry, Schema, StringSchema,
use proxmox_lang::constnamedbitmap;
use proxmox_schema::{
api, const_regex, ApiStringFormat, BooleanSchema, EnumEntry, Schema, StringSchema,
};
use proxmox::{constnamedbitmap, const_regex};
const_regex! {
pub ACL_PATH_REGEX = concat!(r"^(?:/|", r"(?:/", PROXMOX_SAFE_ID_REGEX_STR!(), ")+", r")$");
@ -222,7 +221,6 @@ pub enum Role {
TapeReader = ROLE_TAPE_READER,
}
impl FromStr for Role {
type Err = value::Error;
@ -231,26 +229,24 @@ impl FromStr for Role {
}
}
pub const ACL_PATH_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&ACL_PATH_REGEX);
pub const ACL_PATH_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&ACL_PATH_REGEX);
pub const ACL_PATH_SCHEMA: Schema = StringSchema::new(
"Access control path.")
pub const ACL_PATH_SCHEMA: Schema = StringSchema::new("Access control path.")
.format(&ACL_PATH_FORMAT)
.min_length(1)
.max_length(128)
.schema();
pub const ACL_PROPAGATE_SCHEMA: Schema = BooleanSchema::new(
"Allow to propagate (inherit) permissions.")
.default(true)
.schema();
pub const ACL_PROPAGATE_SCHEMA: Schema =
BooleanSchema::new("Allow to propagate (inherit) permissions.")
.default(true)
.schema();
pub const ACL_UGID_TYPE_SCHEMA: Schema = StringSchema::new(
"Type of 'ugid' property.")
pub const ACL_UGID_TYPE_SCHEMA: Schema = StringSchema::new("Type of 'ugid' property.")
.format(&ApiStringFormat::Enum(&[
EnumEntry::new("user", "User"),
EnumEntry::new("group", "Group")]))
EnumEntry::new("group", "Group"),
]))
.schema();
#[api(

View File

@ -3,7 +3,7 @@ use std::fmt::{self, Display};
use anyhow::Error;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
use pbs_tools::format::{as_fingerprint, bytes_as_fingerprint};

View File

@ -1,13 +1,10 @@
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox::api::schema::{
ApiStringFormat, ApiType, ArraySchema, EnumEntry, IntegerSchema, ReturnType, Schema,
StringSchema, Updater,
use proxmox_schema::{
api, const_regex, ApiStringFormat, ApiType, ArraySchema, EnumEntry, IntegerSchema, ReturnType,
Schema, StringSchema, Updater,
};
use proxmox::const_regex;
use crate::{
PROXMOX_SAFE_ID_FORMAT, SHA256_HEX_REGEX, SINGLE_LINE_COMMENT_SCHEMA, CryptMode, UPID,
Fingerprint, Userid, Authid,

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
#[api]
#[derive(Serialize, Deserialize)]

View File

@ -1,8 +1,6 @@
use serde::{Deserialize, Serialize};
use proxmox::const_regex;
use proxmox::api::{api, schema::*};
use proxmox_schema::*;
use crate::{
Userid, Authid, REMOTE_ID_SCHEMA, DRIVE_NAME_SCHEMA, MEDIA_POOL_NAME_SCHEMA,

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
use crate::CERT_FINGERPRINT_SHA256_SCHEMA;

View File

@ -3,9 +3,9 @@
use serde::{Deserialize, Serialize};
use anyhow::bail;
use proxmox::api::api;
use proxmox::api::schema::{ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, ReturnType};
use proxmox::const_regex;
use proxmox_schema::{
api, const_regex, ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, ReturnType,
};
use proxmox::{IPRE, IPRE_BRACKET, IPV4OCTET, IPV4RE, IPV6H16, IPV6LS32, IPV6RE};
#[rustfmt::skip]
@ -60,7 +60,7 @@ pub use userid::{PROXMOX_GROUP_ID_SCHEMA, PROXMOX_TOKEN_ID_SCHEMA, PROXMOX_TOKEN
mod user;
pub use user::*;
pub use proxmox::api::upid::*;
pub use proxmox_schema::upid::*;
mod crypto;
pub use crypto::{CryptMode, Fingerprint};

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use proxmox::api::{api, schema::*};
use proxmox_schema::*;
use crate::{
PROXMOX_SAFE_ID_REGEX,

View File

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use super::*;
use proxmox::api::{api, schema::*};
use proxmox_schema::*;
pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth token for remote host.")
.format(&PASSWORD_FORMAT)

View File

@ -2,22 +2,11 @@
use serde::{Deserialize, Serialize};
use proxmox::api::{
api,
schema::{
Schema,
ApiStringFormat,
ArraySchema,
IntegerSchema,
StringSchema,
Updater,
},
use proxmox_schema::{
api, ApiStringFormat, ArraySchema, IntegerSchema, Schema, StringSchema, Updater,
};
use crate::{
PROXMOX_SAFE_ID_FORMAT,
OptionalDeviceIdentification,
};
use crate::{OptionalDeviceIdentification, PROXMOX_SAFE_ID_FORMAT};
pub const CHANGER_NAME_SCHEMA: Schema = StringSchema::new("Tape Changer Identifier.")
.format(&PROXMOX_SAFE_ID_FORMAT)
@ -25,9 +14,8 @@ pub const CHANGER_NAME_SCHEMA: Schema = StringSchema::new("Tape Changer Identifi
.max_length(32)
.schema();
pub const SCSI_CHANGER_PATH_SCHEMA: Schema = StringSchema::new(
"Path to Linux generic SCSI device (e.g. '/dev/sg4')")
.schema();
pub const SCSI_CHANGER_PATH_SCHEMA: Schema =
StringSchema::new("Path to Linux generic SCSI device (e.g. '/dev/sg4')").schema();
pub const MEDIA_LABEL_SCHEMA: Schema = StringSchema::new("Media Label/Barcode.")
.format(&PROXMOX_SAFE_ID_FORMAT)
@ -36,16 +24,18 @@ pub const MEDIA_LABEL_SCHEMA: Schema = StringSchema::new("Media Label/Barcode.")
.schema();
pub const SLOT_ARRAY_SCHEMA: Schema = ArraySchema::new(
"Slot list.", &IntegerSchema::new("Slot number")
.minimum(1)
.schema())
.schema();
"Slot list.",
&IntegerSchema::new("Slot number").minimum(1).schema(),
)
.schema();
pub const EXPORT_SLOT_LIST_SCHEMA: Schema = StringSchema::new("\
pub const EXPORT_SLOT_LIST_SCHEMA: Schema = StringSchema::new(
"\
A list of slot numbers, comma separated. Those slots are reserved for
Import/Export, i.e. any media in those slots are considered to be
'offline'.
")
",
)
.format(&ApiStringFormat::PropertyString(&SLOT_ARRAY_SCHEMA))
.schema();
@ -63,14 +53,14 @@ Import/Export, i.e. any media in those slots are considered to be
},
},
)]
#[derive(Serialize,Deserialize,Updater)]
#[derive(Serialize, Deserialize, Updater)]
#[serde(rename_all = "kebab-case")]
/// SCSI tape changer
pub struct ScsiTapeChanger {
#[updater(skip)]
pub name: String,
pub path: String,
#[serde(skip_serializing_if="Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub export_slots: Option<String>,
}
@ -84,7 +74,7 @@ pub struct ScsiTapeChanger {
},
},
)]
#[derive(Serialize,Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
/// Changer config with optional device identification attributes
pub struct ChangerListEntry {
@ -95,7 +85,7 @@ pub struct ChangerListEntry {
}
#[api()]
#[derive(Serialize,Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
/// Mtx Entry Kind
pub enum MtxEntryKind {
@ -118,7 +108,7 @@ pub enum MtxEntryKind {
},
},
)]
#[derive(Serialize,Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
/// Mtx Status Entry
pub struct MtxStatusEntry {
@ -126,12 +116,12 @@ pub struct MtxStatusEntry {
/// The ID of the slot or drive
pub entry_id: u64,
/// The media label (volume tag) if the slot/drive is full
#[serde(skip_serializing_if="Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub label_text: Option<String>,
/// The slot the drive was loaded from
#[serde(skip_serializing_if="Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub loaded_slot: Option<u64>,
/// The current state of the drive
#[serde(skip_serializing_if="Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
}

View File

@ -1,6 +1,6 @@
use ::serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
#[api()]
#[derive(Serialize,Deserialize)]

View File

@ -4,10 +4,7 @@ use std::convert::TryFrom;
use anyhow::{bail, Error};
use serde::{Deserialize, Serialize};
use proxmox::api::{
api,
schema::{Schema, IntegerSchema, StringSchema, Updater},
};
use proxmox_schema::{api, Schema, IntegerSchema, StringSchema, Updater};
use crate::{
PROXMOX_SAFE_ID_FORMAT,

View File

@ -1,9 +1,7 @@
use ::serde::{Deserialize, Serialize};
use proxmox::{
api::{api, schema::*},
tools::Uuid,
};
use proxmox_schema::*;
use proxmox_uuid::Uuid;
use crate::{
UUID_FORMAT,

View File

@ -1,18 +1,8 @@
use anyhow::{bail, Error};
use proxmox::api::{
schema::{
Schema,
StringSchema,
ApiStringFormat,
parse_simple_value,
},
};
use proxmox_schema::{parse_simple_value, ApiStringFormat, Schema, StringSchema};
use crate::{
PROXMOX_SAFE_ID_FORMAT,
CHANGER_NAME_SCHEMA,
};
use crate::{CHANGER_NAME_SCHEMA, PROXMOX_SAFE_ID_FORMAT};
pub const VAULT_NAME_SCHEMA: Schema = StringSchema::new("Vault name.")
.format(&PROXMOX_SAFE_ID_FORMAT)
@ -35,28 +25,27 @@ pub enum MediaLocation {
proxmox::forward_deserialize_to_from_str!(MediaLocation);
proxmox::forward_serialize_to_display!(MediaLocation);
impl proxmox::api::schema::ApiType for MediaLocation {
impl proxmox_schema::ApiType for MediaLocation {
const API_SCHEMA: Schema = StringSchema::new(
"Media location (e.g. 'offline', 'online-<changer_name>', 'vault-<vault_name>')")
.format(&ApiStringFormat::VerifyFn(|text| {
let location: MediaLocation = text.parse()?;
match location {
MediaLocation::Online(ref changer) => {
parse_simple_value(changer, &CHANGER_NAME_SCHEMA)?;
}
MediaLocation::Vault(ref vault) => {
parse_simple_value(vault, &VAULT_NAME_SCHEMA)?;
}
MediaLocation::Offline => { /* OK */}
"Media location (e.g. 'offline', 'online-<changer_name>', 'vault-<vault_name>')",
)
.format(&ApiStringFormat::VerifyFn(|text| {
let location: MediaLocation = text.parse()?;
match location {
MediaLocation::Online(ref changer) => {
parse_simple_value(changer, &CHANGER_NAME_SCHEMA)?;
}
Ok(())
}))
.schema();
MediaLocation::Vault(ref vault) => {
parse_simple_value(vault, &VAULT_NAME_SCHEMA)?;
}
MediaLocation::Offline => { /* OK */ }
}
Ok(())
}))
.schema();
}
impl std::fmt::Display for MediaLocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MediaLocation::Offline => {

View File

@ -9,10 +9,7 @@ use std::str::FromStr;
use anyhow::Error;
use serde::{Deserialize, Serialize};
use proxmox::api::{
api,
schema::{Schema, StringSchema, ApiStringFormat, Updater},
};
use proxmox_schema::{api, Schema, StringSchema, ApiStringFormat, Updater};
use proxmox_systemd::time::{parse_calendar_event, parse_time_span, CalendarEvent, TimeSpan};

View File

@ -1,6 +1,6 @@
use ::serde::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
#[api()]
/// Media status

View File

@ -22,13 +22,10 @@ pub use media_location::*;
mod media;
pub use media::*;
use ::serde::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox::api::schema::{Schema, StringSchema, ApiStringFormat};
use proxmox::tools::Uuid;
use proxmox::const_regex;
use proxmox_schema::{api, const_regex, Schema, StringSchema, ApiStringFormat};
use proxmox_uuid::Uuid;
use crate::{
FINGERPRINT_SHA256_FORMAT, BACKUP_ID_SCHEMA, BACKUP_TYPE_SCHEMA,

View File

@ -1,8 +1,7 @@
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox::api::schema::{
BooleanSchema, IntegerSchema, Schema, StringSchema, Updater,
use proxmox_schema::{
api, BooleanSchema, IntegerSchema, Schema, StringSchema, Updater,
};
use super::{SINGLE_LINE_COMMENT_FORMAT, SINGLE_LINE_COMMENT_SCHEMA};
@ -133,7 +132,7 @@ impl ApiToken {
return false;
}
if let Some(expire) = self.expire {
let now = proxmox::tools::time::epoch_i64();
let now = proxmox_time::epoch_i64();
if expire > 0 && expire <= now {
return false;
}
@ -198,7 +197,7 @@ impl User {
return false;
}
if let Some(expire) = self.expire {
let now = proxmox::tools::time::epoch_i64();
let now = proxmox_time::epoch_i64();
if expire > 0 && expire <= now {
return false;
}

View File

@ -29,9 +29,9 @@ use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox::api::schema::{ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType};
use proxmox::const_regex;
use proxmox_schema::{
api, const_regex, ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType,
};
// we only allow a limited set of characters
// colon is not allowed, because we store usernames in

View File

@ -1,8 +1,6 @@
use serde::{Deserialize, Serialize};
use proxmox::api::{api, schema::*};
use proxmox::const_regex;
use proxmox_schema::*;
const_regex! {
pub ZPOOL_NAME_REGEX = r"^[a-zA-Z][a-z0-9A-Z\-_.:]+$";

View File

@ -28,9 +28,14 @@ tower-service = "0.3.0"
xdg = "2.2"
pathpatterns = "0.1.2"
proxmox = { version = "0.14.0", default-features = false, features = [ "cli" ] }
proxmox = "0.14.0"
proxmox-fuse = "0.1.1"
proxmox-http = { version = "0.5.0", features = [ "client", "http-helpers", "websocket" ] }
proxmox-io = { version = "1", features = [ "tokio" ] }
proxmox-lang = "1"
proxmox-router = { version = "1", features = [ "cli" ] }
proxmox-schema = "1"
proxmox-time = "1"
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
pbs-api-types = { path = "../pbs-api-types" }

View File

@ -1,8 +1,8 @@
use anyhow::{bail, Error};
use proxmox::api::schema::*;
use proxmox_schema::*;
proxmox::const_regex! {
const_regex! {
BACKUPSPEC_REGEX = r"^([a-zA-Z0-9_-]+\.(pxar|img|conf|log)):(.+)$";
}

View File

@ -13,9 +13,9 @@ use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
use pathpatterns::{MatchEntry, MatchList, MatchPattern, MatchType, PatternFlag};
use proxmox::api::api;
use proxmox::api::cli::{self, CliCommand, CliCommandMap, CliHelper, CommandLineInterface};
use proxmox::tools::fs::{create_path, CreateOptions};
use proxmox_router::cli::{self, CliCommand, CliCommandMap, CliHelper, CommandLineInterface};
use proxmox_schema::api;
use pxar::{EntryKind, Metadata};
use pbs_runtime::block_in_place;

View File

@ -15,10 +15,10 @@ use percent_encoding::percent_encode;
use xdg::BaseDirectories;
use proxmox::{
api::error::HttpError,
sys::linux::tty,
tools::fs::{file_get_json, replace_file, CreateOptions},
};
use proxmox_router::HttpError;
use proxmox_http::client::HttpsConnector;
use proxmox_http::uri::build_authority;
@ -230,7 +230,7 @@ fn store_ticket_info(prefix: &str, server: &str, username: &str, ticket: &str, t
let mut data = file_get_json(&path, Some(json!({})))?;
let now = proxmox::tools::time::epoch_i64();
let now = proxmox_time::epoch_i64();
data[server][username] = json!({ "timestamp": now, "ticket": ticket, "token": token});
@ -261,7 +261,7 @@ fn load_ticket_info(prefix: &str, server: &str, userid: &Userid) -> Option<(Stri
// usually /run/user/<uid>/...
let path = base.place_runtime_file("tickets").ok()?;
let data = file_get_json(&path, None).ok()?;
let now = proxmox::tools::time::epoch_i64();
let now = proxmox_time::epoch_i64();
let ticket_lifetime = ticket::TICKET_LIFETIME - 60;
let uinfo = data[server][userid.as_str()].as_object()?;
let timestamp = uinfo["timestamp"].as_i64()?;

View File

@ -19,11 +19,11 @@ use pathpatterns::{MatchEntry, MatchFlag, MatchList, MatchType, PatternFlag};
use pxar::Metadata;
use pxar::encoder::{SeqWrite, LinkOffset};
use proxmox::c_str;
use proxmox::sys::error::SysError;
use proxmox::tools::fd::RawFdNum;
use proxmox::tools::vec;
use proxmox::tools::fd::Fd;
use proxmox_io::vec;
use proxmox_lang::c_str;
use pbs_datastore::catalog::BackupCatalogWriter;
use pbs_tools::{acl, fs, xattr};

View File

@ -22,10 +22,8 @@ use pxar::format::Device;
use pxar::{Entry, EntryKind, Metadata};
use proxmox::c_result;
use proxmox::tools::{
fs::{create_path, CreateOptions},
io::{sparse_copy, sparse_copy_async},
};
use proxmox::tools::fs::{create_path, CreateOptions};
use proxmox_io::{sparse_copy, sparse_copy_async};
use pbs_tools::zip::{ZipEncoder, ZipEntry};

View File

@ -20,7 +20,7 @@ use futures::select;
use futures::sink::SinkExt;
use futures::stream::{StreamExt, TryStreamExt};
use proxmox::tools::vec;
use proxmox_io::vec;
use pxar::accessor::{self, EntryRangeInfo, ReadAt};
use proxmox_fuse::requests::{self, FuseRequest};

View File

@ -115,7 +115,7 @@ fn mode_string(entry: &Entry) -> String {
}
fn format_mtime(mtime: &StatxTimestamp) -> String {
if let Ok(s) = proxmox::tools::time::strftime_local("%Y-%m-%d %H:%M:%S", mtime.secs) {
if let Ok(s) = proxmox_time::strftime_local("%Y-%m-%d %H:%M:%S", mtime.secs) {
return s;
}
format!("{}.{}", mtime.secs, mtime.nanos)

View File

@ -5,7 +5,7 @@ use serde_json::{json, Value};
use tokio::signal::unix::{signal, SignalKind};
use futures::*;
use proxmox::api::cli::format_and_print_result;
use proxmox_router::cli::format_and_print_result;
use pbs_tools::percent_encoding::percent_encode_component;

View File

@ -6,9 +6,9 @@ use std::io::Read;
use anyhow::{bail, format_err, Error};
use serde_json::Value;
use proxmox::api::schema::*;
use proxmox::sys::linux::tty;
use proxmox::tools::fs::file_get_contents;
use proxmox_schema::*;
use pbs_api_types::CryptMode;

View File

@ -10,11 +10,9 @@ use anyhow::{bail, format_err, Context, Error};
use serde_json::{json, Value};
use xdg::BaseDirectories;
use proxmox::{
api::schema::*,
api::cli::shellword_split,
tools::fs::file_get_json,
};
use proxmox_schema::*;
use proxmox_router::cli::shellword_split;
use proxmox::tools::fs::file_get_json;
use pbs_api_types::{BACKUP_REPO_URL, Authid, UserWithTokens};
use pbs_datastore::BackupDir;

View File

@ -13,7 +13,7 @@ use serde_json::Value;
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf};
use tokio::net::UnixStream;
use proxmox::api::error::HttpError;
use proxmox_router::HttpError;
pub const DEFAULT_VSOCK_PORT: u16 = 807;

View File

@ -6,17 +6,23 @@ edition = "2018"
description = "Configuration file management for PBS"
[dependencies]
libc = "0.2"
anyhow = "1.0"
hex = "0.4.3"
lazy_static = "1.4"
libc = "0.2"
nix = "0.19.1"
once_cell = "1.3.1"
openssl = "0.10"
regex = "1.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
openssl = "0.10"
nix = "0.19.1"
regex = "1.2"
once_cell = "1.3.1"
proxmox = { version = "0.14.0", default-features = false, features = [ "cli" ] }
proxmox = "0.14.0"
proxmox-lang = "1"
proxmox-router = "1"
proxmox-schema = "1"
proxmox-section-config = "1"
proxmox-time = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-buildcfg = { path = "../pbs-buildcfg" }

View File

@ -8,7 +8,7 @@ use anyhow::{bail, Error};
use lazy_static::lazy_static;
use proxmox::api::schema::{Schema, StringSchema, ApiStringFormat, ApiType};
use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema};
use pbs_api_types::{Authid, Userid, Role, ROLE_NAME_NO_ACCESS};

View File

@ -3,11 +3,11 @@
use std::sync::{RwLock, Arc};
use anyhow::{Error, bail};
use proxmox::api::section_config::SectionConfigData;
use lazy_static::lazy_static;
use proxmox::api::UserInformation;
use proxmox::tools::time::epoch_i64;
use proxmox_router::UserInformation;
use proxmox_section_config::SectionConfigData;
use proxmox_time::epoch_i64;
use pbs_api_types::{Authid, Userid, User, ApiToken, ROLE_ADMIN};

View File

@ -2,14 +2,8 @@ use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use proxmox::api::{
schema::{ApiType, Schema},
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use proxmox_schema::{ApiType, Schema};
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{DataStoreConfig, DATASTORE_SCHEMA};

View File

@ -1,17 +1,11 @@
use std::collections::HashMap;
use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use proxmox::api::{
api,
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use proxmox_schema::{api, ApiType, Updater, Schema};
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA};
use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
@ -59,7 +53,7 @@ pub enum OpenIdUserAttribute {
},
},
)]
#[derive(Serialize,Deserialize,Updater)]
#[derive(Serialize, Deserialize, Updater)]
#[serde(rename_all="kebab-case")]
/// OpenID configuration properties.
pub struct OpenIdRealmConfig {

View File

@ -16,16 +16,8 @@ use std::collections::HashMap;
use anyhow::{bail, Error};
use lazy_static::lazy_static;
use proxmox::{
api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
},
},
};
use proxmox_schema::*;
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};

View File

@ -5,7 +5,7 @@ use anyhow::{bail, format_err, Context, Error};
use serde::{Deserialize, Serialize};
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox::try_block;
use proxmox_lang::try_block;
use pbs_api_types::{Kdf, KeyInfo, Fingerprint};
@ -122,7 +122,7 @@ impl KeyConfig {
let crypt_config = CryptConfig::new(raw_key.clone())?;
let fingerprint = Some(Fingerprint::new(crypt_config.fingerprint()));
let created = proxmox::tools::time::epoch_i64();
let created = proxmox_time::epoch_i64();
Ok(Self {
kdf: None,
created,
@ -183,7 +183,7 @@ impl KeyConfig {
enc_data.extend_from_slice(&tag);
enc_data.extend_from_slice(&encrypted_key);
let created = proxmox::tools::time::epoch_i64();
let created = proxmox_time::epoch_i64();
// always compute fingerprint
let crypt_config = CryptConfig::new(raw_key.clone())?;
@ -370,8 +370,8 @@ fn encrypt_decrypt_test() -> Result<(), Error> {
let key = KeyConfig {
kdf: None,
created: proxmox::tools::time::epoch_i64(),
modified: proxmox::tools::time::epoch_i64(),
created: proxmox_time::epoch_i64(),
modified: proxmox_time::epoch_i64(),
data: (0u8..32u8).collect(),
fingerprint: Some(Fingerprint::new([
14, 171, 212, 70, 11, 110, 185, 202, 52, 80, 35, 222, 226, 183, 120, 199, 144, 229, 74,
@ -396,8 +396,8 @@ fn encrypt_decrypt_test() -> Result<(), Error> {
fn fingerprint_checks() -> Result<(), Error> {
let key = KeyConfig {
kdf: None,
created: proxmox::tools::time::epoch_i64(),
modified: proxmox::tools::time::epoch_i64(),
created: proxmox_time::epoch_i64(),
modified: proxmox_time::epoch_i64(),
data: (0u8..32u8).collect(),
fingerprint: Some(Fingerprint::new([0u8; 32])), // wrong FP
hint: None,
@ -413,8 +413,8 @@ fn fingerprint_checks() -> Result<(), Error> {
let key = KeyConfig {
kdf: None,
created: proxmox::tools::time::epoch_i64(),
modified: proxmox::tools::time::epoch_i64(),
created: proxmox_time::epoch_i64(),
modified: proxmox_time::epoch_i64(),
data: (0u8..32u8).collect(),
fingerprint: None,
hint: None,

View File

@ -4,23 +4,15 @@
//! provides a type safe interface to store [`MediaPoolConfig`],
//!
//! [MediaPoolConfig]: crate::api2::types::MediaPoolConfig
//! [SectionConfig]: proxmox::api::section_config::SectionConfig
//! [SectionConfig]: proxmox_section_config::SectionConfig
use std::collections::HashMap;
use anyhow::Error;
use lazy_static::lazy_static;
use proxmox::{
api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
},
};
use proxmox_schema::*;
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{MEDIA_POOL_NAME_SCHEMA, MediaPoolConfig};

View File

@ -1,15 +1,10 @@
use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use proxmox::api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use anyhow::Error;
use lazy_static::lazy_static;
use proxmox_schema::*;
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{Remote, REMOTE_ID_SCHEMA};

View File

@ -1,15 +1,10 @@
use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use proxmox::api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use anyhow::Error;
use lazy_static::lazy_static;
use proxmox_schema::{ApiType, Schema};
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{JOB_ID_SCHEMA, SyncJobConfig};

View File

@ -2,14 +2,8 @@ use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use proxmox::api::{
schema::{Schema, ApiType},
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use proxmox_schema::{Schema, ApiType};
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{TapeBackupJobConfig, JOB_ID_SCHEMA};

View File

@ -4,14 +4,8 @@ use std::sync::{Arc, RwLock};
use anyhow::{bail, Error};
use lazy_static::lazy_static;
use proxmox::api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use proxmox_schema::*;
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{
Authid, Userid, ApiToken, User,

View File

@ -1,15 +1,10 @@
use anyhow::{Error};
use lazy_static::lazy_static;
use std::collections::HashMap;
use proxmox::api::{
schema::*,
section_config::{
SectionConfig,
SectionConfigData,
SectionConfigPlugin,
}
};
use anyhow::Error;
use lazy_static::lazy_static;
use proxmox_schema::*;
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
use pbs_api_types::{JOB_ID_SCHEMA, VerificationJobConfig};

View File

@ -25,7 +25,12 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
pathpatterns = "0.1.2"
pxar = "0.10.1"
proxmox = { version = "0.14.0", default-features = false, features = [ "api-macro" ] }
proxmox = "0.14.0"
proxmox-io = "1"
proxmox-lang = "1"
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-time = "1"
proxmox-uuid = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-tools = { path = "../pbs-tools" }

View File

@ -138,7 +138,7 @@ impl BackupGroup {
}
}
let timestamp = proxmox::tools::time::parse_rfc3339(backup_time)?;
let timestamp = proxmox_time::parse_rfc3339(backup_time)?;
if let Some(last_timestamp) = last {
if timestamp > last_timestamp {
last = Some(timestamp);
@ -215,7 +215,7 @@ impl BackupDir {
V: Into<String>,
{
let backup_time_string = backup_time_string.into();
let backup_time = proxmox::tools::time::parse_rfc3339(&backup_time_string)?;
let backup_time = proxmox_time::parse_rfc3339(&backup_time_string)?;
let group = BackupGroup::new(backup_type.into(), backup_id.into());
Ok(Self {
group,
@ -255,7 +255,7 @@ impl BackupDir {
pub fn backup_time_to_string(backup_time: i64) -> Result<String, Error> {
// fixme: can this fail? (avoid unwrap)
proxmox::tools::time::epoch_to_rfc3339_utc(backup_time)
Ok(proxmox_time::epoch_to_rfc3339_utc(backup_time)?)
}
}

View File

@ -8,8 +8,9 @@ use anyhow::{bail, format_err, Error};
use serde::{Deserialize, Serialize};
use pathpatterns::{MatchList, MatchType};
use proxmox::api::api;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use proxmox_schema::api;
use crate::file_formats::PROXMOX_CATALOG_FILE_MAGIC_1_0;
@ -570,7 +571,7 @@ impl <R: Read + Seek> CatalogReader<R> {
}
CatalogEntryType::File => {
let mut mtime_string = mtime.to_string();
if let Ok(s) = proxmox::tools::time::strftime_local("%FT%TZ", mtime as i64) {
if let Ok(s) = proxmox_time::strftime_local("%FT%TZ", mtime as i64) {
mtime_string = s;
}

View File

@ -4,7 +4,7 @@ use std::io::Write;
use anyhow::{bail, Error};
use openssl::symm::{decrypt_aead, Mode};
use proxmox::tools::io::{ReadExt, WriteExt};
use proxmox_io::{ReadExt, WriteExt};
use pbs_tools::crypt_config::CryptConfig;
use pbs_api_types::CryptMode;
@ -58,13 +58,13 @@ impl DataBlob {
/// accessor to crc32 checksum
pub fn crc(&self) -> u32 {
let crc_o = proxmox::offsetof!(DataBlobHeader, crc);
let crc_o = proxmox_lang::offsetof!(DataBlobHeader, crc);
u32::from_le_bytes(self.raw_data[crc_o..crc_o+4].try_into().unwrap())
}
// set the CRC checksum field
pub fn set_crc(&mut self, crc: u32) {
let crc_o = proxmox::offsetof!(DataBlobHeader, crc);
let crc_o = proxmox_lang::offsetof!(DataBlobHeader, crc);
self.raw_data[crc_o..crc_o+4].copy_from_slice(&crc.to_le_bytes());
}

View File

@ -2,7 +2,8 @@ use std::io::{BufReader, Read};
use std::sync::Arc;
use anyhow::{bail, format_err, Error};
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_tools::crypt_config::CryptConfig;

View File

@ -1,8 +1,10 @@
use anyhow::Error;
use proxmox::tools::io::WriteExt;
use std::io::{Seek, SeekFrom, Write};
use std::sync::Arc;
use anyhow::Error;
use proxmox_io::WriteExt;
use pbs_tools::crypt_config::CryptConfig;
use crate::checksum_writer::ChecksumWriter;

View File

@ -620,7 +620,7 @@ impl DataStore {
// writer" information and thus no safe atime cutoff
let _exclusive_lock = self.chunk_store.try_exclusive_lock()?;
let phase1_start_time = proxmox::tools::time::epoch_i64();
let phase1_start_time = proxmox_time::epoch_i64();
let oldest_writer = self.chunk_store.oldest_writer().unwrap_or(phase1_start_time);
let mut gc_status = GarbageCollectionStatus::default();
@ -742,7 +742,7 @@ impl DataStore {
path.push(backup_dir.relative_path());
path.push(filename);
proxmox::try_block!({
proxmox_lang::try_block!({
let mut file = std::fs::File::open(&path)?;
DataBlob::load_from_reader(&mut file)
}).map_err(|err| format_err!("unable to load blob '{:?}' - {}", path, err))
@ -758,7 +758,7 @@ impl DataStore {
let (chunk_path, digest_str) = self.chunk_store.chunk_path(digest);
proxmox::try_block!({
proxmox_lang::try_block!({
let mut file = std::fs::File::open(&chunk_path)?;
DataBlob::load_from_reader(&mut file)
}).map_err(|err| format_err!(

View File

@ -9,9 +9,9 @@ use std::task::Context;
use anyhow::{bail, format_err, Error};
use proxmox::tools::io::ReadExt;
use proxmox::tools::uuid::Uuid;
use proxmox::tools::mmap::Mmap;
use proxmox_io::ReadExt;
use proxmox_uuid::Uuid;
use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use pbs_tools::lru_cache::LruCache;
@ -35,7 +35,7 @@ pub struct DynamicIndexHeader {
pub index_csum: [u8; 32],
reserved: [u8; 4032], // overall size is one page (4096 bytes)
}
proxmox::static_assert_size!(DynamicIndexHeader, 4096);
proxmox_lang::static_assert_size!(DynamicIndexHeader, 4096);
// TODO: Once non-Copy unions are stabilized, use:
// union DynamicIndexHeader {
// reserved: [u8; 4096],
@ -119,7 +119,7 @@ impl DynamicIndexReader {
bail!("got unknown magic number");
}
let ctime = proxmox::tools::time::epoch_i64();
let ctime = proxmox_time::epoch_i64();
let index_size = stat.st_size as usize - header_size;
let index_count = index_size / 40;
@ -301,7 +301,7 @@ impl DynamicIndexWriter {
let mut writer = BufWriter::with_capacity(1024 * 1024, file);
let ctime = proxmox::tools::time::epoch_i64();
let ctime = proxmox_time::epoch_i64();
let uuid = Uuid::generate();
@ -344,7 +344,7 @@ impl DynamicIndexWriter {
self.writer.flush()?;
let csum_offset = proxmox::offsetof!(DynamicIndexHeader, index_csum);
let csum_offset = proxmox_lang::offsetof!(DynamicIndexHeader, index_csum);
self.writer.seek(SeekFrom::Start(csum_offset as u64))?;
let csum = self.csum.take().unwrap();

View File

@ -9,8 +9,8 @@ use anyhow::{bail, format_err, Error};
use pbs_tools::process_locker::ProcessLockSharedGuard;
use proxmox::tools::io::ReadExt;
use proxmox::tools::Uuid;
use proxmox_io::ReadExt;
use proxmox_uuid::Uuid;
use crate::chunk_stat::ChunkStat;
use crate::chunk_store::ChunkStore;
@ -30,7 +30,7 @@ pub struct FixedIndexHeader {
pub chunk_size: u64,
reserved: [u8; 4016], // overall size is one page (4096 bytes)
}
proxmox::static_assert_size!(FixedIndexHeader, 4096);
proxmox_lang::static_assert_size!(FixedIndexHeader, 4096);
// split image into fixed size chunks
@ -149,7 +149,7 @@ impl FixedIndexReader {
println!("ChunkSize: {}", self.chunk_size);
let mut ctime_str = self.ctime.to_string();
if let Ok(s) = proxmox::tools::time::strftime_local("%c", self.ctime) {
if let Ok(s) = proxmox_time::strftime_local("%c", self.ctime) {
ctime_str = s;
}
@ -281,7 +281,7 @@ impl FixedIndexWriter {
panic!("got unexpected header size");
}
let ctime = proxmox::tools::time::epoch_i64();
let ctime = proxmox_time::epoch_i64();
let uuid = Uuid::generate();
@ -361,7 +361,7 @@ impl FixedIndexWriter {
self.unmap()?;
let csum_offset = proxmox::offsetof!(FixedIndexHeader, index_csum);
let csum_offset = proxmox_lang::offsetof!(FixedIndexHeader, index_csum);
self.file.seek(SeekFrom::Start(csum_offset as u64))?;
self.file.write_all(&index_csum)?;
self.file.flush()?;

View File

@ -4,7 +4,7 @@ use std::process::{Command, Stdio};
use anyhow::{bail, format_err, Error};
use serde::{Deserialize, Serialize};
use proxmox::api::api;
use proxmox_schema::api;
use pbs_config::key_config::KeyConfig;

View File

@ -135,17 +135,17 @@ pub fn compute_prune_info(
})?;
}
use proxmox::tools::time::strftime_local;
use proxmox_time::strftime_local;
if let Some(keep_hourly) = options.keep_hourly {
mark_selections(&mut mark, &list, keep_hourly as usize, |info| {
strftime_local("%Y/%m/%d/%H", info.backup_dir.backup_time())
strftime_local("%Y/%m/%d/%H", info.backup_dir.backup_time()).map_err(Error::from)
})?;
}
if let Some(keep_daily) = options.keep_daily {
mark_selections(&mut mark, &list, keep_daily as usize, |info| {
strftime_local("%Y/%m/%d", info.backup_dir.backup_time())
strftime_local("%Y/%m/%d", info.backup_dir.backup_time()).map_err(Error::from)
})?;
}
@ -153,19 +153,19 @@ pub fn compute_prune_info(
mark_selections(&mut mark, &list, keep_weekly as usize, |info| {
// Note: Use iso-week year/week here. This year number
// might not match the calendar year number.
strftime_local("%G/%V", info.backup_dir.backup_time())
strftime_local("%G/%V", info.backup_dir.backup_time()).map_err(Error::from)
})?;
}
if let Some(keep_monthly) = options.keep_monthly {
mark_selections(&mut mark, &list, keep_monthly as usize, |info| {
strftime_local("%Y/%m", info.backup_dir.backup_time())
strftime_local("%Y/%m", info.backup_dir.backup_time()).map_err(Error::from)
})?;
}
if let Some(keep_yearly) = options.keep_yearly {
mark_selections(&mut mark, &list, keep_yearly as usize, |info| {
strftime_local("%Y", info.backup_dir.backup_time())
strftime_local("%Y", info.backup_dir.backup_time()).map_err(Error::from)
})?;
}

View File

@ -107,7 +107,7 @@ impl <'a> Iterator for SnapshotChunkIterator<'a> {
type Item = Result<[u8; 32], Error>;
fn next(&mut self) -> Option<Self::Item> {
proxmox::try_block!({
proxmox_lang::try_block!({
loop {
if self.current_index.is_none() {
if let Some(filename) = self.todo_list.pop() {

View File

@ -14,7 +14,7 @@ nix = "0.19.1"
regex = "1.2"
tokio = { version = "1.6", features = [] }
proxmox = "0.14.0"
proxmox-time = "1"
proxmox-fuse = "0.1.1"
pbs-tools = { path = "../pbs-tools" }

View File

@ -1,29 +1,29 @@
//! Map a raw data reader as a loop device via FUSE
use anyhow::{Error, format_err, bail};
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::fs::{File, remove_file, read_to_string, OpenOptions};
use std::io::SeekFrom;
use std::io::prelude::*;
use anyhow::{bail, format_err, Error};
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::{read_to_string, remove_file, File, OpenOptions};
use std::io::prelude::*;
use std::io::SeekFrom;
use std::path::{Path, PathBuf};
use nix::unistd::Pid;
use nix::sys::signal::{self, Signal};
use nix::unistd::Pid;
use regex::Regex;
use tokio::io::{AsyncRead, AsyncSeek, AsyncReadExt, AsyncSeekExt};
use futures::channel::mpsc::{Receiver, Sender};
use futures::stream::{StreamExt, TryStreamExt};
use futures::channel::mpsc::{Sender, Receiver};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncSeek, AsyncSeekExt};
use proxmox::const_regex;
use proxmox::tools::time;
use proxmox_fuse::{*, requests::FuseRequest};
use super::loopdev;
use proxmox_fuse::{requests::FuseRequest, *};
use proxmox_time::epoch_i64;
const RUN_DIR: &str = "/run/pbs-loopdev";
const_regex! {
pub LOOPDEV_REGEX = r"^loop\d+$";
lazy_static::lazy_static! {
static ref LOOPDEV_REGEX: Regex = Regex::new(r"^loop\d+$").unwrap();
}
/// Represents an ongoing FUSE-session that has been mapped onto a loop device.
@ -40,12 +40,14 @@ pub struct FuseLoopSession<R: AsyncRead + AsyncSeek + Unpin> {
}
impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
/// Prepare for mapping the given reader as a block device node at
/// /dev/loopN. Creates a temporary file for FUSE and a PID file for unmap.
pub async fn map_loop<P: AsRef<str>>(size: u64, mut reader: R, name: P, options: &OsStr)
-> Result<Self, Error>
{
pub async fn map_loop<P: AsRef<str>>(
size: u64,
mut reader: R,
name: P,
options: &OsStr,
) -> Result<Self, Error> {
// attempt a single read to check if the reader is configured correctly
let _ = reader.read_u8().await?;
@ -61,14 +63,14 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
cleanup_unused_run_files(Some(name.as_ref().to_owned()));
match OpenOptions::new().write(true).create_new(true).open(&path) {
Ok(_) => { /* file created, continue on */ },
Ok(_) => { /* file created, continue on */ }
Err(e) => {
if e.kind() == std::io::ErrorKind::AlreadyExists {
bail!("the given archive is already mapped, cannot map twice");
} else {
bail!("error while creating backing file ({:?}) - {}", &path, e);
}
},
}
}
let session = Fuse::builder("pbs-block-dev")?
@ -77,9 +79,8 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
.build()?
.mount(&path)?;
let loopdev_path = loopdev::get_or_create_free_dev().map_err(|err| {
format_err!("loop-control GET_FREE failed - {}", err)
})?;
let loopdev_path = loopdev::get_or_create_free_dev()
.map_err(|err| format_err!("loop-control GET_FREE failed - {}", err))?;
// write pidfile so unmap can later send us a signal to exit
Self::write_pidfile(&pid_path)?;
@ -111,7 +112,6 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
mut startup_chan: Sender<Result<(), Error>>,
abort_chan: Receiver<()>,
) -> Result<(), Error> {
if self.session.is_none() {
panic!("internal error: fuse_loop::main called before ::map_loop");
}
@ -121,7 +121,10 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
let (loopdev_path, fuse_path) = (self.loopdev_path.clone(), self.fuse_path.clone());
tokio::task::spawn_blocking(move || {
if let Err(err) = loopdev::assign(loopdev_path, fuse_path) {
let _ = startup_chan.try_send(Err(format_err!("error while assigning loop device - {}", err)));
let _ = startup_chan.try_send(Err(format_err!(
"error while assigning loop device - {}",
err
)));
} else {
// device is assigned successfully, which means not only is the
// loopdev ready, but FUSE is also okay, since the assignment
@ -130,16 +133,17 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
}
});
let (loopdev_path, fuse_path, pid_path) =
(self.loopdev_path.clone(), self.fuse_path.clone(), self.pid_path.clone());
let (loopdev_path, fuse_path, pid_path) = (
self.loopdev_path.clone(),
self.fuse_path.clone(),
self.pid_path.clone(),
);
let cleanup = |session: futures::stream::Fuse<Fuse>| {
// only warn for errors on cleanup, if these fail nothing is lost
if let Err(err) = loopdev::unassign(&loopdev_path) {
eprintln!(
"cleanup: warning: could not unassign file {} from loop device {} - {}",
&fuse_path,
&loopdev_path,
err,
&fuse_path, &loopdev_path, err,
);
}
@ -149,21 +153,19 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
if let Err(err) = remove_file(&fuse_path) {
eprintln!(
"cleanup: warning: could not remove temporary file {} - {}",
&fuse_path,
err,
&fuse_path, err,
);
}
if let Err(err) = remove_file(&pid_path) {
eprintln!(
"cleanup: warning: could not remove PID file {} - {}",
&pid_path,
err,
&pid_path, err,
);
}
};
loop {
tokio::select!{
tokio::select! {
_ = abort_chan.next() => {
// aborted, do cleanup and exit
break;
@ -227,8 +229,8 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
pub fn cleanup_unused_run_files(filter_name: Option<String>) {
if let Ok(maps) = find_all_mappings() {
for (name, loopdev) in maps {
if loopdev.is_none() &&
(filter_name.is_none() || &name == filter_name.as_ref().unwrap())
if loopdev.is_none()
&& (filter_name.is_none() || &name == filter_name.as_ref().unwrap())
{
let mut path = PathBuf::from(RUN_DIR);
path.push(&name);
@ -254,10 +256,17 @@ pub fn cleanup_unused_run_files(filter_name: Option<String>) {
}
fn get_backing_file(loopdev: &str) -> Result<String, Error> {
let num = loopdev.split_at(9).1.parse::<u8>().map_err(|err|
format_err!("malformed loopdev path, does not end with valid number - {}", err))?;
let num = loopdev.split_at(9).1.parse::<u8>().map_err(|err| {
format_err!(
"malformed loopdev path, does not end with valid number - {}",
err
)
})?;
let block_path = PathBuf::from(format!("/sys/devices/virtual/block/loop{}/loop/backing_file", num));
let block_path = PathBuf::from(format!(
"/sys/devices/virtual/block/loop{}/loop/backing_file",
num
));
let backing_file = read_to_string(block_path).map_err(|err| {
if err.kind() == std::io::ErrorKind::NotFound {
format_err!("nothing mapped to {}", loopdev)
@ -281,7 +290,7 @@ fn get_backing_file(loopdev: &str) -> Result<String, Error> {
// call in broken state: we found the mapping, but the client is already dead,
// only thing to do is clean up what we can
fn emerg_cleanup (loopdev: Option<&str>, mut backing_file: PathBuf) {
fn emerg_cleanup(loopdev: Option<&str>, mut backing_file: PathBuf) {
eprintln!(
"warning: found mapping with dead process ({:?}), attempting cleanup",
&backing_file
@ -312,35 +321,36 @@ fn unmap_from_backing(backing_file: &Path, loopdev: Option<&str>) -> Result<(),
}
format_err!("error reading pidfile {:?}: {}", &pid_path, err)
})?;
let pid = pid_str.parse::<i32>().map_err(|err|
format_err!("malformed PID ({}) in pidfile - {}", pid_str, err))?;
let pid = pid_str
.parse::<i32>()
.map_err(|err| format_err!("malformed PID ({}) in pidfile - {}", pid_str, err))?;
let pid = Pid::from_raw(pid);
// send SIGINT to trigger cleanup and exit in target process
match signal::kill(pid, Signal::SIGINT) {
Ok(()) => {},
Ok(()) => {}
Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => {
emerg_cleanup(loopdev, backing_file.to_owned());
return Ok(());
},
}
Err(e) => return Err(e.into()),
}
// block until unmap is complete or timeout
let start = time::epoch_i64();
let start = epoch_i64();
loop {
match signal::kill(pid, None) {
Ok(_) => {
// 10 second timeout, then assume failure
if (time::epoch_i64() - start) > 10 {
if (epoch_i64() - start) > 10 {
return Err(format_err!("timed out waiting for PID '{}' to exit", &pid));
}
std::thread::sleep(std::time::Duration::from_millis(100));
},
}
Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => {
break;
},
}
Err(e) => return Err(e.into()),
}
}
@ -360,13 +370,13 @@ pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String
let loopdev = format!("/dev/{}", ent.file_name().to_string_lossy());
if let Ok(file) = get_backing_file(&loopdev) {
// insert filename only, strip RUN_DIR/
loopmap.insert(file[RUN_DIR.len()+1..].to_owned(), loopdev);
loopmap.insert(file[RUN_DIR.len() + 1..].to_owned(), loopdev);
}
}
}
Ok(pbs_tools::fs::read_subdir(libc::AT_FDCWD, Path::new(RUN_DIR))?
.filter_map(move |ent| {
Ok(
pbs_tools::fs::read_subdir(libc::AT_FDCWD, Path::new(RUN_DIR))?.filter_map(move |ent| {
match ent {
Ok(ent) => {
let file = ent.file_name().to_string_lossy();
@ -376,10 +386,11 @@ pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String
let loopdev = loopmap.get(file.as_ref()).map(String::to_owned);
Some((file.into_owned(), loopdev))
}
},
}
Err(_) => None,
}
}))
}),
)
}
/// Try and unmap a running proxmox-backup-client instance from the given

View File

@ -18,7 +18,16 @@ bitflags = "1.2.1"
regex = "1.2"
udev = ">= 0.3, <0.5"
proxmox = { version = "0.14.0", default-features = false, features = [] }
proxmox = "0.14.0"
proxmox-io = "1"
proxmox-lang = "1"
# api-macro is only used by the binaries, so maybe we should split them out
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-time = "1"
proxmox-uuid = "1"
# router::cli is only used by binaries, so maybe we should split them out
proxmox-router = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-tools = { path = "../pbs-tools" }

View File

@ -18,19 +18,9 @@ use std::convert::TryInto;
use anyhow::{bail, Error};
use serde_json::Value;
use proxmox::{
api::{
api,
cli::*,
schema::{
Schema,
IntegerSchema,
StringSchema,
ArraySchema,
},
RpcEnvironment,
},
};
use proxmox_schema::{api, ArraySchema, IntegerSchema, Schema, StringSchema};
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use pbs_api_types::{
LTO_DRIVE_PATH_SCHEMA, DRIVE_NAME_SCHEMA, LtoTapeDrive,

View File

@ -17,13 +17,9 @@ use std::fs::File;
use anyhow::{bail, Error};
use serde_json::Value;
use proxmox::{
api::{
api,
cli::*,
RpcEnvironment,
},
};
use proxmox_schema::api;
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use pbs_config::drive::complete_changer_name;
use pbs_api_types::{
@ -93,7 +89,7 @@ fn inquiry(
let output_format = get_output_format(&param);
let result: Result<_, Error> = proxmox::try_block!({
let result: Result<_, Error> = proxmox_lang::try_block!({
let mut file = get_changer_handle(&param)?;
let info = scsi_inquiry(&mut file)?;
Ok(info)
@ -281,7 +277,7 @@ fn status(
let output_format = get_output_format(&param);
let result: Result<_, Error> = proxmox::try_block!({
let result: Result<_, Error> = proxmox_lang::try_block!({
let mut file = get_changer_handle(&param)?;
let status = sg_pt_changer::read_element_status(&mut file)?;
Ok(status)

View File

@ -1,4 +1,4 @@
use proxmox::tools::vec;
use proxmox_io::vec;
use crate::{
TapeWrite,

View File

@ -1,6 +1,6 @@
use std::io::Read;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::{BlockRead, BlockReadError, PROXMOX_TAPE_BLOCK_SIZE};

View File

@ -6,8 +6,8 @@ use endian_trait::Endian;
use serde::{Serialize, Deserialize};
use serde_json::Value;
use proxmox::tools::Uuid;
use proxmox::api::schema::parse_property_string;
use proxmox_schema::parse_property_string;
use proxmox_uuid::Uuid;
use pbs_api_types::{ScsiTapeChanger, SLOT_ARRAY_SCHEMA};
@ -119,13 +119,13 @@ impl MediaContentHeader {
/// Create a new instance with autogenerated Uuid
pub fn new(content_magic: [u8; 8], size: u32) -> Self {
let uuid = *proxmox::tools::uuid::Uuid::generate()
let uuid = *Uuid::generate()
.into_inner();
Self {
magic: PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
content_magic,
uuid,
ctime: proxmox::tools::time::epoch_i64(),
ctime: proxmox_time::epoch_i64(),
size,
part_number: 0,
reserved_0: 0,

View File

@ -8,7 +8,7 @@ use std::fs::{OpenOptions, File};
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::ScsiTapeChanger;
@ -139,7 +139,7 @@ fn read_element_address_assignment<F: AsRawFd>(
let data = execute_scsi_command(&mut sg_raw, &cmd, "read element address assignment", true)?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: AddressAssignmentPage = unsafe { reader.read_be_value()? };
@ -662,7 +662,7 @@ fn decode_element_status_page(
start_element_address: u16,
) -> Result<DecodedStatusPage, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut result = DecodedStatusPage {
last_element_address: None,

View File

@ -25,10 +25,8 @@ pub use mam::*;
mod report_density;
pub use report_density::*;
use proxmox::{
sys::error::SysResult,
tools::io::{ReadExt, WriteExt},
};
use proxmox::sys::error::SysResult;
use proxmox_io::{ReadExt, WriteExt};
use pbs_api_types::{MamAttribute, Lp17VolumeStatistics, LtoDriveAndMediaStatus};
@ -386,7 +384,7 @@ impl SgTape {
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("read position failed - {}", err))?;
let page = proxmox::try_block!({
let page = proxmox_lang::try_block!({
if data.len() != expected_size {
bail!("got unexpected data len ({} != {}", data.len(), expected_size);
}
@ -793,7 +791,7 @@ impl SgTape {
let (head, block_descriptor, page): (_,_, MediumConfigurationModePage)
= scsi_mode_sense(&mut self.file, false, 0x1d, 0)?;
proxmox::try_block!({
proxmox_lang::try_block!({
if (page.page_code & 0b0011_1111) != 0x1d {
bail!("wrong page code {}", page.page_code);
}
@ -817,7 +815,7 @@ impl SgTape {
let (head, block_descriptor, page): (_,_, DataCompressionModePage)
= scsi_mode_sense(&mut self.file, false, 0x0f, 0)?;
proxmox::try_block!({
proxmox_lang::try_block!({
if (page.page_code & 0b0011_1111) != 0x0f {
bail!("wrong page code {}", page.page_code);
}

View File

@ -4,7 +4,7 @@ use std::io::Write;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::{ReadExt, WriteExt};
use proxmox_io::{ReadExt, WriteExt};
use crate::sgutils2::{SgRaw, alloc_page_aligned_buffer};
@ -216,7 +216,7 @@ struct SspDataEncryptionAlgorithmDescriptor {
// Returns the algorythm_index for AES-CGM
fn decode_spin_data_encryption_caps(data: &[u8]) -> Result<u8, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let _page: SspDataEncryptionCapabilityPage = unsafe { reader.read_be_value()? };
@ -267,7 +267,7 @@ struct SspDataEncryptionStatusPage {
fn decode_spin_data_encryption_status(data: &[u8]) -> Result<DataEncryptionStatus, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: SspDataEncryptionStatusPage = unsafe { reader.read_be_value()? };

View File

@ -5,7 +5,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::MamAttribute;
@ -211,7 +211,7 @@ pub fn mam_extract_media_usage(mam: &[MamAttribute]) -> Result<MediaUsageInfo, E
let mon: i32 = date_str[4..6].parse()?;
let mday: i32 = date_str[6..8].parse()?;
use proxmox::tools::time::TmEditor;
use proxmox_time::TmEditor;
let mut t = TmEditor::new(true);
t.set_year(year)?;
t.set_mon(mon)?;

View File

@ -3,7 +3,7 @@ use std::io::Read;
use endian_trait::Endian;
use std::os::unix::io::AsRawFd;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::sgutils2::SgRaw;
@ -38,7 +38,7 @@ pub fn report_density<F: AsRawFd>(file: &mut F) -> Result<u8, Error> {
let mut max_density = 0u8;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page_len: u16 = unsafe { reader.read_be_value()? };

View File

@ -3,7 +3,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use crate::sgutils2::SgRaw;
@ -106,7 +106,7 @@ fn sg_read_tape_alert_flags<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, Error>
fn decode_tape_alert_flags(data: &[u8]) -> Result<TapeAlertFlags, Error> {
proxmox::try_block!({
proxmox_lang::try_block!({
if !((data[0] & 0x7f) == 0x12 && data[1] == 0) {
bail!("invalid response");
}

View File

@ -4,7 +4,7 @@ use std::os::unix::io::AsRawFd;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
use pbs_api_types::Lp17VolumeStatistics;
@ -71,7 +71,7 @@ fn decode_volume_statistics(data: &[u8]) -> Result<Lp17VolumeStatistics, Error>
Ok(value)
};
proxmox::try_block!({
proxmox_lang::try_block!({
if !((data[0] & 0x7f) == 0x17 && data[1] == 0) {
bail!("invalid response");
}

View File

@ -6,16 +6,16 @@
//!
//! The SCSI Commands Reference Manual also contains some useful information.
use std::ffi::CStr;
use std::os::unix::io::AsRawFd;
use std::ptr::NonNull;
use anyhow::{bail, format_err, Error};
use endian_trait::Endian;
use serde::{Deserialize, Serialize};
use libc::{c_char, c_int};
use std::ffi::CStr;
use serde::{Deserialize, Serialize};
use proxmox::tools::io::ReadExt;
use proxmox_io::ReadExt;
#[derive(thiserror::Error, Debug)]
pub struct SenseInfo {
@ -379,7 +379,7 @@ pub fn get_asc_ascq_string(asc: u8, ascq: u8) -> String {
)
};
proxmox::try_block!({
proxmox_lang::try_block!({
if res.is_null() { // just to be safe
bail!("unexpected NULL ptr");
}
@ -675,7 +675,7 @@ pub fn scsi_inquiry<F: AsRawFd>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("SCSI inquiry failed - {}", err))?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let page: InquiryPage = unsafe { reader.read_be_value()? };
@ -724,7 +724,7 @@ pub fn scsi_mode_sense<F: AsRawFd, P: Endian>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("mode sense failed - {}", err))?;
proxmox::try_block!({
proxmox_lang::try_block!({
let mut reader = &data[..];
let head: ModeParameterHeader = unsafe { reader.read_be_value()? };
@ -777,7 +777,7 @@ pub fn scsi_request_sense<F: AsRawFd>(
let data = sg_raw.do_command(&cmd)
.map_err(|err| format_err!("request sense failed - {}", err))?;
let sense = proxmox::try_block!({
let sense = proxmox_lang::try_block!({
let data_len = data.len();
if data_len < std::mem::size_of::<RequestSenseFixed>() {

View File

@ -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" }

View File

@ -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> {

View File

@ -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;

View File

@ -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() })
}
}

View File

@ -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 {

View File

@ -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;

View File

@ -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
});
}

View File

@ -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() {

View File

@ -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};

View File

@ -22,7 +22,10 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
pathpatterns = "0.1.2"
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
proxmox = { version = "0.14.0", features = [ "sortable-macro", "api-macro", "cli", "router" ] }
proxmox = { version = "0.14.0", features = [ "sortable-macro" ] }
proxmox-router = { version = "1", features = [ "cli" ] }
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-time = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-buildcfg = { path = "../pbs-buildcfg" }

View File

@ -5,9 +5,8 @@ use anyhow::{Error};
use serde_json::Value;
use serde::Serialize;
use proxmox::api::{ApiMethod, RpcEnvironment};
use proxmox::api::{
api,
use proxmox_schema::{api, ApiType, ReturnType};
use proxmox_router::{
cli::{
OUTPUT_FORMAT,
ColumnConfig,
@ -15,8 +14,8 @@ use proxmox::api::{
format_and_print_result_full,
default_table_format_options,
},
router::ReturnType,
schema::ApiType,
ApiMethod,
RpcEnvironment,
};
use pbs_tools::crypt_config::CryptConfig;
@ -222,7 +221,7 @@ async fn test_upload_speed(
verbose: bool,
) -> Result<(), Error> {
let backup_time = proxmox::tools::time::epoch_i64();
let backup_time = proxmox_time::epoch_i64();
let client = connect(&repo)?;
record_repository(&repo);

View File

@ -1,7 +1,7 @@
use anyhow::{Error};
use proxmox::api::format::*;
use proxmox::api::cli::*;
use proxmox_router::cli::*;
use proxmox_schema::format::*;
use pbs_client::catalog_shell::catalog_shell_cli;

View File

@ -5,7 +5,8 @@ use std::sync::Arc;
use anyhow::{bail, format_err, Error};
use serde_json::Value;
use proxmox::api::{api, cli::*};
use proxmox_schema::api;
use proxmox_router::cli::*;
use pbs_client::tools::key_source::get_encryption_key_password;
use pbs_client::{BackupReader, RemoteChunkReader};

View File

@ -4,15 +4,13 @@ use std::path::PathBuf;
use anyhow::{bail, format_err, Error};
use serde_json::Value;
use proxmox::api::api;
use proxmox::api::cli::{
use proxmox::sys::linux::tty;
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox_router::cli::{
format_and_print_result_full, get_output_format, CliCommand, CliCommandMap, ColumnConfig,
OUTPUT_FORMAT,
};
use proxmox::api::router::ReturnType;
use proxmox::api::schema::ApiType;
use proxmox::sys::linux::tty;
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox_schema::{api, ApiType, ReturnType};
use pbs_api_types::{RsaPubKeyInfo, PASSWORD_HINT_SCHEMA, Kdf, KeyInfo};
use pbs_config::key_config::{KeyConfig, rsa_decrypt_key_config};
@ -266,7 +264,7 @@ fn show_key(path: Option<String>, param: Value) -> Result<(), Error> {
let mut info: KeyInfo = (&config).into();
info.path = Some(format!("{:?}", path));
let options = proxmox::api::cli::default_table_format_options()
let options = proxmox_router::cli::default_table_format_options()
.column(ColumnConfig::new("path"))
.column(ColumnConfig::new("kdf"))
.column(ColumnConfig::new("created").renderer(pbs_tools::format::render_epoch))
@ -394,7 +392,7 @@ fn show_master_pubkey(path: Option<String>, param: Value) -> Result<(), Error> {
let mut info = RsaPubKeyInfo::try_from(rsa)?;
info.path = Some(path.display().to_string());
let options = proxmox::api::cli::default_table_format_options()
let options = proxmox_router::cli::default_table_format_options()
.column(ColumnConfig::new("path"))
.column(ColumnConfig::new("modulus"))
.column(ColumnConfig::new("exponent"))

View File

@ -13,18 +13,10 @@ use tokio_stream::wrappers::ReceiverStream;
use xdg::BaseDirectories;
use pathpatterns::{MatchEntry, MatchType, PatternFlag};
use proxmox::{
tools::{
time::{strftime_local, epoch_i64},
fs::{file_get_json, replace_file, CreateOptions, image_size},
},
api::{
api,
ApiMethod,
RpcEnvironment,
cli::*,
},
};
use proxmox::tools::fs::{file_get_json, replace_file, CreateOptions, image_size};
use proxmox_router::{ApiMethod, RpcEnvironment, cli::*};
use proxmox_schema::api;
use proxmox_time::{strftime_local, epoch_i64};
use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation};
use pbs_api_types::{

View File

@ -14,8 +14,9 @@ use serde_json::Value;
use tokio::signal::unix::{signal, SignalKind};
use proxmox::{sortable, identity};
use proxmox::api::{ApiHandler, ApiMethod, RpcEnvironment, schema::*, cli::*};
use proxmox::tools::fd::Fd;
use proxmox_router::{ApiHandler, ApiMethod, RpcEnvironment, cli::*};
use proxmox_schema::*;
use pbs_tools::crypt_config::CryptConfig;
use pbs_config::key_config::load_and_decrypt_key;

View File

@ -3,10 +3,9 @@ use std::sync::Arc;
use anyhow::Error;
use serde_json::{json, Value};
use proxmox::{
api::{api, cli::*},
tools::fs::file_get_contents,
};
use proxmox::tools::fs::file_get_contents;
use proxmox_router::cli::*;
use proxmox_schema::api;
use pbs_tools::crypt_config::CryptConfig;
use pbs_config::key_config::decrypt_key;

View File

@ -1,7 +1,8 @@
use anyhow::{Error};
use serde_json::{json, Value};
use proxmox::api::{api, cli::*};
use proxmox_schema::api;
use proxmox_router::cli::*;
use pbs_client::display_task_log;
use pbs_tools::percent_encoding::percent_encode_component;

View File

@ -16,7 +16,12 @@ tokio = { version = "1.6", features = [ "io-std", "rt", "rt-multi-thread", "time
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
proxmox = { version = "0.14.0", features = [ "api-macro", "cli" ] }
proxmox = { version = "0.14.0" }
proxmox-lang = "1"
proxmox-router = { version = "1", features = [ "cli" ] }
proxmox-schema = { version = "1", features = [ "api-macro" ] }
proxmox-time = "1"
proxmox-uuid = "1"
pbs-api-types = { path = "../pbs-api-types" }
pbs-buildcfg = { path = "../pbs-buildcfg" }

View File

@ -8,7 +8,8 @@ use anyhow::{bail, Error};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use proxmox::api::{api, cli::*};
use proxmox_router::cli::*;
use proxmox_schema::api;
use pbs_client::BackupRepository;
use pbs_datastore::backup_info::BackupDir;

Some files were not shown because too many files have changed in this diff Show More