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:
@ -10,7 +10,7 @@ use hyper::{Body, Request};
|
||||
use nix::sys::stat::Mode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_acme_rs::account::AccountCreator;
|
||||
use proxmox_acme_rs::account::AccountData as AcmeAccountData;
|
||||
use proxmox_acme_rs::order::{Order, OrderData};
|
||||
|
@ -1,6 +1,7 @@
|
||||
//! Manage Access Control Lists
|
||||
|
||||
use anyhow::{bail, Error};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -126,7 +127,7 @@ pub fn read_acl(
|
||||
extract_acl_node_data(&tree.root, "", &mut list, exact, &auth_id_filter);
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -210,7 +211,7 @@ pub fn update_acl(
|
||||
let (mut tree, expected_digest) = pbs_config::acl::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ fn list_domains(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<BasicRealmInf
|
||||
list.push(serde_json::from_value(entry)?);
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_router::{
|
||||
http_err, list_subdirs_api_method, Router, RpcEnvironment, SubdirMap, Permission,
|
||||
};
|
||||
|
@ -2,10 +2,9 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_router::{
|
||||
http_err, list_subdirs_api_method, Router, RpcEnvironment, SubdirMap, Permission,
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ use anyhow::{bail, format_err, Error};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, SubdirMap, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -80,7 +81,7 @@ pub fn list_users(
|
||||
|
||||
let list:Vec<User> = config.convert_to_typed_array("user")?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
let iter = list.into_iter().filter(filter_by_privs);
|
||||
let list = if include_tokens {
|
||||
@ -187,7 +188,7 @@ pub fn create_user(
|
||||
pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<User, Error> {
|
||||
let (config, digest) = pbs_config::user::config()?;
|
||||
let user = config.lookup("user", userid.as_str())?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
@ -258,7 +259,7 @@ pub fn update_user(
|
||||
let (mut config, expected_digest) = pbs_config::user::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -351,7 +352,7 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
|
||||
let (mut config, expected_digest) = pbs_config::user::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -421,7 +422,7 @@ pub fn read_token(
|
||||
|
||||
let tokenid = Authid::from((userid, Some(token_name)));
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
config.lookup("token", &tokenid.to_string())
|
||||
}
|
||||
|
||||
@ -488,7 +489,7 @@ pub fn generate_token(
|
||||
let (mut config, expected_digest) = pbs_config::user::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -569,7 +570,7 @@ pub fn update_token(
|
||||
let (mut config, expected_digest) = pbs_config::user::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -637,7 +638,7 @@ pub fn delete_token(
|
||||
let (mut config, expected_digest) = pbs_config::user::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -703,7 +704,7 @@ pub fn list_tokens(
|
||||
|
||||
let list:Vec<ApiToken> = config.convert_to_typed_array("token")?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
let filter_by_owner = |token: ApiToken| {
|
||||
if token.tokenid.is_token() && token.tokenid.user() == &userid {
|
||||
|
@ -12,8 +12,8 @@ use hyper::{header, Body, Response, StatusCode};
|
||||
use serde_json::{json, Value};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox::tools::fs::{
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_sys::fs::{
|
||||
file_read_firstline, file_read_optional_string, replace_file, CreateOptions,
|
||||
};
|
||||
use proxmox_router::{
|
||||
|
@ -3,7 +3,7 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::sortable;
|
||||
use proxmox_sys::sortable;
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, ApiMethod, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
|
||||
Permission,
|
||||
@ -87,7 +87,7 @@ pub fn list_sync_jobs(
|
||||
list.push(SyncJobStatus { config: job, status });
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub fn show_current_traffic(
|
||||
}
|
||||
|
||||
// also return the configuration digest
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use anyhow::{format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::sortable;
|
||||
use proxmox_sys::sortable;
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, ApiMethod, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
|
||||
Permission,
|
||||
@ -87,7 +87,7 @@ pub fn list_verification_jobs(
|
||||
list.push(VerificationJobStatus { config: job, status });
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ use nix::dir::Dir;
|
||||
use ::serde::{Serialize};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::tools::digest_to_hex;
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_router::{RpcEnvironment, RpcEnvironmentType};
|
||||
|
||||
use pbs_datastore::{DataStore, DataBlob};
|
||||
@ -331,8 +330,8 @@ impl BackupEnvironment {
|
||||
|
||||
fn log_upload_stat(&self, archive_name: &str, csum: &[u8; 32], uuid: &[u8; 16], size: u64, chunk_count: u64, upload_stat: &UploadStatistic) {
|
||||
self.log(format!("Upload statistics for '{}'", archive_name));
|
||||
self.log(format!("UUID: {}", digest_to_hex(uuid)));
|
||||
self.log(format!("Checksum: {}", digest_to_hex(csum)));
|
||||
self.log(format!("UUID: {}", hex::encode(uuid)));
|
||||
self.log(format!("Checksum: {}", hex::encode(csum)));
|
||||
self.log(format!("Size: {}", size));
|
||||
self.log(format!("Chunk count: {}", chunk_count));
|
||||
|
||||
|
@ -6,8 +6,9 @@ use hyper::header::{HeaderValue, UPGRADE};
|
||||
use hyper::http::request::Parts;
|
||||
use hyper::{Body, Response, Request, StatusCode};
|
||||
use serde_json::{json, Value};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::list_subdirs_api_method;
|
||||
use proxmox_router::{
|
||||
ApiResponseFuture, ApiHandler, ApiMethod, Router, RpcEnvironment, SubdirMap, Permission,
|
||||
@ -19,7 +20,7 @@ use pbs_api_types::{
|
||||
BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
|
||||
CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_BACKUP, BACKUP_ARCHIVE_NAME_SCHEMA,
|
||||
};
|
||||
use pbs_tools::fs::lock_dir_noblock_shared;
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
use pbs_tools::json::{required_array_param, required_integer_param, required_string_param};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::{DataStore, PROXMOX_BACKUP_PROTOCOL_ID_V1};
|
||||
@ -433,7 +434,7 @@ fn create_fixed_index(
|
||||
};
|
||||
|
||||
let (old_csum, _) = index.compute_csum();
|
||||
let old_csum = proxmox::tools::digest_to_hex(&old_csum);
|
||||
let old_csum = hex::encode(&old_csum);
|
||||
if old_csum != csum {
|
||||
bail!("expected csum ({}) doesn't match last backup's ({}), cannot do incremental backup",
|
||||
csum, old_csum);
|
||||
@ -508,7 +509,7 @@ fn dynamic_append (
|
||||
|
||||
for (i, item) in digest_list.iter().enumerate() {
|
||||
let digest_str = item.as_str().unwrap();
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
let offset = offset_list[i].as_u64().unwrap();
|
||||
let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
|
||||
|
||||
@ -573,7 +574,7 @@ fn fixed_append (
|
||||
|
||||
for (i, item) in digest_list.iter().enumerate() {
|
||||
let digest_str = item.as_str().unwrap();
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
let offset = offset_list[i].as_u64().unwrap();
|
||||
let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
|
||||
|
||||
@ -628,7 +629,7 @@ fn close_dynamic_index (
|
||||
let chunk_count = required_integer_param(¶m, "chunk-count")? as u64;
|
||||
let size = required_integer_param(¶m, "size")? as u64;
|
||||
let csum_str = required_string_param(¶m, "csum")?;
|
||||
let csum = proxmox::tools::hex_to_digest(csum_str)?;
|
||||
let csum = <[u8; 32]>::from_hex(csum_str)?;
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
@ -682,7 +683,7 @@ fn close_fixed_index (
|
||||
let chunk_count = required_integer_param(¶m, "chunk-count")? as u64;
|
||||
let size = required_integer_param(¶m, "size")? as u64;
|
||||
let csum_str = required_string_param(¶m, "csum")?;
|
||||
let csum = proxmox::tools::hex_to_digest(csum_str)?;
|
||||
let csum = <[u8; 32]>::from_hex(csum_str)?;
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
|
@ -7,8 +7,9 @@ use futures::*;
|
||||
use hyper::Body;
|
||||
use hyper::http::request::Parts;
|
||||
use serde_json::{json, Value};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{ApiResponseFuture, ApiHandler, ApiMethod, RpcEnvironment};
|
||||
use proxmox_schema::*;
|
||||
|
||||
@ -127,7 +128,7 @@ fn upload_fixed_chunk(
|
||||
let encoded_size = required_integer_param(¶m, "encoded-size")? as u32;
|
||||
|
||||
let digest_str = required_string_param(¶m, "digest")?;
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
@ -135,7 +136,7 @@ fn upload_fixed_chunk(
|
||||
UploadChunk::new(req_body, env.datastore.clone(), digest, size, encoded_size).await?;
|
||||
|
||||
env.register_fixed_chunk(wid, digest, size, compressed_size, is_duplicate)?;
|
||||
let digest_str = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest_str = hex::encode(&digest);
|
||||
env.debug(format!("upload_chunk done: {} bytes, {}", size, digest_str));
|
||||
|
||||
let result = Ok(json!(digest_str));
|
||||
@ -185,7 +186,7 @@ fn upload_dynamic_chunk(
|
||||
let encoded_size = required_integer_param(¶m, "encoded-size")? as u32;
|
||||
|
||||
let digest_str = required_string_param(¶m, "digest")?;
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
|
||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||
|
||||
@ -194,7 +195,7 @@ fn upload_dynamic_chunk(
|
||||
.await?;
|
||||
|
||||
env.register_dynamic_chunk(wid, digest, size, compressed_size, is_duplicate)?;
|
||||
let digest_str = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest_str = hex::encode(&digest);
|
||||
env.debug(format!("upload_chunk done: {} bytes, {}", size, digest_str));
|
||||
|
||||
let result = Ok(json!(digest_str));
|
||||
|
@ -1,6 +1,6 @@
|
||||
use proxmox_router::{Router, SubdirMap};
|
||||
use proxmox_router::list_subdirs_api_method;
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
|
||||
pub mod tfa;
|
||||
pub mod openid;
|
||||
|
@ -3,6 +3,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -37,7 +38,7 @@ pub fn list_openid_realms(
|
||||
|
||||
let list = config.convert_to_typed_array("openid")?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -106,7 +107,7 @@ pub fn delete_openid_realm(
|
||||
let (mut domains, expected_digest) = domains::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -142,7 +143,7 @@ pub fn read_openid_realm(
|
||||
|
||||
let config = domains.lookup("openid", &realm)?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
@ -211,7 +212,7 @@ pub fn update_openid_realm(
|
||||
let (mut domains, expected_digest) = domains::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
//! If we add more, it should be moved into a sub module.
|
||||
|
||||
use anyhow::Error;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission, SubdirMap};
|
||||
use proxmox_schema::api;
|
||||
@ -42,7 +43,7 @@ pub fn get_webauthn_config(
|
||||
Some(c) => c,
|
||||
None => return Ok(None),
|
||||
};
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(Some(config))
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ pub fn update_webauthn_config(
|
||||
|
||||
if let Some(wa) = &mut tfa.webauthn {
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(
|
||||
&digest,
|
||||
&crate::config::tfa::webauthn_config_digest(&wa)?,
|
||||
|
@ -8,6 +8,7 @@ use anyhow::{bail, format_err, Error};
|
||||
use lazy_static::lazy_static;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{
|
||||
http_bail, list_subdirs_api_method, Permission, Router, RpcEnvironment, SubdirMap,
|
||||
@ -520,7 +521,7 @@ fn modify_cfg_for_api(id: &str, ty: &str, data: &Value) -> PluginConfig {
|
||||
/// List ACME challenge plugins.
|
||||
pub fn list_plugins(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<PluginConfig>, Error> {
|
||||
let (plugins, digest) = plugin::config()?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(plugins
|
||||
.iter()
|
||||
.map(|(id, (ty, data))| modify_cfg_for_api(&id, &ty, data))
|
||||
@ -542,7 +543,7 @@ pub fn list_plugins(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<PluginCon
|
||||
/// List ACME challenge plugins.
|
||||
pub fn get_plugin(id: String, mut rpcenv: &mut dyn RpcEnvironment) -> Result<PluginConfig, Error> {
|
||||
let (plugins, digest) = plugin::config()?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
match plugins.get(&id) {
|
||||
Some((ty, data)) => Ok(modify_cfg_for_api(&id, &ty, &data)),
|
||||
@ -695,7 +696,7 @@ pub fn update_plugin(
|
||||
let (mut plugins, expected_digest) = plugin::config()?;
|
||||
|
||||
if let Some(digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(&digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(&digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::{api, parse_property_string};
|
||||
@ -83,7 +84,7 @@ pub fn get_config(
|
||||
|
||||
let data: ScsiTapeChanger = config.lookup("changer", &name)?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
@ -124,7 +125,7 @@ pub fn list_changers(
|
||||
})
|
||||
.collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -181,7 +182,7 @@ pub fn update_changer(
|
||||
let (mut config, expected_digest) = pbs_config::drive::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,12 @@ use std::path::PathBuf;
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, RpcEnvironmentType, Permission};
|
||||
use proxmox_schema::{api, ApiType, parse_property_string};
|
||||
use proxmox_section_config::SectionConfigData;
|
||||
use proxmox_sys::worker_task_context::WorkerTaskContext;
|
||||
use proxmox_sys::WorkerTaskContext;
|
||||
|
||||
use pbs_datastore::chunk_store::ChunkStore;
|
||||
use pbs_config::BackupLockGuard;
|
||||
@ -55,7 +56,7 @@ pub fn list_datastores(
|
||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||
let user_info = CachedUserInfo::new()?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
let list:Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
|
||||
let filter_by_privs = |store: &DataStoreConfig| {
|
||||
@ -148,7 +149,7 @@ pub fn read_datastore(
|
||||
let (config, digest) = pbs_config::datastore::config()?;
|
||||
|
||||
let store_config = config.lookup("datastore", &name)?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(store_config)
|
||||
}
|
||||
@ -228,7 +229,7 @@ pub fn update_datastore(
|
||||
let (mut config, expected_digest) = pbs_config::datastore::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -347,7 +348,7 @@ pub async fn delete_datastore(
|
||||
let (mut config, expected_digest) = pbs_config::datastore::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -82,7 +83,7 @@ pub fn get_config(
|
||||
|
||||
let data: LtoTapeDrive = config.lookup("lto", &name)?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
@ -123,7 +124,7 @@ pub fn list_drives(
|
||||
})
|
||||
.collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(drive_list)
|
||||
}
|
||||
@ -183,7 +184,7 @@ pub fn update_drive(
|
||||
let (mut config, expected_digest) = pbs_config::drive::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ pub fn list_pools(
|
||||
})
|
||||
.collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use proxmox::sortable;
|
||||
use proxmox_sys::sortable;
|
||||
use proxmox_router::SubdirMap;
|
||||
use proxmox_router::list_subdirs_api_method;
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{http_err, ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -57,7 +58,7 @@ pub fn list_remotes(
|
||||
})
|
||||
.collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(list)
|
||||
}
|
||||
|
||||
@ -128,7 +129,7 @@ pub fn read_remote(
|
||||
let (config, digest) = pbs_config::remote::config()?;
|
||||
let mut data: Remote = config.lookup("remote", &name)?;
|
||||
data.password = "".to_string(); // do not return password in api
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@ -193,7 +194,7 @@ pub fn update_remote(
|
||||
let (mut config, expected_digest) = pbs_config::remote::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -265,7 +266,7 @@ pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error>
|
||||
let (mut config, expected_digest) = pbs_config::remote::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -91,7 +92,7 @@ pub fn list_sync_jobs(
|
||||
|
||||
let list = config.convert_to_typed_array("sync")?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
let list = list
|
||||
.into_iter()
|
||||
@ -173,7 +174,7 @@ pub fn read_sync_job(
|
||||
bail!("permission check failed");
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(sync_job)
|
||||
}
|
||||
@ -251,7 +252,7 @@ pub fn update_sync_job(
|
||||
let (mut config, expected_digest) = sync::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -355,7 +356,7 @@ pub fn delete_sync_job(
|
||||
let (mut config, expected_digest) = sync::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -47,7 +48,7 @@ pub fn list_tape_backup_jobs(
|
||||
})
|
||||
.collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -111,7 +112,7 @@ pub fn read_tape_backup_job(
|
||||
|
||||
let job = config.lookup("backup", &id)?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(job)
|
||||
}
|
||||
@ -180,7 +181,7 @@ pub fn update_tape_backup_job(
|
||||
let mut data: TapeBackupJobConfig = config.lookup("backup", &id)?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -259,7 +260,7 @@ pub fn delete_tape_backup_job(
|
||||
let (mut config, expected_digest) = pbs_config::tape_job::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -50,7 +51,7 @@ pub fn list_keys(
|
||||
list.push(item.into());
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -109,7 +110,7 @@ pub fn change_passphrase(
|
||||
let (mut config_map, expected_digest) = load_key_configs()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -245,7 +246,7 @@ pub fn delete_key(
|
||||
let (mut key_map, _) = load_keys()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -34,7 +35,7 @@ pub fn list_traffic_controls(
|
||||
|
||||
let list: Vec<TrafficControlRule> = config.convert_to_typed_array("rule")?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -92,7 +93,7 @@ pub fn read_traffic_control(
|
||||
) -> Result<TrafficControlRule, Error> {
|
||||
let (config, digest) = pbs_config::traffic_control::config()?;
|
||||
let data: TrafficControlRule = config.lookup("rule", &name)?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ pub fn update_traffic_control(
|
||||
let (mut config, expected_digest) = pbs_config::traffic_control::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -238,7 +239,7 @@ pub fn delete_traffic_control(name: String, digest: Option<String>) -> Result<()
|
||||
let (mut config, expected_digest) = pbs_config::traffic_control::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
@ -48,7 +49,7 @@ pub fn list_verification_jobs(
|
||||
privs & required_privs != 00
|
||||
}).collect();
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
@ -125,7 +126,7 @@ pub fn read_verification_job(
|
||||
let required_privs = PRIV_DATASTORE_AUDIT | PRIV_DATASTORE_VERIFY;
|
||||
user_info.check_privs(&auth_id, &["datastore", &verification_job.store], required_privs, true)?;
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(verification_job)
|
||||
}
|
||||
@ -193,7 +194,7 @@ pub fn update_verification_job(
|
||||
let (mut config, expected_digest) = verify::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -280,7 +281,7 @@ pub fn delete_verification_job(
|
||||
user_info.check_privs(&auth_id, &["datastore", &job.store], PRIV_DATASTORE_VERIFY, true)?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ use anyhow::{Error, bail, format_err};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, RpcEnvironment, RpcEnvironmentType, Permission, Router, SubdirMap
|
||||
};
|
||||
@ -277,7 +277,7 @@ fn apt_get_changelog(
|
||||
command.arg("changelog");
|
||||
command.arg("-qq"); // don't display download progress
|
||||
command.arg(name);
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
Ok(json!(output))
|
||||
}
|
||||
}
|
||||
@ -447,7 +447,7 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
|
||||
/// Get APT repository information.
|
||||
pub fn get_repositories() -> Result<Value, Error> {
|
||||
let (files, errors, digest) = proxmox_apt::repositories::repositories()?;
|
||||
let digest = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest = hex::encode(&digest);
|
||||
|
||||
let suite = proxmox_apt::repositories::get_current_release_codename()?;
|
||||
|
||||
@ -493,7 +493,7 @@ pub fn add_repository(handle: APTRepositoryHandle, digest: Option<String>) -> Re
|
||||
let suite = proxmox_apt::repositories::get_current_release_codename()?;
|
||||
|
||||
if let Some(expected_digest) = digest {
|
||||
let current_digest = proxmox::tools::digest_to_hex(¤t_digest);
|
||||
let current_digest = hex::encode(¤t_digest);
|
||||
crate::tools::assert_if_modified(&expected_digest, ¤t_digest)?;
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ pub fn change_repository(
|
||||
let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
|
||||
|
||||
if let Some(expected_digest) = digest {
|
||||
let current_digest = proxmox::tools::digest_to_hex(¤t_digest);
|
||||
let current_digest = hex::encode(¤t_digest);
|
||||
crate::tools::assert_if_modified(&expected_digest, ¤t_digest)?;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ impl TryFrom<&cert::CertInfo> for CertificateInfo {
|
||||
|
||||
fn get_certificate_pem() -> Result<String, Error> {
|
||||
let cert_path = configdir!("/proxy.pem");
|
||||
let cert_pem = proxmox::tools::fs::file_get_contents(&cert_path)?;
|
||||
let cert_pem = proxmox_sys::fs::file_get_contents(&cert_path)?;
|
||||
String::from_utf8(cert_pem)
|
||||
.map_err(|_| format_err!("certificate in {:?} is not a valid PEM file", cert_path))
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use anyhow::Error;
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{Permission, Router, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
@ -29,7 +30,7 @@ pub const ROUTER: Router = Router::new()
|
||||
/// Get the node configuration
|
||||
pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<NodeConfig, Error> {
|
||||
let (config, digest) = crate::config::node::config()?;
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ pub fn update_node_config(
|
||||
if let Some(digest) = digest {
|
||||
// FIXME: GUI doesn't handle our non-inlined digest part here properly...
|
||||
if !digest.is_empty() {
|
||||
let digest = proxmox::tools::hex_to_digest(&digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(&digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
let basedir = "/etc/systemd/system";
|
||||
for item in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
|
||||
for item in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
|
||||
let item = item?;
|
||||
let name = item.file_name().to_string_lossy().to_string();
|
||||
|
||||
@ -243,7 +243,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
// disable systemd mount-unit
|
||||
let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&path, true);
|
||||
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&path, true);
|
||||
mount_unit_name.push_str(".mount");
|
||||
crate::tools::systemd::disable_unit(&mount_unit_name)?;
|
||||
|
||||
@ -256,7 +256,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
|
||||
// try to unmount, if that fails tell the user to reboot or unmount manually
|
||||
let mut command = std::process::Command::new("umount");
|
||||
command.arg(&path);
|
||||
match pbs_tools::run_command(command, None) {
|
||||
match proxmox_sys::command::run_command(command, None) {
|
||||
Err(_) => bail!(
|
||||
"Could not umount '{}' since it is busy. It will stay mounted \
|
||||
until the next reboot or until unmounted manually!",
|
||||
@ -282,7 +282,7 @@ fn create_datastore_mount_unit(
|
||||
what: &str,
|
||||
) -> Result<String, Error> {
|
||||
|
||||
let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&mount_point, true);
|
||||
let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&mount_point, true);
|
||||
mount_unit_name.push_str(".mount");
|
||||
|
||||
let mount_unit_path = format!("/etc/systemd/system/{}", mount_unit_name);
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap, Permission,
|
||||
};
|
||||
|
@ -265,11 +265,11 @@ pub fn create_zpool(
|
||||
|
||||
task_log!(worker, "# {:?}", command);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
task_log!(worker, "{}", output);
|
||||
|
||||
if std::path::Path::new("/lib/systemd/system/zfs-import@.service").exists() {
|
||||
let import_unit = format!("zfs-import@{}.service", proxmox::tools::systemd::escape_unit(&name, false));
|
||||
let import_unit = format!("zfs-import@{}.service", proxmox_sys::systemd::escape_unit(&name, false));
|
||||
crate::tools::systemd::enable_unit(&import_unit)?;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ pub fn create_zpool(
|
||||
let mut command = std::process::Command::new("zfs");
|
||||
command.args(&["set", &format!("compression={}", compression), &name]);
|
||||
task_log!(worker, "# {:?}", command);
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
task_log!(worker, "{}", output);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ use ::serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use proxmox::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
|
||||
use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use pbs_api_types::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
|
||||
|
||||
use pbs_api_types::{
|
||||
PROXMOX_CONFIG_DIGEST_SCHEMA, FIRST_DNS_SERVER_SCHEMA, SECOND_DNS_SERVER_SCHEMA,
|
||||
@ -41,7 +41,7 @@ pub fn read_etc_resolv_conf() -> Result<Value, Error> {
|
||||
|
||||
let raw = file_get_contents(RESOLV_CONF_FN)?;
|
||||
|
||||
result["digest"] = Value::from(proxmox::tools::digest_to_hex(&sha::sha256(&raw)));
|
||||
result["digest"] = Value::from(hex::encode(&sha::sha256(&raw)));
|
||||
|
||||
let data = String::from_utf8(raw)?;
|
||||
|
||||
|
@ -12,8 +12,8 @@ use hyper::Request;
|
||||
use serde_json::{json, Value};
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox::tools::fd::fd_change_cloexec;
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_sys::fd::fd_change_cloexec;
|
||||
|
||||
use proxmox_router::{
|
||||
ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment, Router, SubdirMap,
|
||||
@ -319,7 +319,7 @@ fn upgrade_to_websocket(
|
||||
#[api]
|
||||
/// List Nodes (only for compatiblity)
|
||||
fn list_nodes() -> Result<Value, Error> {
|
||||
Ok(json!([ { "node": proxmox::tools::nodename().to_string() } ]))
|
||||
Ok(json!([ { "node": proxmox_sys::nodename().to_string() } ]))
|
||||
}
|
||||
|
||||
pub const SUBDIRS: SubdirMap = &[
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::{Error, bail};
|
||||
use serde_json::{Value, to_value};
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::{api, parse_property_string};
|
||||
@ -92,7 +93,7 @@ pub fn list_network_devices(
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let (config, digest) = network::config()?;
|
||||
let digest = proxmox::tools::digest_to_hex(&digest);
|
||||
let digest = hex::encode(&digest);
|
||||
|
||||
let mut list = Vec::new();
|
||||
|
||||
@ -136,7 +137,7 @@ pub fn read_interface(iface: String) -> Result<Value, Error> {
|
||||
let interface = config.lookup(&iface)?;
|
||||
|
||||
let mut data: Value = to_value(interface)?;
|
||||
data["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
data["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(data)
|
||||
}
|
||||
@ -528,7 +529,7 @@ pub fn update_interface(
|
||||
let (mut config, expected_digest) = network::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
@ -668,7 +669,7 @@ pub fn delete_interface(iface: String, digest: Option<String>) -> Result<(), Err
|
||||
let (mut config, expected_digest) = network::config()?;
|
||||
|
||||
if let Some(ref digest) = digest {
|
||||
let digest = proxmox::tools::hex_to_digest(digest)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest)?;
|
||||
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::process::{Command, Stdio};
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{list_subdirs_api_method, Router, Permission, RpcEnvironment, SubdirMap};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||
use anyhow::{Error, format_err, bail};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::sys::linux::procfs;
|
||||
use proxmox_sys::linux::procfs;
|
||||
|
||||
use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
|
||||
use proxmox_schema::api;
|
||||
|
@ -4,7 +4,7 @@ use std::io::{BufRead, BufReader};
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_router::{list_subdirs_api_method, Router, RpcEnvironment, Permission, SubdirMap};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::tools::fs::{file_read_firstline, replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{file_read_firstline, replace_file, CreateOptions};
|
||||
use proxmox_router::{Router, Permission};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -6,8 +6,9 @@ use hyper::header::{self, HeaderValue, UPGRADE};
|
||||
use hyper::http::request::Parts;
|
||||
use hyper::{Body, Response, Request, StatusCode};
|
||||
use serde_json::Value;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox::{identity, sortable};
|
||||
use proxmox_sys::{identity, sortable};
|
||||
use proxmox_router::{
|
||||
http_err, list_subdirs_api_method, ApiHandler, ApiMethod, ApiResponseFuture, Permission,
|
||||
Router, RpcEnvironment, SubdirMap,
|
||||
@ -19,7 +20,7 @@ use pbs_api_types::{
|
||||
CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_READ, PRIV_DATASTORE_BACKUP,
|
||||
BACKUP_ARCHIVE_NAME_SCHEMA,
|
||||
};
|
||||
use pbs_tools::fs::lock_dir_noblock_shared;
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
use pbs_tools::json::{required_integer_param, required_string_param};
|
||||
use pbs_datastore::{DataStore, PROXMOX_BACKUP_READER_PROTOCOL_ID_V1};
|
||||
use pbs_datastore::backup_info::BackupDir;
|
||||
@ -277,7 +278,7 @@ fn download_chunk(
|
||||
let env: &ReaderEnvironment = rpcenv.as_ref();
|
||||
|
||||
let digest_str = required_string_param(¶m, "digest")?;
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
|
||||
if !env.check_chunk_access(digest) {
|
||||
env.log(format!("attempted to download chunk {} which is not in registered chunk list", digest_str));
|
||||
@ -316,7 +317,7 @@ fn download_chunk_old(
|
||||
let env2 = env.clone();
|
||||
|
||||
let digest_str = required_string_param(¶m, "digest")?;
|
||||
let digest = proxmox::tools::hex_to_digest(digest_str)?;
|
||||
let digest = <[u8; 32]>::from_hex(digest_str)?;
|
||||
|
||||
let (path, _) = env.datastore.chunk_path(&digest);
|
||||
|
||||
|
@ -7,7 +7,7 @@ use serde_json::Value;
|
||||
use proxmox_lang::try_block;
|
||||
use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType};
|
||||
use proxmox_schema::api;
|
||||
use proxmox_sys::{task_log, task_warn, worker_task_context::WorkerTaskContext};
|
||||
use proxmox_sys::{task_log, task_warn, WorkerTaskContext};
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, Userid, TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, MediaPoolConfig,
|
||||
@ -147,7 +147,7 @@ pub fn list_tape_backup_jobs(
|
||||
list.push(TapeBackupJobStatus { config: job, status, next_media_label });
|
||||
}
|
||||
|
||||
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
|
||||
rpcenv["digest"] = hex::encode(&digest).into();
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use std::collections::HashMap;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::{sortable, identity};
|
||||
use proxmox_sys::{sortable, identity};
|
||||
use proxmox_router::{
|
||||
list_subdirs_api_method, Permission, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
|
||||
};
|
||||
|
@ -8,13 +8,13 @@ use std::sync::Arc;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_io::ReadExt;
|
||||
use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType};
|
||||
use proxmox_schema::{api, parse_property_string};
|
||||
use proxmox_section_config::SectionConfigData;
|
||||
use proxmox_uuid::Uuid;
|
||||
use proxmox_sys::{task_log, task_warn, worker_task_context::WorkerTaskContext};
|
||||
use proxmox_sys::{task_log, task_warn, WorkerTaskContext};
|
||||
|
||||
use pbs_api_types::{
|
||||
Authid, Userid, CryptMode,
|
||||
@ -1158,7 +1158,7 @@ fn scan_chunk_archive<'a>(
|
||||
worker.check_abort()?;
|
||||
|
||||
if verbose {
|
||||
task_log!(worker, "Found chunk: {}", proxmox::tools::digest_to_hex(&digest));
|
||||
task_log!(worker, "Found chunk: {}", hex::encode(&digest));
|
||||
}
|
||||
|
||||
chunks.push(digest);
|
||||
@ -1193,10 +1193,10 @@ fn restore_chunk_archive<'a>(
|
||||
let chunk_exists = datastore2.cond_touch_chunk(&digest, false)?;
|
||||
if !chunk_exists {
|
||||
if verbose {
|
||||
task_log!(worker2, "Insert chunk: {}", proxmox::tools::digest_to_hex(&digest));
|
||||
task_log!(worker2, "Insert chunk: {}", hex::encode(&digest));
|
||||
}
|
||||
bytes2.fetch_add(chunk.raw_size(), std::sync::atomic::Ordering::SeqCst);
|
||||
// println!("verify and write {}", proxmox::tools::digest_to_hex(&digest));
|
||||
// println!("verify and write {}", hex::encode(&digest));
|
||||
chunk.verify_crc()?;
|
||||
if chunk.crypt_mode()? == CryptMode::None {
|
||||
chunk.decode(None, Some(&digest))?; // verify digest
|
||||
@ -1204,7 +1204,7 @@ fn restore_chunk_archive<'a>(
|
||||
|
||||
datastore2.insert_chunk(&chunk, &digest)?;
|
||||
} else if verbose {
|
||||
task_log!(worker2, "Found existing chunk: {}", proxmox::tools::digest_to_hex(&digest));
|
||||
task_log!(worker2, "Found existing chunk: {}", hex::encode(&digest));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
|
14
src/auth.rs
14
src/auth.rs
@ -75,7 +75,7 @@ const SHADOW_CONFIG_FILENAME: &str = configdir!("/shadow.json");
|
||||
impl ProxmoxAuthenticator for PBS {
|
||||
|
||||
fn authenticate_user(&self, username: &UsernameRef, password: &str) -> Result<(), Error> {
|
||||
let data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
let data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
match data[username.as_str()].as_str() {
|
||||
None => bail!("no password set"),
|
||||
Some(enc_password) => proxmox_sys::crypt::verify_crypt_pw(password, enc_password)?,
|
||||
@ -85,35 +85,35 @@ impl ProxmoxAuthenticator for PBS {
|
||||
|
||||
fn store_password(&self, username: &UsernameRef, password: &str) -> Result<(), Error> {
|
||||
let enc_password = proxmox_sys::crypt::encrypt_pw(password)?;
|
||||
let mut data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
let mut data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
data[username.as_str()] = enc_password.into();
|
||||
|
||||
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
|
||||
let options = proxmox::tools::fs::CreateOptions::new()
|
||||
let options = proxmox_sys::fs::CreateOptions::new()
|
||||
.perm(mode)
|
||||
.owner(nix::unistd::ROOT)
|
||||
.group(nix::unistd::Gid::from_raw(0));
|
||||
|
||||
let data = serde_json::to_vec_pretty(&data)?;
|
||||
proxmox::tools::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
|
||||
proxmox_sys::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_password(&self, username: &UsernameRef) -> Result<(), Error> {
|
||||
let mut data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
let mut data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
|
||||
if let Some(map) = data.as_object_mut() {
|
||||
map.remove(username.as_str());
|
||||
}
|
||||
|
||||
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
|
||||
let options = proxmox::tools::fs::CreateOptions::new()
|
||||
let options = proxmox_sys::fs::CreateOptions::new()
|
||||
.perm(mode)
|
||||
.owner(nix::unistd::ROOT)
|
||||
.group(nix::unistd::Gid::from_raw(0));
|
||||
|
||||
let data = serde_json::to_vec_pretty(&data)?;
|
||||
proxmox::tools::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
|
||||
proxmox_sys::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use openssl::pkey::{PKey, Private, Public};
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::sha;
|
||||
|
||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
|
||||
use proxmox_lang::try_block;
|
||||
|
||||
use pbs_buildcfg::configdir;
|
||||
|
@ -6,14 +6,14 @@ use std::time::Instant;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
|
||||
use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
|
||||
use proxmox_sys::{task_log, WorkerTaskContext};
|
||||
|
||||
use pbs_api_types::{Authid, CryptMode, VerifyState, UPID, SnapshotVerifyState};
|
||||
use pbs_datastore::{DataStore, DataBlob, StoreProgress};
|
||||
use pbs_datastore::backup_info::{BackupGroup, BackupDir, BackupInfo};
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, FileInfo};
|
||||
use pbs_tools::fs::lock_dir_noblock_shared;
|
||||
use proxmox_sys::fs::lock_dir_noblock_shared;
|
||||
|
||||
use crate::tools::ParallelHandler;
|
||||
|
||||
@ -158,7 +158,7 @@ fn verify_index_chunks(
|
||||
if verify_worker.verified_chunks.lock().unwrap().contains(digest) {
|
||||
true
|
||||
} else if verify_worker.corrupt_chunks.lock().unwrap().contains(digest) {
|
||||
let digest_str = proxmox::tools::digest_to_hex(digest);
|
||||
let digest_str = hex::encode(digest);
|
||||
task_log!(verify_worker.worker, "chunk {} was marked as corrupt", digest_str);
|
||||
errors.fetch_add(1, Ordering::SeqCst);
|
||||
true
|
||||
|
@ -10,7 +10,7 @@ use http::HeaderMap;
|
||||
|
||||
use proxmox_lang::try_block;
|
||||
use proxmox_router::{RpcEnvironmentType, UserInformation};
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
|
||||
use proxmox_rest_server::{daemon, AuthError, ApiConfig, RestServer, RestEnvironment, ServerAdapter};
|
||||
|
||||
|
@ -4,7 +4,7 @@ use std::io::{self, Write};
|
||||
use anyhow::Error;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_router::{cli::*, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -17,8 +17,8 @@ use tokio_stream::wrappers::ReceiverStream;
|
||||
use serde_json::{json, Value};
|
||||
use http::{Method, HeaderMap};
|
||||
|
||||
use proxmox::sys::linux::socket::set_tcp_keepalive;
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::linux::socket::set_tcp_keepalive;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_lang::try_block;
|
||||
use proxmox_router::{RpcEnvironment, RpcEnvironmentType, UserInformation};
|
||||
use proxmox_http::client::{RateLimitedStream, ShareableRateLimit};
|
||||
@ -145,7 +145,7 @@ async fn get_index_future(
|
||||
None => (None, None),
|
||||
};
|
||||
|
||||
let nodename = proxmox::tools::nodename();
|
||||
let nodename = proxmox_sys::nodename();
|
||||
let user = userid.as_ref().map(|u| u.as_str()).unwrap_or("");
|
||||
|
||||
let csrf_token = csrf_token.unwrap_or_else(|| String::from(""));
|
||||
@ -815,7 +815,7 @@ async fn schedule_task_log_rotate() {
|
||||
let max_files = 20; // times twenty files gives > 100000 task entries
|
||||
|
||||
let user = pbs_config::backup_user()?;
|
||||
let options = proxmox::tools::fs::CreateOptions::new()
|
||||
let options = proxmox_sys::fs::CreateOptions::new()
|
||||
.owner(user.uid)
|
||||
.group(user.gid);
|
||||
|
||||
@ -949,7 +949,7 @@ async fn generate_host_stats() {
|
||||
}
|
||||
|
||||
fn generate_host_stats_sync() {
|
||||
use proxmox::sys::linux::procfs::{
|
||||
use proxmox_sys::linux::procfs::{
|
||||
read_meminfo, read_proc_stat, read_proc_net_dev, read_loadavg};
|
||||
|
||||
match read_proc_stat() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::Error;
|
||||
use serde_json::json;
|
||||
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_router::{cli::*, RpcEnvironment, ApiHandler};
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
@ -6,6 +6,7 @@ use std::path::Path;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::{json, Value};
|
||||
use walkdir::WalkDir;
|
||||
use hex::FromHex;
|
||||
|
||||
use proxmox_router::cli::{
|
||||
format_and_print_result, get_output_format, CliCommand, CliCommandMap, CommandLineInterface,
|
||||
@ -116,7 +117,7 @@ fn inspect_chunk(
|
||||
|
||||
let digest_raw: Option<[u8; 32]> = digest
|
||||
.map(|ref d| {
|
||||
proxmox::tools::hex_to_digest(d)
|
||||
<[u8; 32]>::from_hex(d)
|
||||
.map_err(|e| format_err!("could not parse chunk - {}", e))
|
||||
})
|
||||
.map_or(Ok(None), |r| r.map(Some))?;
|
||||
@ -291,7 +292,7 @@ fn inspect_file(
|
||||
|
||||
for pos in 0..index.index_count() {
|
||||
let digest = index.index_digest(pos).unwrap();
|
||||
chunk_digests.insert(proxmox::tools::digest_to_hex(digest));
|
||||
chunk_digests.insert(hex::encode(digest));
|
||||
}
|
||||
|
||||
json!({
|
||||
|
@ -5,7 +5,6 @@ use std::path::Path;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools::digest_to_hex;
|
||||
use proxmox_router::cli::{CliCommand, CliCommandMap, CommandLineInterface};
|
||||
use proxmox_schema::api;
|
||||
|
||||
@ -87,7 +86,7 @@ fn recover_index(
|
||||
let mut data = Vec::with_capacity(4 * 1024 * 1024);
|
||||
for pos in 0..index.index_count() {
|
||||
let chunk_digest = index.index_digest(pos).unwrap();
|
||||
let digest_str = digest_to_hex(chunk_digest);
|
||||
let digest_str = hex::encode(chunk_digest);
|
||||
let digest_prefix = &digest_str[0..4];
|
||||
let chunk_path = chunks_path.join(digest_prefix).join(digest_str);
|
||||
let mut chunk_file = std::fs::File::open(&chunk_path)
|
||||
|
@ -3,7 +3,7 @@ use std::io::Write;
|
||||
use anyhow::{bail, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools::fs::file_get_contents;
|
||||
use proxmox_sys::fs::file_get_contents;
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use serde_json::Value;
|
||||
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
use proxmox::sys::linux::tty;
|
||||
use proxmox_sys::linux::tty;
|
||||
|
||||
use pbs_api_types::{
|
||||
Fingerprint, Kdf, DRIVE_NAME_SCHEMA, TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
|
||||
|
@ -5,8 +5,8 @@ use std::path::Path;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::sys::error::SysError;
|
||||
use proxmox::tools::fs::{CreateOptions, file_read_string};
|
||||
use proxmox_sys::error::SysError;
|
||||
use proxmox_sys::fs::{CreateOptions, file_read_string};
|
||||
|
||||
use pbs_api_types::PROXMOX_SAFE_ID_REGEX;
|
||||
|
||||
@ -32,7 +32,7 @@ fn root_only() -> CreateOptions {
|
||||
}
|
||||
|
||||
fn create_acme_subdir(dir: &str) -> nix::Result<()> {
|
||||
match proxmox::tools::fs::create_dir(dir, root_only()) {
|
||||
match proxmox_sys::fs::create_dir(dir, root_only()) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(err) if err.already_exists() => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
@ -70,7 +70,7 @@ pub fn foreach_acme_account<F>(mut func: F) -> Result<(), Error>
|
||||
where
|
||||
F: FnMut(AcmeAccountName) -> ControlFlow<Result<(), Error>>,
|
||||
{
|
||||
match pbs_tools::fs::scan_subdir(-1, ACME_ACCOUNT_DIR, &PROXMOX_SAFE_ID_REGEX) {
|
||||
match proxmox_sys::fs::scan_subdir(-1, ACME_ACCOUNT_DIR, &PROXMOX_SAFE_ID_REGEX) {
|
||||
Ok(files) => {
|
||||
for file in files {
|
||||
let file = file?;
|
||||
|
@ -90,7 +90,7 @@ pub struct DnsPlugin {
|
||||
|
||||
// We handle this property separately in the API calls.
|
||||
/// DNS plugin data (base64url encoded without padding).
|
||||
#[serde(with = "proxmox::tools::serde::string_as_base64url_nopad")]
|
||||
#[serde(with = "proxmox_serde::string_as_base64url_nopad")]
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
|
||||
}
|
||||
|
||||
pub fn config() -> Result<(PluginData, [u8; 32]), Error> {
|
||||
let content = proxmox::tools::fs::file_read_optional_string(ACME_PLUGIN_CFG_FILENAME)?
|
||||
let content = proxmox_sys::fs::file_read_optional_string(ACME_PLUGIN_CFG_FILENAME)?
|
||||
.unwrap_or_else(|| "".to_string());
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
|
@ -104,7 +104,7 @@ pub fn update_self_signed_cert(force: bool) -> Result<(), Error> {
|
||||
let expire = openssl::asn1::Asn1Time::days_from_now(365*1000)?;
|
||||
x509.set_not_after(&expire)?;
|
||||
|
||||
let nodename = proxmox::tools::nodename();
|
||||
let nodename = proxmox_sys::nodename();
|
||||
let mut fqdn = nodename.to_owned();
|
||||
|
||||
let resolv_conf = crate::api2::node::dns::read_etc_resolv_conf()?;
|
||||
|
@ -25,7 +25,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
|
||||
/// Read the Node Config.
|
||||
pub fn config() -> Result<(NodeConfig, [u8; 32]), Error> {
|
||||
let content =
|
||||
proxmox::tools::fs::file_read_optional_string(CONF_FILE)?.unwrap_or_else(|| "".to_string());
|
||||
proxmox_sys::fs::file_read_optional_string(CONF_FILE)?.unwrap_or_else(|| "".to_string());
|
||||
|
||||
let digest = openssl::sha::sha256(content.as_bytes());
|
||||
let data: NodeConfig = crate::tools::config::from_str(&content, &NodeConfig::API_SCHEMA)?;
|
||||
|
@ -7,8 +7,8 @@ use std::path::PathBuf;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use nix::sys::stat::Mode;
|
||||
|
||||
use proxmox::sys::error::SysError;
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::error::SysError;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_tfa::totp::Totp;
|
||||
|
||||
pub use proxmox_tfa::api::{
|
||||
@ -68,7 +68,7 @@ pub fn write(data: &TfaConfig) -> Result<(), Error> {
|
||||
let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
|
||||
|
||||
let json = serde_json::to_vec(data)?;
|
||||
proxmox::tools::fs::replace_file(CONF_FILE, &json, options, true)
|
||||
proxmox_sys::fs::replace_file(CONF_FILE, &json, options, true)
|
||||
}
|
||||
|
||||
/// Cleanup non-existent users from the tfa config.
|
||||
@ -101,7 +101,7 @@ impl TfaUserChallengeData {
|
||||
);
|
||||
}
|
||||
|
||||
proxmox::c_try!(unsafe { libc::ftruncate(self.lock.as_raw_fd(), 0) });
|
||||
proxmox_sys::c_try!(unsafe { libc::ftruncate(self.lock.as_raw_fd(), 0) });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -224,7 +224,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
|
||||
fn open(&self, userid: &str) -> Result<Self::Data, Error> {
|
||||
crate::server::create_run_dir()?;
|
||||
let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
|
||||
proxmox::tools::fs::create_path(CHALLENGE_DATA_PATH, Some(options.clone()), Some(options))
|
||||
proxmox_sys::fs::create_path(CHALLENGE_DATA_PATH, Some(options.clone()), Some(options))
|
||||
.map_err(|err| {
|
||||
format_err!(
|
||||
"failed to crate challenge data dir {:?}: {}",
|
||||
@ -244,7 +244,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
|
||||
.open(&path)
|
||||
.map_err(|err| format_err!("failed to create challenge file {:?}: {}", path, err))?;
|
||||
|
||||
proxmox::tools::fs::lock_file(&mut file, true, None)?;
|
||||
proxmox_sys::fs::lock_file(&mut file, true, None)?;
|
||||
|
||||
// the file may be empty, so read to a temporary buffer first:
|
||||
let mut data = Vec::with_capacity(4096);
|
||||
@ -291,7 +291,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
|
||||
proxmox::tools::fs::lock_file(&mut file, true, None)?;
|
||||
proxmox_sys::fs::lock_file(&mut file, true, None)?;
|
||||
|
||||
let inner = serde_json::from_reader(&mut file).map_err(|err| {
|
||||
format_err!("failed to read challenge data for user {}: {}", userid, err)
|
||||
|
@ -3,7 +3,7 @@ use std::path::Path;
|
||||
use anyhow::{format_err, Error};
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
use proxmox_rrd::RRDCache;
|
||||
use proxmox_rrd::rrd::{RRD, DST, CF};
|
||||
|
||||
|
@ -3,7 +3,7 @@ use serde_json::json;
|
||||
|
||||
use handlebars::{Handlebars, Helper, Context, RenderError, RenderContext, Output, HelperResult, TemplateError};
|
||||
|
||||
use proxmox::tools::email::sendmail;
|
||||
use proxmox_sys::email::sendmail;
|
||||
use proxmox_lang::try_block;
|
||||
use proxmox_schema::{parse_property_string, ApiType};
|
||||
|
||||
@ -239,7 +239,7 @@ fn send_job_status_mail(
|
||||
// so we include html as well
|
||||
let html = format!("<html><body><pre>\n{}\n<pre>", handlebars::html_escape(text));
|
||||
|
||||
let nodename = proxmox::tools::nodename();
|
||||
let nodename = proxmox_sys::nodename();
|
||||
|
||||
let author = format!("Proxmox Backup Server - {}", nodename);
|
||||
|
||||
@ -504,7 +504,7 @@ fn get_server_url() -> (String, usize) {
|
||||
|
||||
// user will surely request that they can change this
|
||||
|
||||
let nodename = proxmox::tools::nodename();
|
||||
let nodename = proxmox_sys::nodename();
|
||||
let mut fqdn = nodename.to_owned();
|
||||
|
||||
if let Ok(resolv_conf) = crate::api2::node::dns::read_etc_resolv_conf() {
|
||||
@ -524,7 +524,7 @@ pub fn send_updates_available(
|
||||
) -> Result<(), Error> {
|
||||
// update mails always go to the root@pam configured email..
|
||||
if let Some(email) = lookup_user_email(Userid::root_userid()) {
|
||||
let nodename = proxmox::tools::nodename();
|
||||
let nodename = proxmox_sys::nodename();
|
||||
let subject = format!("New software packages available ({})", nodename);
|
||||
|
||||
let (fqdn, port) = get_server_url();
|
||||
|
@ -42,7 +42,7 @@ use std::path::{Path, PathBuf};
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox::tools::fs::{
|
||||
use proxmox_sys::fs::{
|
||||
create_path, file_read_optional_string, replace_file, CreateOptions,
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
use anyhow::Error;
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox::tools::fs::{create_path, CreateOptions};
|
||||
use proxmox_sys::fs::{create_path, CreateOptions};
|
||||
|
||||
use pbs_buildcfg;
|
||||
|
||||
|
@ -110,7 +110,7 @@ async fn pull_index_chunks<I: IndexFile>(
|
||||
"sync chunk writer",
|
||||
4,
|
||||
move |(chunk, digest, size): (DataBlob, [u8; 32], u64)| {
|
||||
// println!("verify and write {}", proxmox::tools::digest_to_hex(&digest));
|
||||
// println!("verify and write {}", hex::encode(&digest));
|
||||
chunk.verify_unencrypted(size as usize, &digest)?;
|
||||
target2.insert_chunk(&chunk, &digest)?;
|
||||
Ok(())
|
||||
@ -133,10 +133,10 @@ async fn pull_index_chunks<I: IndexFile>(
|
||||
target.cond_touch_chunk(&info.digest, false)
|
||||
})?;
|
||||
if chunk_exists {
|
||||
//task_log!(worker, "chunk {} exists {}", pos, proxmox::tools::digest_to_hex(digest));
|
||||
//task_log!(worker, "chunk {} exists {}", pos, hex::encode(digest));
|
||||
return Ok::<_, Error>(());
|
||||
}
|
||||
//task_log!(worker, "sync {} chunk {}", pos, proxmox::tools::digest_to_hex(digest));
|
||||
//task_log!(worker, "sync {} chunk {}", pos, hex::encode(digest));
|
||||
let chunk = chunk_reader.read_raw_chunk(&info.digest).await?;
|
||||
let raw_size = chunk.raw_size() as usize;
|
||||
|
||||
|
@ -48,7 +48,7 @@ fn function_calls() -> Vec<FunctionMapping> {
|
||||
}
|
||||
|
||||
pub fn generate_report() -> String {
|
||||
use proxmox::tools::fs::file_read_optional_string;
|
||||
use proxmox_sys::fs::file_read_optional_string;
|
||||
|
||||
let file_contents = files()
|
||||
.iter()
|
||||
|
@ -5,7 +5,7 @@ use std::time::{Instant, Duration};
|
||||
use anyhow::{bail, Error};
|
||||
use nix::sys::stat::Mode;
|
||||
|
||||
use proxmox::tools::fs::{create_path, CreateOptions};
|
||||
use proxmox_sys::fs::{create_path, CreateOptions};
|
||||
|
||||
use proxmox_http::client::{RateLimit, RateLimiter, ShareableRateLimit};
|
||||
use proxmox_shared_memory::{Init, SharedMemory, SharedMutex};
|
||||
|
@ -9,7 +9,7 @@ use std::path::PathBuf;
|
||||
|
||||
use anyhow::{bail, Error};
|
||||
|
||||
use proxmox::tools::fs::{CreateOptions, replace_file, file_read_optional_string};
|
||||
use proxmox_sys::fs::{CreateOptions, replace_file, file_read_optional_string};
|
||||
|
||||
use pbs_api_types::{ScsiTapeChanger, LtoTapeDrive};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use anyhow::Error;
|
||||
|
||||
use pbs_tools::run_command;
|
||||
use proxmox_sys::command::run_command;
|
||||
use pbs_api_types::ScsiTapeChanger;
|
||||
use pbs_tape::MtxStatus;
|
||||
|
||||
|
@ -23,7 +23,7 @@ use pbs_api_types::{
|
||||
Fingerprint, MamAttribute, LtoDriveAndMediaStatus, LtoTapeDrive, Lp17VolumeStatistics,
|
||||
};
|
||||
use pbs_config::key_config::KeyConfig;
|
||||
use pbs_tools::run_command;
|
||||
use proxmox_sys::command::run_command;
|
||||
use pbs_tape::{
|
||||
TapeWrite, TapeRead, BlockReadError, MediaContentHeader,
|
||||
sg_tape::{SgTape, TapeAlertFlags},
|
||||
|
@ -13,21 +13,18 @@ use serde_json::Value;
|
||||
use nix::fcntl::OFlag;
|
||||
use nix::sys::stat::Mode;
|
||||
|
||||
use proxmox::{
|
||||
tools::{
|
||||
fs::{
|
||||
lock_file,
|
||||
atomic_open_or_create_file,
|
||||
file_read_optional_string,
|
||||
replace_file,
|
||||
CreateOptions,
|
||||
}
|
||||
},
|
||||
use proxmox_sys::fs::{
|
||||
lock_file,
|
||||
atomic_open_or_create_file,
|
||||
file_read_optional_string,
|
||||
replace_file,
|
||||
CreateOptions,
|
||||
};
|
||||
|
||||
use proxmox_io::ReadExt;
|
||||
use proxmox_section_config::SectionConfigData;
|
||||
use proxmox_uuid::Uuid;
|
||||
use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
|
||||
use proxmox_sys::{task_log, WorkerTaskContext};
|
||||
|
||||
use pbs_api_types::{VirtualTapeDrive, LtoTapeDrive, Fingerprint};
|
||||
use pbs_config::key_config::KeyConfig;
|
||||
@ -602,7 +599,7 @@ pub struct DeviceLockGuard(std::fs::File);
|
||||
// Uses systemd escape_unit to compute a file name from `device_path`, the try
|
||||
// to lock `/var/lock/<name>`.
|
||||
fn open_device_lock(device_path: &str) -> Result<std::fs::File, Error> {
|
||||
let lock_name = proxmox::tools::systemd::escape_unit(device_path, true);
|
||||
let lock_name = proxmox_sys::systemd::escape_unit(device_path, true);
|
||||
|
||||
let mut path = std::path::PathBuf::from(crate::tape::DRIVE_LOCK_DIR);
|
||||
path.push(lock_name);
|
||||
|
@ -6,7 +6,7 @@ use std::io;
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use proxmox::tools::{
|
||||
use proxmox_sys::{
|
||||
fs::{replace_file, CreateOptions},
|
||||
};
|
||||
|
||||
@ -48,7 +48,7 @@ pub fn open_virtual_tape_drive(config: &VirtualTapeDrive) -> Result<VirtualTapeH
|
||||
|
||||
let options = CreateOptions::new();
|
||||
let timeout = std::time::Duration::new(10, 0);
|
||||
let lock = proxmox::tools::fs::open_file_locked(&lock_path, timeout, true, options)?;
|
||||
let lock = proxmox_sys::fs::open_file_locked(&lock_path, timeout, true, options)?;
|
||||
|
||||
Ok(VirtualTapeHandle {
|
||||
_lock: lock,
|
||||
@ -104,7 +104,7 @@ impl VirtualTapeHandle {
|
||||
|
||||
fn load_tape_index(&self, tape_name: &str) -> Result<TapeIndex, Error> {
|
||||
let path = self.tape_index_path(tape_name);
|
||||
let raw = proxmox::tools::fs::file_get_contents(&path)?;
|
||||
let raw = proxmox_sys::fs::file_get_contents(&path)?;
|
||||
if raw.is_empty() {
|
||||
return Ok(TapeIndex { files: 0 });
|
||||
}
|
||||
@ -147,7 +147,7 @@ impl VirtualTapeHandle {
|
||||
current_tape: None,
|
||||
})?;
|
||||
|
||||
let data = proxmox::tools::fs::file_get_json(&path, Some(default))?;
|
||||
let data = proxmox_sys::fs::file_get_json(&path, Some(default))?;
|
||||
let status: VirtualDriveStatus = serde_json::from_value(data)?;
|
||||
Ok(status)
|
||||
}
|
||||
@ -309,7 +309,7 @@ impl TapeDriver for VirtualTapeHandle {
|
||||
Ok(Box::new(reader))
|
||||
}
|
||||
None => {
|
||||
return Err(BlockReadError::Error(proxmox::io_format_err!("drive is empty (no tape loaded).")));
|
||||
return Err(BlockReadError::Error(proxmox_sys::io_format_err!("drive is empty (no tape loaded).")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ impl TapeDriver for VirtualTapeHandle {
|
||||
|
||||
Ok(writer)
|
||||
}
|
||||
None => proxmox::io_bail!("drive is empty (no tape loaded)."),
|
||||
None => proxmox_sys::io_bail!("drive is empty (no tape loaded)."),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
use proxmox::sys::error::SysError;
|
||||
use proxmox_sys::error::SysError;
|
||||
use proxmox_uuid::Uuid;
|
||||
|
||||
use pbs_tape::{
|
||||
@ -61,13 +61,13 @@ pub fn tape_write_catalog<'a>(
|
||||
while remaining != 0 {
|
||||
let got = file.read(&mut file_copy_buffer[..])?;
|
||||
if got as u64 > remaining {
|
||||
proxmox::io_bail!("catalog '{}' changed while reading", uuid);
|
||||
proxmox_sys::io_bail!("catalog '{}' changed while reading", uuid);
|
||||
}
|
||||
writer.write_all(&file_copy_buffer[..got])?;
|
||||
remaining -= got as u64;
|
||||
}
|
||||
if remaining > 0 {
|
||||
proxmox::io_bail!("catalog '{}' shrunk while reading", uuid);
|
||||
proxmox_sys::io_bail!("catalog '{}' shrunk while reading", uuid);
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ impl <'a> ChunkArchiveWriter<'a> {
|
||||
fn write_all(&mut self, data: &[u8]) -> Result<bool, std::io::Error> {
|
||||
match self.writer {
|
||||
Some(ref mut writer) => writer.write_all(data),
|
||||
None => proxmox::io_bail!(
|
||||
None => proxmox_sys::io_bail!(
|
||||
"detected write after archive finished - internal error"),
|
||||
}
|
||||
}
|
||||
|
@ -48,23 +48,23 @@ impl <'a> Read for MultiVolumeReader<'a> {
|
||||
|
||||
if self.reader.is_none() {
|
||||
let mut reader = (self.next_reader_fn)()
|
||||
.map_err(|err| proxmox::io_format_err!("multi-volume next failed: {}", err))?;
|
||||
.map_err(|err| proxmox_sys::io_format_err!("multi-volume next failed: {}", err))?;
|
||||
|
||||
proxmox_lang::try_block!({
|
||||
let part_header: MediaContentHeader = unsafe { reader.read_le_value()? };
|
||||
self.reader = Some(reader);
|
||||
|
||||
if part_header.uuid != self.header.uuid {
|
||||
proxmox::io_bail!("got wrong part uuid");
|
||||
proxmox_sys::io_bail!("got wrong part uuid");
|
||||
}
|
||||
if part_header.content_magic!= self.header.content_magic {
|
||||
proxmox::io_bail!("got wrong part content magic");
|
||||
proxmox_sys::io_bail!("got wrong part content magic");
|
||||
}
|
||||
|
||||
let expect_part_number = self.header.part_number + 1;
|
||||
|
||||
if part_header.part_number != expect_part_number {
|
||||
proxmox::io_bail!("got wrong part number ({} != {})",
|
||||
proxmox_sys::io_bail!("got wrong part number ({} != {})",
|
||||
part_header.part_number, expect_part_number);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ impl <'a> Read for MultiVolumeReader<'a> {
|
||||
|
||||
Ok(())
|
||||
}).map_err(|err| {
|
||||
proxmox::io_format_err!("multi-volume read content header failed: {}", err)
|
||||
proxmox_sys::io_format_err!("multi-volume read content header failed: {}", err)
|
||||
})?;
|
||||
}
|
||||
|
||||
|
@ -53,16 +53,16 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
|
||||
fn write_all(&mut self, buf: &[u8]) -> Result<bool, std::io::Error> {
|
||||
|
||||
if self.finished {
|
||||
proxmox::io_bail!("multi-volume writer already finished: internal error");
|
||||
proxmox_sys::io_bail!("multi-volume writer already finished: internal error");
|
||||
}
|
||||
|
||||
if self.got_leom {
|
||||
if !self.wrote_header {
|
||||
proxmox::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
|
||||
proxmox_sys::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
|
||||
}
|
||||
let mut writer = match self.writer.take() {
|
||||
Some(writer) => writer,
|
||||
None => proxmox::io_bail!("multi-volume writer: no writer -internal error"),
|
||||
None => proxmox_sys::io_bail!("multi-volume writer: no writer -internal error"),
|
||||
};
|
||||
self.bytes_written = writer.bytes_written();
|
||||
writer.finish(true)?;
|
||||
@ -70,11 +70,11 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
|
||||
|
||||
if self.writer.is_none() {
|
||||
if self.header.part_number >= 255 {
|
||||
proxmox::io_bail!("multi-volume writer: too many parts");
|
||||
proxmox_sys::io_bail!("multi-volume writer: too many parts");
|
||||
}
|
||||
self.writer = Some(
|
||||
(self.next_writer_fn)()
|
||||
.map_err(|err| proxmox::io_format_err!("multi-volume get next volume failed: {}", err))?
|
||||
.map_err(|err| proxmox_sys::io_format_err!("multi-volume get next volume failed: {}", err))?
|
||||
);
|
||||
self.got_leom = false;
|
||||
self.wrote_header = false;
|
||||
@ -107,12 +107,12 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
|
||||
|
||||
fn finish(&mut self, incomplete: bool) -> Result<bool, std::io::Error> {
|
||||
if incomplete {
|
||||
proxmox::io_bail!(
|
||||
proxmox_sys::io_bail!(
|
||||
"incomplete flag makes no sense for multi-volume stream: internal error");
|
||||
}
|
||||
|
||||
match self.writer.take() {
|
||||
None if self.finished => proxmox::io_bail!(
|
||||
None if self.finished => proxmox_sys::io_bail!(
|
||||
"multi-volume writer already finished: internal error"),
|
||||
None => Ok(false),
|
||||
Some(ref mut writer) => {
|
||||
|
@ -2,7 +2,7 @@ use std::io::{Read, Write};
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use proxmox::sys::error::SysError;
|
||||
use proxmox_sys::error::SysError;
|
||||
use proxmox_uuid::Uuid;
|
||||
|
||||
use pbs_tape::{
|
||||
@ -58,14 +58,14 @@ pub fn tape_write_snapshot_archive<'a>(
|
||||
for filename in file_list.iter() {
|
||||
|
||||
let mut file = snapshot_reader.open_file(filename)
|
||||
.map_err(|err| proxmox::io_format_err!("open file '{}' failed - {}", filename, err))?;
|
||||
.map_err(|err| proxmox_sys::io_format_err!("open file '{}' failed - {}", filename, err))?;
|
||||
let metadata = file.metadata()?;
|
||||
let file_size = metadata.len();
|
||||
|
||||
let metadata: pxar::Metadata = metadata.into();
|
||||
|
||||
if !metadata.is_regular_file() {
|
||||
proxmox::io_bail!("file '{}' is not a regular file", filename);
|
||||
proxmox_sys::io_bail!("file '{}' is not a regular file", filename);
|
||||
}
|
||||
|
||||
let mut remaining = file_size;
|
||||
@ -73,14 +73,14 @@ pub fn tape_write_snapshot_archive<'a>(
|
||||
while remaining != 0 {
|
||||
let got = file.read(&mut file_copy_buffer[..])?;
|
||||
if got as u64 > remaining {
|
||||
proxmox::io_bail!("file '{}' changed while reading", filename);
|
||||
proxmox_sys::io_bail!("file '{}' changed while reading", filename);
|
||||
}
|
||||
out.write_all(&file_copy_buffer[..got])?;
|
||||
remaining -= got as u64;
|
||||
|
||||
}
|
||||
if remaining > 0 {
|
||||
proxmox::io_bail!("file '{}' shrunk while reading", filename);
|
||||
proxmox_sys::io_bail!("file '{}' shrunk while reading", filename);
|
||||
}
|
||||
}
|
||||
encoder.finish()?;
|
||||
|
@ -30,7 +30,7 @@ use anyhow::{bail, Error};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde_json::json;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, file_get_json, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, file_get_json, CreateOptions};
|
||||
use proxmox_uuid::Uuid;
|
||||
|
||||
use proxmox_time::compute_next_event;
|
||||
|
@ -8,10 +8,10 @@ use std::collections::{HashSet, HashMap};
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use endian_trait::Endian;
|
||||
|
||||
use pbs_tools::fs::read_subdir;
|
||||
use proxmox_sys::fs::read_subdir;
|
||||
use pbs_datastore::backup_info::BackupDir;
|
||||
|
||||
use proxmox::tools::fs::{
|
||||
use proxmox_sys::fs::{
|
||||
fchown,
|
||||
create_path,
|
||||
CreateOptions,
|
||||
@ -541,7 +541,7 @@ impl MediaCatalog {
|
||||
};
|
||||
|
||||
if self.log_to_stdout {
|
||||
println!("C|{}", proxmox::tools::digest_to_hex(digest));
|
||||
println!("C|{}", hex::encode(digest));
|
||||
}
|
||||
|
||||
self.pending.push(b'C');
|
||||
|
@ -3,7 +3,7 @@ use std::io::{BufRead, BufReader};
|
||||
|
||||
use anyhow::{format_err, bail, Error};
|
||||
|
||||
use proxmox::tools::fs::CreateOptions;
|
||||
use proxmox_sys::fs::CreateOptions;
|
||||
|
||||
use crate::tape::{MediaCatalog, MediaId};
|
||||
|
||||
@ -98,7 +98,7 @@ fn write_snapshot_cache(
|
||||
.owner(backup_user.uid)
|
||||
.group(backup_user.gid);
|
||||
|
||||
proxmox::tools::fs::replace_file(
|
||||
proxmox_sys::fs::replace_file(
|
||||
cache_path,
|
||||
data.as_bytes(),
|
||||
options,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use anyhow::{format_err, Error};
|
||||
|
||||
use proxmox::tools::fs::{
|
||||
use proxmox_sys::fs::{
|
||||
create_path,
|
||||
CreateOptions,
|
||||
};
|
||||
|
@ -554,7 +554,7 @@ fn write_chunk_archive<'a>(
|
||||
Some(Err(err)) => bail!("{}", err),
|
||||
};
|
||||
|
||||
//println!("CHUNK {} size {}", proxmox::tools::digest_to_hex(digest), blob.raw_size());
|
||||
//println!("CHUNK {} size {}", hex::encode(digest), blob.raw_size());
|
||||
|
||||
match writer.try_write_chunk(&digest, &blob) {
|
||||
Ok(true) => {
|
||||
|
@ -58,7 +58,7 @@ impl NewChunksIterator {
|
||||
};
|
||||
|
||||
let blob = datastore.load_chunk(&digest)?;
|
||||
//println!("LOAD CHUNK {}", proxmox::tools::digest_to_hex(&digest));
|
||||
//println!("LOAD CHUNK {}", hex::encode(&digest));
|
||||
match tx.send(Ok(Some((digest, blob)))) {
|
||||
Ok(()) => {},
|
||||
Err(err) => {
|
||||
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
||||
use anyhow::{Error, bail, format_err};
|
||||
use apt_pkg_native::Cache;
|
||||
|
||||
use proxmox::tools::fs::{file_read_optional_string, replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{file_read_optional_string, replace_file, CreateOptions};
|
||||
use proxmox_schema::const_regex;
|
||||
|
||||
use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M;
|
||||
@ -102,7 +102,7 @@ fn get_changelog_url(
|
||||
command.arg("changelog");
|
||||
command.arg("--print-uris");
|
||||
command.arg(package);
|
||||
let output = pbs_tools::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
|
||||
let output = proxmox_sys::command::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
|
||||
let output = match output.splitn(2, ' ').next() {
|
||||
Some(output) => {
|
||||
if output.len() < 2 {
|
||||
|
@ -27,7 +27,7 @@ pub fn get_lvm_devices(
|
||||
let mut command = std::process::Command::new(PVS_BIN_PATH);
|
||||
command.args(&["--reportformat", "json", "--noheadings", "--readonly", "-o", "pv_name"]);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
let mut device_set: HashSet<u64> = HashSet::new();
|
||||
|
||||
|
@ -14,9 +14,9 @@ use once_cell::sync::OnceCell;
|
||||
|
||||
use ::serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox::sys::error::io_err_other;
|
||||
use proxmox::sys::linux::procfs::{MountInfo, mountinfo::Device};
|
||||
use proxmox::{io_bail, io_format_err};
|
||||
use proxmox_sys::error::io_err_other;
|
||||
use proxmox_sys::linux::procfs::{MountInfo, mountinfo::Device};
|
||||
use proxmox_sys::{io_bail, io_format_err};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use pbs_api_types::{BLOCKDEVICE_NAME_REGEX, StorageStatus};
|
||||
@ -498,7 +498,7 @@ impl Disk {
|
||||
|
||||
let mut map = HashMap::new();
|
||||
|
||||
for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, sys_path)? {
|
||||
for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, sys_path)? {
|
||||
let item = item?;
|
||||
let name = match item.file_name().to_str() {
|
||||
Ok(name) => name,
|
||||
@ -574,7 +574,7 @@ pub fn get_lsblk_info() -> Result<Vec<LsblkInfo>, Error> {
|
||||
let mut command = std::process::Command::new("lsblk");
|
||||
command.args(&["--json", "-o", "path,parttype,fstype"]);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
let mut output: serde_json::Value = output.parse()?;
|
||||
|
||||
@ -680,7 +680,7 @@ fn scan_partitions(
|
||||
let mut found_dm = false;
|
||||
let mut found_partitions = false;
|
||||
|
||||
for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, &sys_path)? {
|
||||
for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &sys_path)? {
|
||||
let item = item?;
|
||||
let name = match item.file_name().to_str() {
|
||||
Ok(name) => name,
|
||||
@ -770,7 +770,7 @@ pub fn get_disks(
|
||||
|
||||
let mut result = HashMap::new();
|
||||
|
||||
for item in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX)? {
|
||||
for item in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX)? {
|
||||
let item = item?;
|
||||
|
||||
let name = item.file_name().to_str().unwrap().to_string();
|
||||
@ -886,7 +886,7 @@ pub fn reread_partition_table(disk: &Disk) -> Result<(), Error> {
|
||||
command.arg("--rereadpt");
|
||||
command.arg(disk_path);
|
||||
|
||||
pbs_tools::run_command(command, None)?;
|
||||
proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -905,7 +905,7 @@ pub fn inititialize_gpt_disk(disk: &Disk, uuid: Option<&str>) -> Result<(), Erro
|
||||
command.arg(disk_path);
|
||||
command.args(&["-U", uuid]);
|
||||
|
||||
pbs_tools::run_command(command, None)?;
|
||||
proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -922,7 +922,7 @@ pub fn create_single_linux_partition(disk: &Disk) -> Result<Disk, Error> {
|
||||
command.args(&["-n1", "-t1:8300"]);
|
||||
command.arg(disk_path);
|
||||
|
||||
pbs_tools::run_command(command, None)?;
|
||||
proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
let mut partitions = disk.partitions()?;
|
||||
|
||||
@ -975,7 +975,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
|
||||
command.args(&["-t", &fs_type]);
|
||||
command.arg(disk_path);
|
||||
|
||||
pbs_tools::run_command(command, None)?;
|
||||
proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -984,7 +984,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
|
||||
pub fn complete_disk_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
let dir = match pbs_tools::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX) {
|
||||
let dir = match proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX) {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => return list,
|
||||
};
|
||||
@ -1013,7 +1013,7 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
|
||||
command.args(&["-o", "export"]);
|
||||
command.arg(disk_path);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
for line in output.lines() {
|
||||
if let Some(uuid) = line.strip_prefix("UUID=") {
|
||||
|
@ -91,7 +91,7 @@ pub fn get_smart_data(
|
||||
};
|
||||
command.arg(disk_path);
|
||||
|
||||
let output = pbs_tools::run_command(command, Some(|exitcode|
|
||||
let output = proxmox_sys::command::run_command(command, Some(|exitcode|
|
||||
(exitcode & 0b0111) == 0 // only bits 0-2 are fatal errors
|
||||
))?;
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub fn zfs_pool_stats(pool: &OsStr) -> Result<Option<BlockDevStat>, Error> {
|
||||
path.push(pool);
|
||||
path.push("io");
|
||||
|
||||
let text = match proxmox::tools::fs::file_read_optional_string(&path)? {
|
||||
let text = match proxmox_sys::fs::file_read_optional_string(&path)? {
|
||||
Some(text) => text,
|
||||
None => { return Ok(None); }
|
||||
};
|
||||
|
@ -147,7 +147,7 @@ pub fn zpool_list(pool: Option<String>, verbose: bool) -> Result<Vec<ZFSPoolInfo
|
||||
|
||||
if let Some(pool) = pool { command.arg(pool); }
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
parse_zpool_list(&output)
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ pub fn zpool_status(pool: &str) -> Result<Vec<(String, String)>, Error> {
|
||||
let mut command = std::process::Command::new("zpool");
|
||||
command.args(&["status", "-p", "-P", pool]);
|
||||
|
||||
let output = pbs_tools::run_command(command, None)?;
|
||||
let output = proxmox_sys::command::run_command(command, None)?;
|
||||
|
||||
parse_zpool_status(&output)
|
||||
}
|
||||
|
@ -18,5 +18,5 @@ use tokio::{
|
||||
};
|
||||
use tokio_openssl::SslStream;
|
||||
|
||||
use proxmox::sys::linux::socket::set_tcp_keepalive;
|
||||
use proxmox_sys::linux::socket::set_tcp_keepalive;
|
||||
use proxmox_http::http::{MaybeTlsStream, ProxyConfig};
|
||||
|
@ -32,12 +32,12 @@ pub fn md5sum(data: &[u8]) -> Result<DigestBytes, Error> {
|
||||
pub fn get_hardware_address() -> Result<String, Error> {
|
||||
static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub";
|
||||
|
||||
let contents = proxmox::tools::fs::file_get_contents(FILENAME)
|
||||
let contents = proxmox_sys::fs::file_get_contents(FILENAME)
|
||||
.map_err(|e| format_err!("Error getting host key - {}", e))?;
|
||||
let digest = md5sum(&contents)
|
||||
.map_err(|e| format_err!("Error digesting host key - {}", e))?;
|
||||
|
||||
Ok(proxmox::tools::bin_to_hex(&digest).to_uppercase())
|
||||
Ok(hex::encode(&digest).to_uppercase())
|
||||
}
|
||||
|
||||
pub fn assert_if_modified(digest1: &str, digest2: &str) -> Result<(), Error> {
|
||||
|
@ -6,7 +6,7 @@ use serde_json::json;
|
||||
|
||||
use proxmox_schema::api;
|
||||
|
||||
use proxmox::tools::fs::{replace_file, CreateOptions};
|
||||
use proxmox_sys::fs::{replace_file, CreateOptions};
|
||||
use proxmox_http::client::SimpleHttp;
|
||||
|
||||
use pbs_tools::json::json_object_to_query;
|
||||
@ -99,7 +99,7 @@ async fn register_subscription(
|
||||
checktime: i64
|
||||
) -> Result<(String, String), Error> {
|
||||
// WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple
|
||||
let rand = proxmox::tools::bin_to_hex(&proxmox::sys::linux::random_data(16)?);
|
||||
let rand = hex::encode(&proxmox_sys::linux::random_data(16)?);
|
||||
let challenge = format!("{}{}", checktime, rand);
|
||||
|
||||
let params = json!({
|
||||
@ -180,7 +180,7 @@ fn parse_register_response(
|
||||
|
||||
if let SubscriptionStatus::ACTIVE = info.status {
|
||||
let response_raw = format!("{}{}", SHARED_KEY_DATA, challenge);
|
||||
let expected = proxmox::tools::bin_to_hex(&tools::md5sum(response_raw.as_bytes())?);
|
||||
let expected = hex::encode(&tools::md5sum(response_raw.as_bytes())?);
|
||||
if expected != md5hash {
|
||||
bail!("Subscription API challenge failed, expected {} != got {}", expected, md5hash);
|
||||
}
|
||||
@ -241,7 +241,7 @@ pub fn check_subscription(key: String, server_id: String) -> Result<Subscription
|
||||
/// reads in subscription information and does a basic integrity verification
|
||||
pub fn read_subscription() -> Result<Option<SubscriptionInfo>, Error> {
|
||||
|
||||
let cfg = proxmox::tools::fs::file_read_optional_string(&SUBSCRIPTION_FN)?;
|
||||
let cfg = proxmox_sys::fs::file_read_optional_string(&SUBSCRIPTION_FN)?;
|
||||
let cfg = if let Some(cfg) = cfg { cfg } else { return Ok(None); };
|
||||
|
||||
let mut cfg = cfg.lines();
|
||||
|
@ -6,7 +6,7 @@ use super::types::*;
|
||||
use proxmox_schema::*;
|
||||
use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
|
||||
|
||||
use proxmox::tools::{fs::replace_file, fs::CreateOptions};
|
||||
use proxmox_sys::{fs::replace_file, fs::CreateOptions};
|
||||
|
||||
|
||||
lazy_static! {
|
||||
@ -104,7 +104,7 @@ fn init_mount() -> SectionConfig {
|
||||
|
||||
fn parse_systemd_config(config: &SectionConfig, filename: &str) -> Result<SectionConfigData, Error> {
|
||||
|
||||
let raw = proxmox::tools::fs::file_get_contents(filename)?;
|
||||
let raw = proxmox_sys::fs::file_get_contents(filename)?;
|
||||
let input = String::from_utf8(raw)?;
|
||||
|
||||
let data = config.parse(filename, &input)?;
|
||||
|
@ -97,7 +97,7 @@ pub fn reload_unit(unit: &str) -> Result<(), Error> {
|
||||
fn test_escape_unit() -> Result<(), Error> {
|
||||
fn test_escape(i: &str, expected: &str, is_path: bool) {
|
||||
|
||||
use proxmox::tools::systemd::{escape_unit, unescape_unit};
|
||||
use proxmox_sys::systemd::{escape_unit, unescape_unit};
|
||||
|
||||
let escaped = escape_unit(i, is_path);
|
||||
assert_eq!(escaped, expected);
|
||||
|
Reference in New Issue
Block a user